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