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