blob: e2975813ced1d6219030ce58f01b1d80eab038cc [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"],
50 target: {
Steven Moreland385fe692017-04-13 14:29:58 -070051 vendor: {
Justin Yunfeef4d32020-11-11 19:17:40 +090052 override_export_include_dirs: ["include_outside_system"],
53 },
54 product: {
55 override_export_include_dirs: ["include_outside_system"],
Steven Moreland385fe692017-04-13 14:29:58 -070056 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070057 linux_bionic: {
58 enabled: true,
59 },
60 windows: {
61 enabled: true,
62 },
Vijay Venkatraman651f8382017-01-25 18:52:17 +000063 },
64}
65
Josh Gaoa9b62d52020-02-19 13:50:57 -080066// Socket specific parts of libcutils that are safe to statically link into an APEX.
Josh Gao7f8a37c2020-03-09 15:20:55 -070067cc_library {
Josh Gaoa9b62d52020-02-19 13:50:57 -080068 name: "libcutils_sockets",
Elliott Hughes527d71f2021-03-04 09:18:19 -080069 defaults: ["libcutils_defaults"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080070
71 export_include_dirs: ["include"],
72
Josh Gao7f8a37c2020-03-09 15:20:55 -070073 shared_libs: ["liblog"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080074 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
Elliott Hughes527d71f2021-03-04 09:18:19 -0800119// some files must not be compiled when building against Mingw
120// they correspond to features not used by our host development tools
121// which are also hard or even impossible to port to native Win32
122libcutils_nonwindows_sources = [
123 "fs.cpp",
124 "hashmap.cpp",
125 "multiuser.cpp",
126 "str_parms.cpp",
127]
128
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700129cc_library {
130 name: "libcutils",
Elliott Hughes527d71f2021-03-04 09:18:19 -0800131 defaults: ["libcutils_defaults"],
Kiyoung Kimad8cf522024-03-11 13:04:38 +0900132 double_loadable: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700133 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800134 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800135 "iosched_policy.cpp",
136 "load_file.cpp",
137 "native_handle.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530138 "properties.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800139 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700140 "strlcpy.c",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700141 ],
142
143 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700144 linux_bionic: {
145 enabled: true,
Brian Duddie9f2af692022-08-24 19:52:08 +0000146 static_libs: [
147 "libasync_safe",
148 ],
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700149 },
Elliott Hughes94ccdc02023-09-22 18:44:28 +0000150 linux: {
151 srcs: [
152 "canned_fs_config.cpp",
153 "fs_config.cpp",
154 ],
155 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700156 not_windows: {
157 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800158 "ashmem-host.cpp",
159 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700160 ],
161 },
162 windows: {
Steven Morelande6132be2019-03-25 20:38:56 -0700163 host_ldlibs: ["-lws2_32"],
164
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700165 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800166 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700167 ],
168
169 enabled: true,
Mark Salyzyn163ecc62017-05-02 08:56:15 -0700170 cflags: [
171 "-D_GNU_SOURCE",
172 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700173 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700174 android: {
Elliott Hughes06a839f2022-10-18 16:31:04 +0000175 sanitize: {
176 misc_undefined: ["integer"],
177 },
Brian Duddie9f2af692022-08-24 19:52:08 +0000178 static_libs: [
179 "libasync_safe",
180 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700181 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800182 "android_reboot.cpp",
183 "ashmem-dev.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700184 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800185 "partition_utils.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700186 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800187 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700188 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700189 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700190 },
191
Justin Yunfeef4d32020-11-11 19:17:40 +0900192 // qtaguid.cpp loads libnetd_client.so with dlopen(). Since
193 // the interface of libnetd_client.so may vary between AOSP
194 // releases, exclude qtaguid.cpp from the VNDK-SP variant.
Logan Chien25b742c2018-05-08 17:37:29 +0800195 vendor: {
196 exclude_srcs: [
Logan Chien25b742c2018-05-08 17:37:29 +0800197 "qtaguid.cpp",
198 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900199 header_abi_checker: {
200 enabled: true,
201 ref_dump_dirs: ["abi-dumps"],
202 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900203 },
204 product: {
205 exclude_srcs: [
206 "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 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700213 },
214
Josh Gaoa9b62d52020-02-19 13:50:57 -0800215 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800216 shared_libs: [
217 "liblog",
218 "libbase",
219 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700220 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700221 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700222 "libcutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000223 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700224 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000225 export_header_lib_headers: [
226 "libcutils_headers",
227 "libprocessgroup_headers",
228 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700229 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000230
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700231 cflags: [
232 "-Werror",
233 "-Wall",
234 "-Wextra",
235 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700236}
237
Elliott Hughes01705e42019-02-07 12:41:37 -0800238cc_defaults {
239 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800240 srcs: [
241 "native_handle_test.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530242 "properties_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800243 "sockets_test.cpp",
244 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800245
246 target: {
247 android: {
248 srcs: [
249 "android_get_control_file_test.cpp",
250 "android_get_control_socket_test.cpp",
251 "ashmem_test.cpp",
252 "fs_config_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800253 "multiuser_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800254 "sched_policy_test.cpp",
255 "str_parms_test.cpp",
256 "trace-dev_test.cpp",
257 ],
258 },
259
260 not_windows: {
261 srcs: [
262 "str_parms_test.cpp",
263 ],
264 },
265 },
266
267 cflags: [
268 "-Wall",
269 "-Wextra",
270 "-Werror",
271 ],
272}
273
Steven Moreland40b59a62023-06-06 17:52:39 +0000274always_static_test_libraries = [
275 "libjsoncpp",
276]
277
Elliott Hughes01705e42019-02-07 12:41:37 -0800278test_libraries = [
279 "libcutils",
280 "liblog",
281 "libbase",
Elliott Hughes01705e42019-02-07 12:41:37 -0800282 "libprocessgroup",
Yifan Hong53e0deb2019-03-22 17:01:08 -0700283 "libcgrouprc",
Elliott Hughes01705e42019-02-07 12:41:37 -0800284]
285
286cc_test {
287 name: "libcutils_test",
288 test_suites: ["device-tests"],
289 defaults: ["libcutils_test_default"],
290 host_supported: true,
291 shared_libs: test_libraries,
Steven Moreland40b59a62023-06-06 17:52:39 +0000292 static_libs: always_static_test_libraries,
Tom Cherrye41aded2019-11-07 14:06:21 -0800293 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800294}
295
nelsonlid83f3902020-01-16 17:20:18 +0800296cc_defaults {
297 name: "libcutils_test_static_defaults",
Elliott Hughes01705e42019-02-07 12:41:37 -0800298 defaults: ["libcutils_test_default"],
Yifan Hong53e0deb2019-03-22 17:01:08 -0700299 static_libs: [
300 "libc",
301 "libcgrouprc_format",
Steven Moreland40b59a62023-06-06 17:52:39 +0000302 ] + test_libraries + always_static_test_libraries,
Elliott Hughes01705e42019-02-07 12:41:37 -0800303 stl: "libc++_static",
Tom Cherrye41aded2019-11-07 14:06:21 -0800304 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800305
306 target: {
307 android: {
308 static_executable: true,
309 },
310 windows: {
311 host_ldlibs: ["-lws2_32"],
312
313 enabled: true,
314 },
315 },
316}
nelsonlid83f3902020-01-16 17:20:18 +0800317
318cc_test {
319 name: "libcutils_test_static",
320 test_suites: ["device-tests"],
321 defaults: ["libcutils_test_static_defaults"],
322}
323
324cc_test {
325 name: "KernelLibcutilsTest",
Michael Hoisied1e4c262024-03-06 17:22:45 +0000326 test_suites: [
327 "general-tests",
328 "vts",
329 ],
nelsonlid83f3902020-01-16 17:20:18 +0800330 defaults: ["libcutils_test_static_defaults"],
331 test_config: "KernelLibcutilsTest.xml",
332}