blob: 3c3eeb6631f30eabc2852fcb4888961b9b276931 [file] [log] [blame]
Bob Badourd69ad692021-02-16 19:02:14 -08001package {
2 default_applicable_licenses: ["system_core_libcutils_license"],
3}
4
Bob Badourd69ad692021-02-16 19:02:14 -08005license {
6 name: "system_core_libcutils_license",
7 visibility: [":__subpackages__"],
8 license_kinds: [
9 "SPDX-license-identifier-Apache-2.0",
10 "SPDX-license-identifier-BSD",
Elliott Hughes527d71f2021-03-04 09:18:19 -080011 "SPDX-license-identifier-MIT", // strlcpy.c
Bob Badourd69ad692021-02-16 19:02:14 -080012 ],
13 license_text: [
14 "NOTICE",
15 ],
16}
17
Tom Cherry167fbf52020-09-17 09:39:24 -070018filegroup {
19 name: "android_filesystem_config_header",
20 srcs: ["include/private/android_filesystem_config.h"],
21}
22
Elliott Hughes527d71f2021-03-04 09:18:19 -080023cc_defaults {
24 name: "libcutils_defaults",
25 cflags: [
26 "-Wno-exit-time-destructors",
27 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -070028
Justin Yunfeef4d32020-11-11 19:17:40 +090029 product_available: true,
Tom Cherrya5edc0f2020-09-17 09:38:42 -070030 ramdisk_available: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080031 recovery_available: true,
32 vendor_available: true,
Yifan Hong55015ff2020-10-27 16:37:06 -070033 vendor_ramdisk_available: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080034
Vijay Venkatraman651f8382017-01-25 18:52:17 +000035 host_supported: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080036 native_bridge_supported: true,
37
Jiyong Park8bf9b162020-03-07 16:36:09 +090038 apex_available: [
39 "//apex_available:platform",
40 "//apex_available:anyapex",
41 ],
Jooyung Han88f00f22020-04-16 18:48:33 +090042 min_sdk_version: "29",
Elliott Hughes527d71f2021-03-04 09:18:19 -080043}
44
45cc_library_headers {
46 name: "libcutils_headers",
47 defaults: ["libcutils_defaults"],
48
Vijay Venkatraman651f8382017-01-25 18:52:17 +000049 export_include_dirs: ["include"],
T.J. Mercier1fd79932024-06-21 22:17:12 +000050 header_libs: ["libprocessgroup_headers"],
51 export_header_lib_headers: ["libprocessgroup_headers"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +000052 target: {
Steven Moreland385fe692017-04-13 14:29:58 -070053 vendor: {
Justin Yunfeef4d32020-11-11 19:17:40 +090054 override_export_include_dirs: ["include_outside_system"],
55 },
56 product: {
57 override_export_include_dirs: ["include_outside_system"],
Steven Moreland385fe692017-04-13 14:29:58 -070058 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070059 linux_bionic: {
60 enabled: true,
61 },
62 windows: {
63 enabled: true,
64 },
Vijay Venkatraman651f8382017-01-25 18:52:17 +000065 },
66}
67
Josh Gaoa9b62d52020-02-19 13:50:57 -080068// Socket specific parts of libcutils that are safe to statically link into an APEX.
Josh Gao7f8a37c2020-03-09 15:20:55 -070069cc_library {
Josh Gaoa9b62d52020-02-19 13:50:57 -080070 name: "libcutils_sockets",
Elliott Hughes527d71f2021-03-04 09:18:19 -080071 defaults: ["libcutils_defaults"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080072
73 export_include_dirs: ["include"],
74
Josh Gao7f8a37c2020-03-09 15:20:55 -070075 shared_libs: ["liblog"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080076 srcs: ["sockets.cpp"],
77 target: {
78 linux_bionic: {
79 enabled: true,
80 },
81
82 not_windows: {
83 srcs: [
84 "socket_inaddr_any_server_unix.cpp",
85 "socket_local_client_unix.cpp",
86 "socket_local_server_unix.cpp",
87 "socket_network_client_unix.cpp",
88 "sockets_unix.cpp",
89 ],
90 },
91
92 // "not_windows" means "non-Windows host".
93 android: {
94 srcs: [
95 "android_get_control_file.cpp",
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 static_libs: ["libbase"],
103 },
104
105 windows: {
106 host_ldlibs: ["-lws2_32"],
107 srcs: [
108 "socket_inaddr_any_server_windows.cpp",
109 "socket_network_client_windows.cpp",
110 "sockets_windows.cpp",
111 ],
112
113 enabled: true,
114 cflags: [
115 "-D_GNU_SOURCE",
116 ],
117 },
118 },
119}
120
Elliott Hughes527d71f2021-03-04 09:18:19 -0800121// some files must not be compiled when building against Mingw
122// they correspond to features not used by our host development tools
123// which are also hard or even impossible to port to native Win32
124libcutils_nonwindows_sources = [
125 "fs.cpp",
126 "hashmap.cpp",
127 "multiuser.cpp",
128 "str_parms.cpp",
129]
130
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700131cc_library {
132 name: "libcutils",
Elliott Hughes527d71f2021-03-04 09:18:19 -0800133 defaults: ["libcutils_defaults"],
Kiyoung Kimad8cf522024-03-11 13:04:38 +0900134 double_loadable: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700135 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800136 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800137 "iosched_policy.cpp",
138 "load_file.cpp",
139 "native_handle.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530140 "properties.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800141 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700142 "strlcpy.c",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700143 ],
144
145 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700146 linux_bionic: {
147 enabled: true,
Brian Duddie9f2af692022-08-24 19:52:08 +0000148 static_libs: [
149 "libasync_safe",
150 ],
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700151 },
Elliott Hughes94ccdc02023-09-22 18:44:28 +0000152 linux: {
153 srcs: [
154 "canned_fs_config.cpp",
155 "fs_config.cpp",
156 ],
157 },
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000158 host: {
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700159 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800160 "trace-host.cpp",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000161 "ashmem-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700162 ],
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000163 },
164 not_windows: {
165 srcs: libcutils_nonwindows_sources,
166 },
167 windows: {
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700168 enabled: true,
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000169 host_ldlibs: ["-lws2_32"],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700170 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700171 android: {
Elliott Hughes06a839f2022-10-18 16:31:04 +0000172 sanitize: {
173 misc_undefined: ["integer"],
174 },
Brian Duddie9f2af692022-08-24 19:52:08 +0000175 static_libs: [
176 "libasync_safe",
177 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700178 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800179 "android_reboot.cpp",
180 "ashmem-dev.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700181 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800182 "partition_utils.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700183 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800184 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700185 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700186 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700187 },
188
Justin Yunfeef4d32020-11-11 19:17:40 +0900189 // qtaguid.cpp loads libnetd_client.so with dlopen(). Since
190 // the interface of libnetd_client.so may vary between AOSP
191 // releases, exclude qtaguid.cpp from the VNDK-SP variant.
Logan Chien25b742c2018-05-08 17:37:29 +0800192 vendor: {
193 exclude_srcs: [
Logan Chien25b742c2018-05-08 17:37:29 +0800194 "qtaguid.cpp",
195 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900196 header_abi_checker: {
197 enabled: true,
198 ref_dump_dirs: ["abi-dumps"],
199 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900200 },
201 product: {
202 exclude_srcs: [
203 "qtaguid.cpp",
204 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900205 header_abi_checker: {
206 enabled: true,
207 ref_dump_dirs: ["abi-dumps"],
208 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900209 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700210 },
211
Josh Gaoa9b62d52020-02-19 13:50:57 -0800212 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800213 shared_libs: [
214 "liblog",
215 "libbase",
216 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700217 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700218 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700219 "libcutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000220 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700221 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000222 export_header_lib_headers: [
223 "libcutils_headers",
224 "libprocessgroup_headers",
225 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700226 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000227
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700228 cflags: [
229 "-Werror",
230 "-Wall",
231 "-Wextra",
232 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700233}
234
Elliott Hughes01705e42019-02-07 12:41:37 -0800235cc_defaults {
236 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800237 srcs: [
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000238 "ashmem_base_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800239 "native_handle_test.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530240 "properties_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800241 "sockets_test.cpp",
242 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800243
244 target: {
245 android: {
246 srcs: [
247 "android_get_control_file_test.cpp",
248 "android_get_control_socket_test.cpp",
249 "ashmem_test.cpp",
250 "fs_config_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800251 "multiuser_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800252 "sched_policy_test.cpp",
253 "str_parms_test.cpp",
254 "trace-dev_test.cpp",
255 ],
256 },
257
258 not_windows: {
259 srcs: [
260 "str_parms_test.cpp",
261 ],
262 },
263 },
264
265 cflags: [
266 "-Wall",
267 "-Wextra",
268 "-Werror",
269 ],
270}
271
Steven Moreland40b59a62023-06-06 17:52:39 +0000272always_static_test_libraries = [
273 "libjsoncpp",
274]
275
Elliott Hughes01705e42019-02-07 12:41:37 -0800276test_libraries = [
277 "libcutils",
278 "liblog",
279 "libbase",
Elliott Hughes01705e42019-02-07 12:41:37 -0800280 "libprocessgroup",
Yifan Hong53e0deb2019-03-22 17:01:08 -0700281 "libcgrouprc",
Elliott Hughes01705e42019-02-07 12:41:37 -0800282]
283
284cc_test {
285 name: "libcutils_test",
286 test_suites: ["device-tests"],
287 defaults: ["libcutils_test_default"],
288 host_supported: true,
289 shared_libs: test_libraries,
Steven Moreland40b59a62023-06-06 17:52:39 +0000290 static_libs: always_static_test_libraries,
Tom Cherrye41aded2019-11-07 14:06:21 -0800291 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800292}
293
nelsonlid83f3902020-01-16 17:20:18 +0800294cc_defaults {
295 name: "libcutils_test_static_defaults",
Elliott Hughes01705e42019-02-07 12:41:37 -0800296 defaults: ["libcutils_test_default"],
Elliott Hughes01705e42019-02-07 12:41:37 -0800297 stl: "libc++_static",
Tom Cherrye41aded2019-11-07 14:06:21 -0800298 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800299
300 target: {
301 android: {
302 static_executable: true,
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000303 static_libs: [
304 "libcgrouprc_format",
305 ] + test_libraries + always_static_test_libraries,
306 },
307 not_windows: {
308 static_libs: test_libraries + always_static_test_libraries,
Elliott Hughes01705e42019-02-07 12:41:37 -0800309 },
310 windows: {
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000311 static_libs: [
312 "libbase",
313 "libcutils",
314 "libcutils_sockets",
315 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800316 host_ldlibs: ["-lws2_32"],
Elliott Hughes01705e42019-02-07 12:41:37 -0800317 enabled: true,
318 },
319 },
320}
nelsonlid83f3902020-01-16 17:20:18 +0800321
322cc_test {
323 name: "libcutils_test_static",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000324 host_supported: true,
nelsonlid83f3902020-01-16 17:20:18 +0800325 test_suites: ["device-tests"],
326 defaults: ["libcutils_test_static_defaults"],
327}
328
329cc_test {
330 name: "KernelLibcutilsTest",
Michael Hoisied1e4c262024-03-06 17:22:45 +0000331 test_suites: [
332 "general-tests",
333 "vts",
334 ],
nelsonlid83f3902020-01-16 17:20:18 +0800335 defaults: ["libcutils_test_static_defaults"],
336 test_config: "KernelLibcutilsTest.xml",
337}