blob: ef566927f396c561e398a971f330cd99cbf67694 [file] [log] [blame]
Colin Crosscaaeb282016-07-11 14:15:31 -07001//
2// Copyright (C) 2015 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Bob Badour13ec36b2021-02-03 20:08:34 -080017package {
18 default_applicable_licenses: ["system_libbase_license"],
19}
20
21license {
22 name: "system_libbase_license",
23 visibility: [":__subpackages__"],
24 license_kinds: [
25 "SPDX-license-identifier-Apache-2.0",
26 "SPDX-license-identifier-BSD",
27 ],
28 license_text: [
29 "NOTICE",
30 ],
31}
32
Chih-Hung Hsieh6f36fb02017-10-02 15:20:07 -070033cc_defaults {
Andreas Gampeed917072018-02-15 11:40:30 -080034 name: "libbase_cflags_defaults",
Elliott Hughesa72e3f62018-02-16 17:58:14 -080035 cflags: [
36 "-Wall",
37 "-Werror",
38 "-Wextra",
39 ],
Paul Crowleyd47a8d72019-09-11 15:31:55 -070040 target: {
41 android: {
42 cflags: [
43 "-D_FILE_OFFSET_BITS=64",
44 ],
45 },
46 },
Chih-Hung Hsieh6f36fb02017-10-02 15:20:07 -070047}
Colin Crosscaaeb282016-07-11 14:15:31 -070048
Steven Morelanda347b772017-04-14 00:54:46 -070049cc_library_headers {
50 name: "libbase_headers",
51 vendor_available: true,
Justin Yun43e23542020-11-11 19:21:37 +090052 product_available: true,
Yifan Hong5afe8b72020-01-21 18:17:19 -080053 ramdisk_available: true,
Yifan Hong9091f312020-10-21 18:22:17 -070054 vendor_ramdisk_available: true,
Jiyong Parkb51bddd2018-04-27 21:48:43 +090055 recovery_available: true,
Steven Morelanda347b772017-04-14 00:54:46 -070056 host_supported: true,
dimitry3b9b11e2019-05-06 14:01:58 +020057 native_bridge_supported: true,
Steven Morelanda347b772017-04-14 00:54:46 -070058 export_include_dirs: ["include"],
59
Jiyong Park7706f492021-12-14 22:33:38 +090060 header_libs: ["fmtlib_headers"],
61 export_header_lib_headers: ["fmtlib_headers"],
62
Steven Morelanda347b772017-04-14 00:54:46 -070063 target: {
64 linux_bionic: {
65 enabled: true,
66 },
67 windows: {
68 enabled: true,
69 },
70 },
Jiyong Park2c7409d2020-03-07 16:36:09 +090071 apex_available: [
72 "//apex_available:anyapex",
73 "//apex_available:platform",
74 ],
Jooyung Hance659962020-04-16 18:48:33 +090075 min_sdk_version: "29",
Steven Morelanda347b772017-04-14 00:54:46 -070076}
77
Andreas Gampeed917072018-02-15 11:40:30 -080078cc_defaults {
79 name: "libbase_defaults",
80 defaults: ["libbase_cflags_defaults"],
Colin Crosscaaeb282016-07-11 14:15:31 -070081 srcs: [
Josh Gaoe4401992019-04-25 14:04:57 -070082 "abi_compatibility.cpp",
Mark Salyzyn764a9c72018-02-05 07:41:31 -080083 "chrono_utils.cpp",
Josh Gaoc50f38f2019-01-07 19:16:21 -080084 "cmsg.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -070085 "file.cpp",
Steven Morelanda7ec8ba2021-07-23 18:10:35 -070086 "hex.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -070087 "logging.cpp",
Elliott Hughes51140082018-10-19 16:09:39 -070088 "mapped_file.cpp",
Daniel Colascione57fceb92019-11-14 00:48:36 -080089 "parsebool.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -070090 "parsenetaddress.cpp",
Colin Cross4bea6552021-12-21 13:54:40 -080091 "posix_strerror_r.cpp",
Tom Cherry3f82dfb2019-06-28 11:09:33 -070092 "process.cpp",
Elliott Hughes083c2fe2018-05-24 18:00:39 -070093 "properties.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -070094 "stringprintf.cpp",
95 "strings.cpp",
Josh Gaoef102be2018-03-16 14:25:42 -070096 "threads.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -070097 "test_utils.cpp",
98 ],
Steven Morelanda347b772017-04-14 00:54:46 -070099
Pirama Arumuga Nainar00b10a82018-09-26 23:31:00 -0700100 cppflags: ["-Wexit-time-destructors"],
Colin Crosscaaeb282016-07-11 14:15:31 -0700101 shared_libs: ["liblog"],
102 target: {
103 android: {
Elliott Hughes83b00972017-02-14 15:46:33 -0800104 sanitize: {
105 misc_undefined: ["integer"],
106 },
James Hawkins99574972017-03-24 11:43:02 -0700107
Colin Crosscaaeb282016-07-11 14:15:31 -0700108 },
Dan Willemsen2cb672f2017-10-03 14:17:31 -0700109 linux: {
110 srcs: [
Dan Willemsen2cb672f2017-10-03 14:17:31 -0700111 "errors_unix.cpp",
112 ],
Dan Willemsen2cb672f2017-10-03 14:17:31 -0700113 },
Colin Crosscaaeb282016-07-11 14:15:31 -0700114 darwin: {
James Hawkins99574972017-03-24 11:43:02 -0700115 srcs: [
James Hawkins99574972017-03-24 11:43:02 -0700116 "errors_unix.cpp",
117 ],
Colin Crosscaaeb282016-07-11 14:15:31 -0700118 },
Dan Willemsen15acb592016-11-29 13:32:55 -0800119 linux_bionic: {
Dan Willemsen15acb592016-11-29 13:32:55 -0800120 enabled: true,
121 },
Colin Crosscaaeb282016-07-11 14:15:31 -0700122 windows: {
123 srcs: [
124 "errors_windows.cpp",
125 "utf8.cpp",
126 ],
Josh Gaoc50f38f2019-01-07 19:16:21 -0800127 exclude_srcs: [
128 "cmsg.cpp",
129 ],
Colin Crosscaaeb282016-07-11 14:15:31 -0700130 enabled: true,
131 },
132 },
Nikita Ioffe9ac27c72020-10-28 00:44:53 +0000133 min_sdk_version: "29",
Colin Crosscaaeb282016-07-11 14:15:31 -0700134}
135
Andreas Gampeed917072018-02-15 11:40:30 -0800136cc_library {
137 name: "libbase",
138 defaults: ["libbase_defaults"],
139 vendor_available: true,
Justin Yun43e23542020-11-11 19:21:37 +0900140 product_available: true,
Yifan Hong5afe8b72020-01-21 18:17:19 -0800141 ramdisk_available: true,
Yifan Hong9091f312020-10-21 18:22:17 -0700142 vendor_ramdisk_available: true,
Jiyong Park9670f162018-05-24 14:11:00 +0900143 recovery_available: true,
Andreas Gampeed917072018-02-15 11:40:30 -0800144 host_supported: true,
dimitry3b9b11e2019-05-06 14:01:58 +0200145 native_bridge_supported: true,
Andreas Gampeed917072018-02-15 11:40:30 -0800146 vndk: {
147 enabled: true,
148 support_system_process: true,
149 },
150 header_libs: [
151 "libbase_headers",
152 ],
153 export_header_lib_headers: ["libbase_headers"],
Jiyong Park4e223e62019-06-12 16:25:04 +0900154 whole_static_libs: ["fmtlib"],
Jiyong Park7706f492021-12-14 22:33:38 +0900155 export_static_lib_headers: ["fmtlib"],
Jeffrey Huang728e33b2020-02-14 10:27:17 -0800156 apex_available: [
157 "//apex_available:anyapex",
158 "//apex_available:platform",
159 ],
Andreas Gampeed917072018-02-15 11:40:30 -0800160}
161
162cc_library_static {
163 name: "libbase_ndk",
164 defaults: ["libbase_defaults"],
165 sdk_version: "current",
166 stl: "c++_static",
167 export_include_dirs: ["include"],
Jiyong Park4e223e62019-06-12 16:25:04 +0900168 whole_static_libs: ["fmtlib_ndk"],
Andreas Gampeed917072018-02-15 11:40:30 -0800169}
170
Colin Crosscaaeb282016-07-11 14:15:31 -0700171// Tests
172// ------------------------------------------------------------------------------
173cc_test {
174 name: "libbase_test",
Andreas Gampeed917072018-02-15 11:40:30 -0800175 defaults: ["libbase_cflags_defaults"],
Colin Crosscaaeb282016-07-11 14:15:31 -0700176 host_supported: true,
Tom Cherryaa817612020-07-14 11:23:39 -0700177 require_root: true,
Colin Crosscaaeb282016-07-11 14:15:31 -0700178 srcs: [
Josh Gaoc50f38f2019-01-07 19:16:21 -0800179 "cmsg_test.cpp",
Elliott Hughes08baa862017-02-24 14:02:05 -0800180 "endian_test.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -0700181 "errors_test.cpp",
Jiyong Parkde84d4a2019-05-15 19:17:48 +0900182 "expected_test.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -0700183 "file_test.cpp",
Yurii Zubrytskyi68ce05e2021-02-19 00:07:31 -0800184 "function_ref_test.cpp",
Steven Morelanda7ec8ba2021-07-23 18:10:35 -0700185 "hex_test.cpp",
Tom Cherrya6872422020-04-17 13:05:11 -0700186 "logging_splitters_test.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -0700187 "logging_test.cpp",
Elliott Hughesda37d812018-04-06 17:45:22 -0700188 "macros_test.cpp",
Elliott Hughes51140082018-10-19 16:09:39 -0700189 "mapped_file_test.cpp",
Josh Gao916ea5e2019-11-14 17:59:57 -0800190 "no_destructor_test.cpp",
Yabin Cuiebe8eef2016-10-05 10:54:35 -0700191 "parsedouble_test.cpp",
Daniel Colascione57fceb92019-11-14 00:48:36 -0800192 "parsebool_test.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -0700193 "parseint_test.cpp",
194 "parsenetaddress_test.cpp",
Tom Cherry3f82dfb2019-06-28 11:09:33 -0700195 "process_test.cpp",
Elliott Hughes083c2fe2018-05-24 18:00:39 -0700196 "properties_test.cpp",
Jiyong Parkab7dc5a2019-05-31 03:43:34 +0900197 "result_test.cpp",
Tom Cherry1d273062017-04-05 14:15:31 -0700198 "scopeguard_test.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -0700199 "stringprintf_test.cpp",
200 "strings_test.cpp",
201 "test_main.cpp",
Josh Gao8f1fa002017-04-27 19:48:44 -0700202 "test_utils_test.cpp",
Colin Crosscaaeb282016-07-11 14:15:31 -0700203 ],
204 target: {
Elliott Hughes5a7788c2016-09-21 16:53:15 -0700205 android: {
Elliott Hughes83b00972017-02-14 15:46:33 -0800206 sanitize: {
207 misc_undefined: ["integer"],
208 },
Elliott Hughes5a7788c2016-09-21 16:53:15 -0700209 },
Dan Willemsen2cb672f2017-10-03 14:17:31 -0700210 linux: {
James Hawkins99574972017-03-24 11:43:02 -0700211 srcs: ["chrono_utils_test.cpp"],
James Hawkins99574972017-03-24 11:43:02 -0700212 },
Colin Crosscaaeb282016-07-11 14:15:31 -0700213 windows: {
214 srcs: ["utf8_test.cpp"],
Dan Willemsenb80b3d52017-11-29 18:06:11 -0800215 cflags: ["-Wno-unused-parameter"],
Colin Crosscaaeb282016-07-11 14:15:31 -0700216 enabled: true,
217 },
218 },
219 local_include_dirs: ["."],
Colin Crosscaaeb282016-07-11 14:15:31 -0700220 shared_libs: ["libbase"],
Yifan Hongf21c5462021-05-21 18:43:16 -0700221 static_libs: ["libgmock"],
Colin Crosscaaeb282016-07-11 14:15:31 -0700222 compile_multilib: "both",
223 multilib: {
224 lib32: {
225 suffix: "32",
226 },
227 lib64: {
228 suffix: "64",
229 },
230 },
Elliott Hughesefdeefd2018-04-27 16:12:06 -0700231 test_suites: ["device-tests"],
Colin Crosscaaeb282016-07-11 14:15:31 -0700232}
Tom Cherry377d1ad2019-06-14 14:34:54 -0700233
Josh Gao89e50182020-03-09 12:05:32 -0700234cc_test {
235 name: "libbase_tidy_test",
236 defaults: ["libbase_cflags_defaults"],
237 host_supported: true,
238
239 tidy: true,
240 tidy_checks_as_errors: ["bugprone-use-after-move"],
241
242 srcs: [
243 "tidy/unique_fd_test.cpp",
244 "tidy/unique_fd_test2.cpp",
245 ],
246
247 shared_libs: ["libbase"],
248 test_suites: ["device_tests"],
249}
250
Atneya Nair6a6a7e52022-02-11 18:18:23 -0500251// Can be removed when we move to c++20
252cc_test {
253 name: "libbase_result_constraint_test",
254 defaults: ["libbase_cflags_defaults"],
255 host_supported: true,
256 srcs: [
257 "result_test_constraint.cpp",
258 ],
259 target: {
260 android: {
261 sanitize: {
262 misc_undefined: ["integer"],
263 },
264 },
265 },
266 cpp_std: "gnu++20",
267 local_include_dirs: ["."],
268 shared_libs: ["libbase"],
269 static_libs: ["libgmock"],
270 compile_multilib: "both",
271 multilib: {
272 lib32: {
273 suffix: "32",
274 },
275 lib64: {
276 suffix: "64",
277 },
278 },
279 test_suites: ["device-tests"],
280}
281
Tom Cherry377d1ad2019-06-14 14:34:54 -0700282cc_benchmark {
283 name: "libbase_benchmark",
284 defaults: ["libbase_cflags_defaults"],
285
286 srcs: ["format_benchmark.cpp"],
287 shared_libs: ["libbase"],
288
289 compile_multilib: "both",
290 multilib: {
291 lib32: {
292 suffix: "32",
293 },
294 lib64: {
295 suffix: "64",
296 },
297 },
298}
Branden Archer200349f2020-10-14 10:20:15 -0700299
300cc_fuzz {
301 name: "libbase_parsenetaddress_fuzzer",
302 shared_libs: ["libbase"],
303 host_supported: true,
304 srcs: ["parsenetaddress_fuzzer.cpp"],
305 dictionary: "parsenetaddress_fuzzer.dict",
306
307 fuzz_config: {
308 cc: [
309 "android-bionic@google.com",
310 ],
311 componentid: 128577
312 }
313}