1package { 2 default_team: "trendy_team_native_tools_libraries", 3 default_applicable_licenses: ["system_core_libcutils_license"], 4} 5 6license { 7 name: "system_core_libcutils_license", 8 visibility: [":__subpackages__"], 9 license_kinds: [ 10 "SPDX-license-identifier-Apache-2.0", 11 "SPDX-license-identifier-BSD", 12 "SPDX-license-identifier-MIT", // strlcpy.c 13 ], 14 license_text: [ 15 "NOTICE", 16 ], 17} 18 19filegroup { 20 name: "android_filesystem_config_header", 21 srcs: ["include/private/android_filesystem_config.h"], 22} 23 24rust_bindgen { 25 name: "libandroid_ids", 26 crate_name: "android_ids", 27 source_stem: "bindings", 28 wrapper_src: "rust/aid_bindings.h", 29 header_libs: ["libcutils_headers"], 30 visibility: [ 31 "//system/bpf/loader", 32 ], 33} 34 35cc_defaults { 36 name: "libcutils_defaults", 37 cflags: [ 38 "-Wno-exit-time-destructors", 39 ], 40 41 product_available: true, 42 ramdisk_available: true, 43 recovery_available: true, 44 vendor_available: true, 45 vendor_ramdisk_available: true, 46 47 host_supported: true, 48 native_bridge_supported: true, 49 50 apex_available: [ 51 "//apex_available:platform", 52 "//apex_available:anyapex", 53 ], 54 min_sdk_version: "29", 55} 56 57cc_library_headers { 58 name: "libcutils_headers", 59 defaults: ["libcutils_defaults"], 60 61 export_include_dirs: ["include"], 62 header_libs: ["libprocessgroup_headers"], 63 export_header_lib_headers: ["libprocessgroup_headers"], 64 target: { 65 vendor: { 66 override_export_include_dirs: ["include_outside_system"], 67 }, 68 product: { 69 override_export_include_dirs: ["include_outside_system"], 70 }, 71 linux_bionic: { 72 enabled: true, 73 }, 74 windows: { 75 enabled: true, 76 }, 77 }, 78} 79 80// Socket specific parts of libcutils that are safe to statically link into an APEX. 81cc_library { 82 name: "libcutils_sockets", 83 defaults: ["libcutils_defaults"], 84 85 export_include_dirs: ["include"], 86 87 shared_libs: ["liblog"], 88 srcs: ["sockets.cpp"], 89 target: { 90 linux_bionic: { 91 enabled: true, 92 }, 93 94 not_windows: { 95 srcs: [ 96 "socket_inaddr_any_server_unix.cpp", 97 "socket_local_client_unix.cpp", 98 "socket_local_server_unix.cpp", 99 "socket_network_client_unix.cpp", 100 "sockets_unix.cpp", 101 ], 102 }, 103 104 // "not_windows" means "non-Windows host". 105 android: { 106 srcs: [ 107 "android_get_control_file.cpp", 108 "socket_inaddr_any_server_unix.cpp", 109 "socket_local_client_unix.cpp", 110 "socket_local_server_unix.cpp", 111 "socket_network_client_unix.cpp", 112 "sockets_unix.cpp", 113 ], 114 static_libs: ["libbase"], 115 }, 116 117 windows: { 118 host_ldlibs: ["-lws2_32"], 119 srcs: [ 120 "socket_inaddr_any_server_windows.cpp", 121 "socket_network_client_windows.cpp", 122 "sockets_windows.cpp", 123 ], 124 125 enabled: true, 126 cflags: [ 127 "-D_GNU_SOURCE", 128 ], 129 }, 130 }, 131} 132 133// some files must not be compiled when building against Mingw 134// they correspond to features not used by our host development tools 135// which are also hard or even impossible to port to native Win32 136libcutils_nonwindows_sources = [ 137 "fs.cpp", 138 "hashmap.cpp", 139 "multiuser.cpp", 140 "str_parms.cpp", 141] 142 143cc_library { 144 name: "libcutils", 145 defaults: ["libcutils_defaults"], 146 double_loadable: true, 147 srcs: [ 148 "config_utils.cpp", 149 "iosched_policy.cpp", 150 "load_file.cpp", 151 "native_handle.cpp", 152 "properties.cpp", 153 "record_stream.cpp", 154 "strlcpy.c", 155 ], 156 157 target: { 158 linux_bionic: { 159 enabled: true, 160 static_libs: [ 161 "libasync_safe", 162 ], 163 }, 164 linux: { 165 srcs: [ 166 "canned_fs_config.cpp", 167 "fs_config.cpp", 168 ], 169 }, 170 host: { 171 srcs: [ 172 "trace-host.cpp", 173 "ashmem-host.cpp", 174 ], 175 }, 176 not_windows: { 177 srcs: libcutils_nonwindows_sources, 178 }, 179 windows: { 180 enabled: true, 181 host_ldlibs: ["-lws2_32"], 182 }, 183 android: { 184 sanitize: { 185 misc_undefined: ["integer"], 186 }, 187 static_libs: [ 188 "libasync_safe", 189 ], 190 srcs: libcutils_nonwindows_sources + [ 191 "android_reboot.cpp", 192 "ashmem-dev.cpp", 193 "klog.cpp", 194 "partition_utils.cpp", 195 "qtaguid.cpp", 196 "trace-dev.cpp", 197 "uevent.cpp", 198 ], 199 }, 200 201 // qtaguid.cpp loads libnetd_client.so with dlopen(). Since 202 // the interface of libnetd_client.so may vary between AOSP 203 // releases, exclude qtaguid.cpp from the VNDK-SP variant. 204 vendor: { 205 exclude_srcs: [ 206 "qtaguid.cpp", 207 ], 208 header_abi_checker: { 209 enabled: true, 210 ref_dump_dirs: ["abi-dumps"], 211 }, 212 }, 213 product: { 214 exclude_srcs: [ 215 "qtaguid.cpp", 216 ], 217 header_abi_checker: { 218 enabled: true, 219 ref_dump_dirs: ["abi-dumps"], 220 }, 221 }, 222 }, 223 224 whole_static_libs: ["libcutils_sockets"], 225 shared_libs: [ 226 "liblog", 227 "libbase", 228 ], 229 header_libs: [ 230 "libbase_headers", 231 "libcutils_headers", 232 "libprocessgroup_headers", 233 ], 234 export_header_lib_headers: [ 235 "libcutils_headers", 236 "libprocessgroup_headers", 237 ], 238 local_include_dirs: ["include"], 239 240 cflags: [ 241 "-Werror", 242 "-Wall", 243 "-Wextra", 244 ], 245} 246 247cc_defaults { 248 name: "libcutils_test_default", 249 srcs: [ 250 "ashmem_base_test.cpp", 251 "native_handle_test.cpp", 252 "properties_test.cpp", 253 "sockets_test.cpp", 254 ], 255 256 target: { 257 android: { 258 srcs: [ 259 "android_get_control_file_test.cpp", 260 "android_get_control_socket_test.cpp", 261 "ashmem_test.cpp", 262 "fs_config_test.cpp", 263 "multiuser_test.cpp", 264 "sched_policy_test.cpp", 265 "str_parms_test.cpp", 266 "trace-dev_test.cpp", 267 ], 268 }, 269 270 not_windows: { 271 srcs: [ 272 "str_parms_test.cpp", 273 ], 274 }, 275 }, 276 277 cflags: [ 278 "-Wall", 279 "-Wextra", 280 "-Werror", 281 ], 282} 283 284always_static_test_libraries = [ 285 "libjsoncpp", 286] 287 288test_libraries = [ 289 "libcutils", 290 "liblog", 291 "libbase", 292 "libprocessgroup", 293] 294 295cc_test { 296 name: "libcutils_test", 297 test_suites: ["device-tests"], 298 defaults: ["libcutils_test_default"], 299 host_supported: true, 300 shared_libs: test_libraries, 301 static_libs: always_static_test_libraries, 302 require_root: true, 303} 304 305cc_defaults { 306 name: "libcutils_test_static_defaults", 307 defaults: ["libcutils_test_default"], 308 stl: "libc++_static", 309 require_root: true, 310 311 target: { 312 android: { 313 static_executable: true, 314 static_libs: [ 315 "libprocessgroup_util", 316 ] + test_libraries + always_static_test_libraries, 317 }, 318 not_windows: { 319 static_libs: test_libraries + always_static_test_libraries, 320 }, 321 windows: { 322 static_libs: [ 323 "libbase", 324 "libcutils", 325 "libcutils_sockets", 326 ], 327 host_ldlibs: ["-lws2_32"], 328 enabled: true, 329 }, 330 }, 331} 332 333cc_test { 334 name: "libcutils_test_static", 335 host_supported: true, 336 test_suites: ["device-tests"], 337 defaults: ["libcutils_test_static_defaults"], 338} 339 340cc_test { 341 name: "KernelLibcutilsTest", 342 test_suites: [ 343 "general-tests", 344 "vts", 345 ], 346 defaults: ["libcutils_test_static_defaults"], 347 test_config: "KernelLibcutilsTest.xml", 348} 349