1package { 2 default_applicable_licenses: ["system_core_libutils_license"], 3} 4 5license { 6 name: "system_core_libutils_license", 7 visibility: [":__subpackages__"], 8 license_kinds: [ 9 "SPDX-license-identifier-Apache-2.0", 10 ], 11 license_text: [ 12 "NOTICE", 13 ], 14} 15 16cc_library_headers { 17 name: "libutils_headers", 18 vendor_available: true, 19 product_available: true, 20 recovery_available: true, 21 vendor_ramdisk_available: true, 22 host_supported: true, 23 native_bridge_supported: true, 24 defaults: [ 25 "apex-lowest-min-sdk-version", 26 ], 27 apex_available: [ 28 "//apex_available:platform", 29 "//apex_available:anyapex", 30 ], 31 32 header_libs: [ 33 "libbase_headers", 34 "libcutils_headers", 35 "liblog_headers", 36 "libsystem_headers", 37 ], 38 export_header_lib_headers: [ 39 "libbase_headers", 40 "libcutils_headers", 41 "liblog_headers", 42 "libsystem_headers", 43 ], 44 export_include_dirs: ["include"], 45 46 target: { 47 linux_bionic: { 48 enabled: true, 49 }, 50 windows: { 51 enabled: true, 52 }, 53 }, 54} 55 56cc_defaults { 57 name: "libutils_defaults_nodeps", 58 vendor_available: true, 59 product_available: true, 60 recovery_available: true, 61 host_supported: true, 62 63 cflags: [ 64 "-Wall", 65 "-Werror", 66 "-Wno-exit-time-destructors", 67 "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", 68 ], 69 70 sanitize: { 71 misc_undefined: ["integer"], 72 }, 73 74 target: { 75 android: { 76 cflags: ["-fvisibility=protected"], 77 78 shared_libs: [ 79 "libvndksupport", 80 ], 81 82 sanitize: { 83 misc_undefined: ["integer"], 84 }, 85 }, 86 87 recovery: { 88 exclude_shared_libs: ["libvndksupport"], 89 }, 90 91 linux_bionic: { 92 enabled: true, 93 }, 94 95 darwin: { 96 cflags: ["-Wno-unused-parameter"], 97 }, 98 99 windows: { 100 cflags: [ 101 // Under MinGW, ctype.h doesn't need multi-byte support 102 "-DMB_CUR_MAX=1", 103 "-Wno-unused-private-field", 104 ], 105 106 enabled: true, 107 }, 108 }, 109 fuzz_config: { 110 cc: ["[email protected]"], 111 }, 112} 113 114cc_defaults { 115 name: "libutils_defaults", 116 defaults: [ 117 "libutils_defaults_nodeps", 118 ], 119 120 shared_libs: [ 121 "libcutils", 122 "liblog", 123 ], 124} 125 126cc_defaults { 127 name: "libutils_impl_defaults", 128 defaults: [ 129 "libutils_defaults", 130 "apex-lowest-min-sdk-version", 131 ], 132 native_bridge_supported: true, 133 134 whole_static_libs: ["libutils_binder"], 135 136 header_libs: [ 137 "libbase_headers", 138 "libutils_headers", 139 ], 140 export_header_lib_headers: [ 141 "libutils_headers", 142 ], 143 144 srcs: [ 145 "FileMap.cpp", 146 "JenkinsHash.cpp", 147 "LightRefBase.cpp", 148 "NativeHandle.cpp", 149 "Printer.cpp", 150 "StopWatch.cpp", 151 "SystemClock.cpp", 152 "Threads.cpp", 153 "Timers.cpp", 154 "Tokenizer.cpp", 155 "misc.cpp", 156 ], 157 158 target: { 159 android: { 160 srcs: [ 161 "Trace.cpp", 162 ], 163 }, 164 linux: { 165 header_libs: ["libbase_headers"], 166 srcs: [ 167 "Looper.cpp", 168 ], 169 }, 170 }, 171 172 apex_available: [ 173 "//apex_available:anyapex", 174 "//apex_available:platform", 175 ], 176 177 afdo: true, 178} 179 180cc_library { 181 name: "libutils", 182 defaults: ["libutils_impl_defaults"], 183 184 double_loadable: true, 185 186 target: { 187 product: { 188 header_abi_checker: { 189 enabled: true, 190 // AFDO affects weak symbols. 191 diff_flags: ["-allow-adding-removing-weak-symbols"], 192 ref_dump_dirs: ["abi-dumps"], 193 }, 194 }, 195 vendor: { 196 header_abi_checker: { 197 enabled: true, 198 // AFDO affects weak symbols. 199 diff_flags: ["-allow-adding-removing-weak-symbols"], 200 ref_dump_dirs: ["abi-dumps"], 201 }, 202 }, 203 }, 204} 205 206cc_library { 207 name: "libutils_test_compile", 208 defaults: ["libutils_impl_defaults"], 209 210 cflags: [ 211 "-DDEBUG_CALLBACKS=1", 212 "-DDEBUG_POLL_AND_WAKE=1", 213 "-DDEBUG_REFS=1", 214 "-DDEBUG_TOKENIZER=1", 215 ], 216 217 visibility: [":__subpackages__"], 218} 219 220cc_library { 221 name: "libutilscallstack", 222 defaults: ["libutils_defaults"], 223 // TODO(b/153609531): remove when no longer needed. 224 native_bridge_supported: true, 225 min_sdk_version: "29", 226 double_loadable: true, 227 228 header_libs: [ 229 "libbase_headers", 230 "libutils_headers", 231 ], 232 export_header_lib_headers: [ 233 "libutils_headers", 234 ], 235 236 srcs: [ 237 "CallStack.cpp", 238 ], 239 240 shared_libs: [ 241 "libutils", 242 "libunwindstack", 243 ], 244 245 target: { 246 linux: { 247 srcs: [ 248 "ProcessCallStack.cpp", 249 ], 250 }, 251 darwin: { 252 enabled: false, 253 }, 254 windows: { 255 enabled: false, 256 }, 257 }, 258} 259 260cc_defaults { 261 name: "libutils_fuzz_defaults", 262 host_supported: true, 263 shared_libs: [ 264 "libutils", 265 "libbase", 266 "liblog", 267 ], 268 fuzz_config: { 269 cc: [ 270 "[email protected]", 271 ], 272 componentid: 128577, 273 description: "The fuzzer targets the APIs of libutils", 274 vector: "local_no_privileges_required", 275 service_privilege: "privileged", 276 users: "multi_user", 277 fuzzed_code_usage: "shipped", 278 }, 279} 280 281cc_fuzz { 282 name: "libutils_fuzz_bitset", 283 defaults: ["libutils_fuzz_defaults"], 284 srcs: ["BitSet_fuzz.cpp"], 285} 286 287cc_fuzz { 288 name: "libutils_fuzz_filemap", 289 defaults: ["libutils_fuzz_defaults"], 290 srcs: ["FileMap_fuzz.cpp"], 291} 292 293cc_fuzz { 294 name: "libutils_fuzz_printer", 295 defaults: ["libutils_fuzz_defaults"], 296 srcs: ["Printer_fuzz.cpp"], 297} 298 299cc_fuzz { 300 name: "libutils_fuzz_callstack", 301 defaults: ["libutils_fuzz_defaults"], 302 srcs: ["CallStack_fuzz.cpp"], 303 shared_libs: [ 304 "libutilscallstack", 305 ], 306} 307 308cc_fuzz { 309 name: "libutils_fuzz_process_callstack", 310 defaults: ["libutils_fuzz_defaults"], 311 srcs: ["ProcessCallStack_fuzz.cpp"], 312 shared_libs: [ 313 "libutilscallstack", 314 ], 315} 316 317cc_fuzz { 318 name: "libutils_fuzz_lrucache", 319 defaults: ["libutils_fuzz_defaults"], 320 srcs: ["LruCache_fuzz.cpp"], 321} 322 323cc_fuzz { 324 name: "libutils_fuzz_looper", 325 defaults: ["libutils_fuzz_defaults"], 326 srcs: ["Looper_fuzz.cpp"], 327} 328 329cc_test { 330 name: "libutils_test", 331 host_supported: true, 332 333 srcs: [ 334 "BitSet_test.cpp", 335 "CallStack_test.cpp", 336 "FileMap_test.cpp", 337 "LruCache_test.cpp", 338 "Mutex_test.cpp", 339 "Singleton_test.cpp", 340 "Timers_test.cpp", 341 ], 342 343 target: { 344 android: { 345 srcs: [ 346 "SystemClock_test.cpp", 347 ], 348 shared_libs: [ 349 "libbase", 350 "libcutils", 351 "liblog", 352 "liblzma", 353 "libunwindstack", 354 "libutils", 355 "libutilscallstack", 356 "libz", 357 ], 358 }, 359 linux: { 360 srcs: [ 361 "Looper_test.cpp", 362 ], 363 }, 364 host: { 365 static_libs: [ 366 "libbase", 367 "liblog", 368 "liblzma", 369 "libunwindstack_no_dex", 370 "libutils", 371 "libutilscallstack", 372 "libz", 373 ], 374 }, 375 }, 376 377 data_libs: [ 378 "libutils_test_singleton1", 379 "libutils_test_singleton2", 380 ], 381 382 cflags: [ 383 "-Wall", 384 "-Wextra", 385 "-Werror", 386 "-Wthread-safety", 387 ], 388 389 test_suites: ["device-tests"], 390} 391 392cc_test_library { 393 name: "libutils_test_singleton1", 394 host_supported: true, 395 installable: false, 396 srcs: ["Singleton_test1.cpp"], 397 cflags: [ 398 "-Wall", 399 "-Werror", 400 ], 401 header_libs: ["libutils_headers"], 402} 403 404cc_test_library { 405 name: "libutils_test_singleton2", 406 host_supported: true, 407 installable: false, 408 srcs: ["Singleton_test2.cpp"], 409 cflags: [ 410 "-Wall", 411 "-Werror", 412 ], 413 shared_libs: ["libutils_test_singleton1"], 414 header_libs: ["libutils_headers"], 415} 416