xref: /aosp_15_r20/system/libbase/README.md (revision 8f0ba417480079999ba552f1087ae592091b9d02)
1*8f0ba417SAndroid Build Coastguard Worker# libbase
2*8f0ba417SAndroid Build Coastguard Worker
3*8f0ba417SAndroid Build Coastguard Worker## Who is this library for?
4*8f0ba417SAndroid Build Coastguard Worker
5*8f0ba417SAndroid Build Coastguard WorkerThis library is a collection of convenience functions to make common tasks
6*8f0ba417SAndroid Build Coastguard Workereasier and less error-prone.
7*8f0ba417SAndroid Build Coastguard Worker
8*8f0ba417SAndroid Build Coastguard WorkerIn this context, "error-prone" covers both "hard to do correctly" and
9*8f0ba417SAndroid Build Coastguard Worker"hard to do with good performance", but as a general purpose library,
10*8f0ba417SAndroid Build Coastguard Workerlibbase's primary focus is on making it easier to do things easily and
11*8f0ba417SAndroid Build Coastguard Workercorrectly when a compromise has to be made between "simplest API" on the
12*8f0ba417SAndroid Build Coastguard Workerone hand and "fastest implementation" on the other. Though obviously
13*8f0ba417SAndroid Build Coastguard Workerthe ideal is to have both.
14*8f0ba417SAndroid Build Coastguard Worker
15*8f0ba417SAndroid Build Coastguard Worker## Should my routine be added?
16*8f0ba417SAndroid Build Coastguard Worker
17*8f0ba417SAndroid Build Coastguard WorkerThe intention is to cover the 80% use cases, not be all things to all users.
18*8f0ba417SAndroid Build Coastguard Worker
19*8f0ba417SAndroid Build Coastguard WorkerIf you have a routine that's really useful in your project,
20*8f0ba417SAndroid Build Coastguard Workercongratulations. But that doesn't mean it should be here rather than
21*8f0ba417SAndroid Build Coastguard Workerjust in your project.
22*8f0ba417SAndroid Build Coastguard Worker
23*8f0ba417SAndroid Build Coastguard WorkerThe question for libbase is "should everyone be doing this?"/"does this
24*8f0ba417SAndroid Build Coastguard Workermake everyone's code cleaner/safer?". Historically we've considered the
25*8f0ba417SAndroid Build Coastguard Workerbar for inclusion to be "are there at least three *unrelated* projects
26*8f0ba417SAndroid Build Coastguard Workerthat would be cleaned up by doing so".
27*8f0ba417SAndroid Build Coastguard Worker
28*8f0ba417SAndroid Build Coastguard WorkerIf your routine is actually something from a future C++ standard (that
29*8f0ba417SAndroid Build Coastguard Workerisn't yet in libc++), or it's widely used in another library, that helps
30*8f0ba417SAndroid Build Coastguard Workershow that there's precedent. Being able to say "so-and-so has used this
31*8f0ba417SAndroid Build Coastguard WorkerAPI for n years" is a good way to reduce concerns about API choices.
32*8f0ba417SAndroid Build Coastguard Worker
33*8f0ba417SAndroid Build Coastguard Worker## Any other restrictions?
34*8f0ba417SAndroid Build Coastguard Worker
35*8f0ba417SAndroid Build Coastguard WorkerUnlike most Android code, code in libbase has to build for Mac and
36*8f0ba417SAndroid Build Coastguard WorkerWindows too.
37*8f0ba417SAndroid Build Coastguard Worker
38*8f0ba417SAndroid Build Coastguard WorkerCode here is also expected to have good test coverage.
39*8f0ba417SAndroid Build Coastguard Worker
40*8f0ba417SAndroid Build Coastguard WorkerBy its nature, it's difficult to change libbase API. It's often best
41*8f0ba417SAndroid Build Coastguard Workerto start using your routine just in your project, and let it "graduate"
42*8f0ba417SAndroid Build Coastguard Workerafter you're certain that the API is solid.
43