blob: ec9b754931eece956ecc80a23b092c2c69e529d9 [file] [log] [blame]
Bob Badourd69ad692021-02-16 19:02:14 -08001package {
Yihan Dong9081b852024-10-12 08:53:19 +00002 default_team: "trendy_team_native_tools_libraries",
Bob Badourd69ad692021-02-16 19:02:14 -08003 default_applicable_licenses: ["system_core_libcutils_license"],
4}
5
Bob Badourd69ad692021-02-16 19:02:14 -08006license {
7 name: "system_core_libcutils_license",
8 visibility: [":__subpackages__"],
9 license_kinds: [
10 "SPDX-license-identifier-Apache-2.0",
11 "SPDX-license-identifier-BSD",
Elliott Hughes527d71f2021-03-04 09:18:19 -080012 "SPDX-license-identifier-MIT", // strlcpy.c
Bob Badourd69ad692021-02-16 19:02:14 -080013 ],
14 license_text: [
15 "NOTICE",
16 ],
17}
18
Tom Cherry167fbf52020-09-17 09:39:24 -070019filegroup {
20 name: "android_filesystem_config_header",
21 srcs: ["include/private/android_filesystem_config.h"],
22}
23
Neill Kapronf1d00f02024-11-19 02:13:33 +000024rust_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
Elliott Hughes527d71f2021-03-04 09:18:19 -080035cc_defaults {
36 name: "libcutils_defaults",
37 cflags: [
38 "-Wno-exit-time-destructors",
39 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -070040
Justin Yunfeef4d32020-11-11 19:17:40 +090041 product_available: true,
Tom Cherrya5edc0f2020-09-17 09:38:42 -070042 ramdisk_available: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080043 recovery_available: true,
44 vendor_available: true,
Yifan Hong55015ff2020-10-27 16:37:06 -070045 vendor_ramdisk_available: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080046
Vijay Venkatraman651f8382017-01-25 18:52:17 +000047 host_supported: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080048 native_bridge_supported: true,
49
Jiyong Park8bf9b162020-03-07 16:36:09 +090050 apex_available: [
51 "//apex_available:platform",
52 "//apex_available:anyapex",
53 ],
Jooyung Han88f00f22020-04-16 18:48:33 +090054 min_sdk_version: "29",
Elliott Hughes527d71f2021-03-04 09:18:19 -080055}
56
57cc_library_headers {
58 name: "libcutils_headers",
59 defaults: ["libcutils_defaults"],
60
Vijay Venkatraman651f8382017-01-25 18:52:17 +000061 export_include_dirs: ["include"],
T.J. Mercier1fd79932024-06-21 22:17:12 +000062 header_libs: ["libprocessgroup_headers"],
63 export_header_lib_headers: ["libprocessgroup_headers"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +000064 target: {
Steven Moreland385fe692017-04-13 14:29:58 -070065 vendor: {
Justin Yunfeef4d32020-11-11 19:17:40 +090066 override_export_include_dirs: ["include_outside_system"],
67 },
68 product: {
69 override_export_include_dirs: ["include_outside_system"],
Steven Moreland385fe692017-04-13 14:29:58 -070070 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070071 linux_bionic: {
72 enabled: true,
73 },
74 windows: {
75 enabled: true,
76 },
Vijay Venkatraman651f8382017-01-25 18:52:17 +000077 },
78}
79
Josh Gaoa9b62d52020-02-19 13:50:57 -080080// Socket specific parts of libcutils that are safe to statically link into an APEX.
Josh Gao7f8a37c2020-03-09 15:20:55 -070081cc_library {
Josh Gaoa9b62d52020-02-19 13:50:57 -080082 name: "libcutils_sockets",
Elliott Hughes527d71f2021-03-04 09:18:19 -080083 defaults: ["libcutils_defaults"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080084
85 export_include_dirs: ["include"],
86
Josh Gao7f8a37c2020-03-09 15:20:55 -070087 shared_libs: ["liblog"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080088 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
Elliott Hughes527d71f2021-03-04 09:18:19 -0800133// 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
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700143cc_library {
144 name: "libcutils",
Elliott Hughes527d71f2021-03-04 09:18:19 -0800145 defaults: ["libcutils_defaults"],
Kiyoung Kimad8cf522024-03-11 13:04:38 +0900146 double_loadable: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700147 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800148 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800149 "iosched_policy.cpp",
150 "load_file.cpp",
151 "native_handle.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530152 "properties.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800153 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700154 "strlcpy.c",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700155 ],
156
157 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700158 linux_bionic: {
159 enabled: true,
Brian Duddie9f2af692022-08-24 19:52:08 +0000160 static_libs: [
161 "libasync_safe",
162 ],
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700163 },
Elliott Hughes94ccdc02023-09-22 18:44:28 +0000164 linux: {
165 srcs: [
166 "canned_fs_config.cpp",
167 "fs_config.cpp",
168 ],
169 },
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000170 host: {
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700171 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800172 "trace-host.cpp",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000173 "ashmem-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700174 ],
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000175 },
176 not_windows: {
177 srcs: libcutils_nonwindows_sources,
178 },
179 windows: {
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700180 enabled: true,
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000181 host_ldlibs: ["-lws2_32"],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700182 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700183 android: {
Elliott Hughes06a839f2022-10-18 16:31:04 +0000184 sanitize: {
185 misc_undefined: ["integer"],
186 },
Brian Duddie9f2af692022-08-24 19:52:08 +0000187 static_libs: [
188 "libasync_safe",
189 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700190 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800191 "android_reboot.cpp",
192 "ashmem-dev.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700193 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800194 "partition_utils.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700195 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800196 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700197 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700198 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700199 },
200
Justin Yunfeef4d32020-11-11 19:17:40 +0900201 // 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.
Logan Chien25b742c2018-05-08 17:37:29 +0800204 vendor: {
205 exclude_srcs: [
Logan Chien25b742c2018-05-08 17:37:29 +0800206 "qtaguid.cpp",
207 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900208 header_abi_checker: {
209 enabled: true,
210 ref_dump_dirs: ["abi-dumps"],
211 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900212 },
213 product: {
214 exclude_srcs: [
215 "qtaguid.cpp",
216 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900217 header_abi_checker: {
218 enabled: true,
219 ref_dump_dirs: ["abi-dumps"],
220 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900221 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700222 },
223
Josh Gaoa9b62d52020-02-19 13:50:57 -0800224 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800225 shared_libs: [
226 "liblog",
227 "libbase",
228 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700229 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700230 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700231 "libcutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000232 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700233 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000234 export_header_lib_headers: [
235 "libcutils_headers",
236 "libprocessgroup_headers",
237 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700238 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000239
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700240 cflags: [
241 "-Werror",
242 "-Wall",
243 "-Wextra",
244 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700245}
246
Elliott Hughes01705e42019-02-07 12:41:37 -0800247cc_defaults {
248 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800249 srcs: [
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000250 "ashmem_base_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800251 "native_handle_test.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530252 "properties_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800253 "sockets_test.cpp",
254 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800255
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",
Elliott Hughes01705e42019-02-07 12:41:37 -0800263 "multiuser_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800264 "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
Steven Moreland40b59a62023-06-06 17:52:39 +0000284always_static_test_libraries = [
285 "libjsoncpp",
286]
287
Elliott Hughes01705e42019-02-07 12:41:37 -0800288test_libraries = [
289 "libcutils",
290 "liblog",
291 "libbase",
Elliott Hughes01705e42019-02-07 12:41:37 -0800292 "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,
Steven Moreland40b59a62023-06-06 17:52:39 +0000301 static_libs: always_static_test_libraries,
Tom Cherrye41aded2019-11-07 14:06:21 -0800302 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800303}
304
nelsonlid83f3902020-01-16 17:20:18 +0800305cc_defaults {
306 name: "libcutils_test_static_defaults",
Elliott Hughes01705e42019-02-07 12:41:37 -0800307 defaults: ["libcutils_test_default"],
Elliott Hughes01705e42019-02-07 12:41:37 -0800308 stl: "libc++_static",
Tom Cherrye41aded2019-11-07 14:06:21 -0800309 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800310
311 target: {
312 android: {
313 static_executable: true,
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000314 static_libs: [
T.J. Merciera09ee8e2024-10-08 23:41:27 +0000315 "libprocessgroup_util",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000316 ] + test_libraries + always_static_test_libraries,
317 },
318 not_windows: {
319 static_libs: test_libraries + always_static_test_libraries,
Elliott Hughes01705e42019-02-07 12:41:37 -0800320 },
321 windows: {
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000322 static_libs: [
323 "libbase",
324 "libcutils",
325 "libcutils_sockets",
326 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800327 host_ldlibs: ["-lws2_32"],
Elliott Hughes01705e42019-02-07 12:41:37 -0800328 enabled: true,
329 },
330 },
331}
nelsonlid83f3902020-01-16 17:20:18 +0800332
333cc_test {
334 name: "libcutils_test_static",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000335 host_supported: true,
nelsonlid83f3902020-01-16 17:20:18 +0800336 test_suites: ["device-tests"],
337 defaults: ["libcutils_test_static_defaults"],
338}
339
340cc_test {
341 name: "KernelLibcutilsTest",
Michael Hoisied1e4c262024-03-06 17:22:45 +0000342 test_suites: [
343 "general-tests",
344 "vts",
345 ],
nelsonlid83f3902020-01-16 17:20:18 +0800346 defaults: ["libcutils_test_static_defaults"],
347 test_config: "KernelLibcutilsTest.xml",
348}