blob: b135e57bc3789645dfc78ac40cd22592e204e3f6 [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
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
Elliott Hughes527d71f2021-03-04 09:18:19 -0800140// 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
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700150cc_library {
151 name: "libcutils",
Elliott Hughes527d71f2021-03-04 09:18:19 -0800152 defaults: ["libcutils_defaults"],
Justin Yun9ca92452017-07-31 15:41:10 +0900153 vndk: {
154 enabled: true,
155 support_system_process: true,
156 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700157 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800158 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800159 "iosched_policy.cpp",
160 "load_file.cpp",
161 "native_handle.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530162 "properties.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800163 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700164 "strlcpy.c",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800165 "threads.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700166 ],
167
168 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700169 linux_bionic: {
170 enabled: true,
Brian Duddie9f2af692022-08-24 19:52:08 +0000171 static_libs: [
172 "libasync_safe",
173 ],
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700174 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700175 not_windows: {
176 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800177 "ashmem-host.cpp",
Jiyong Parkd8602912021-12-13 13:11:10 +0900178 "canned_fs_config.cpp",
Elliott Hughes39d6c8e2021-03-08 18:50:59 +0000179 "fs_config.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800180 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700181 ],
182 },
183 windows: {
Steven Morelande6132be2019-03-25 20:38:56 -0700184 host_ldlibs: ["-lws2_32"],
185
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700186 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800187 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700188 ],
189
190 enabled: true,
Mark Salyzyn163ecc62017-05-02 08:56:15 -0700191 cflags: [
192 "-D_GNU_SOURCE",
193 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700194 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700195 android: {
Elliott Hughes06a839f2022-10-18 16:31:04 +0000196 sanitize: {
197 misc_undefined: ["integer"],
198 },
Brian Duddie9f2af692022-08-24 19:52:08 +0000199 static_libs: [
200 "libasync_safe",
201 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700202 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800203 "android_reboot.cpp",
204 "ashmem-dev.cpp",
Jiyong Parkd8602912021-12-13 13:11:10 +0900205 "canned_fs_config.cpp",
Elliott Hughes39d6c8e2021-03-08 18:50:59 +0000206 "fs_config.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700207 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800208 "partition_utils.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700209 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800210 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700211 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700212 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700213 },
214
Justin Yunfeef4d32020-11-11 19:17:40 +0900215 // 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.
Logan Chien25b742c2018-05-08 17:37:29 +0800218 vendor: {
219 exclude_srcs: [
Logan Chien25b742c2018-05-08 17:37:29 +0800220 "qtaguid.cpp",
221 ],
Justin Yunfeef4d32020-11-11 19:17:40 +0900222 },
223 product: {
224 exclude_srcs: [
225 "qtaguid.cpp",
226 ],
227 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700228 },
229
Josh Gaoa9b62d52020-02-19 13:50:57 -0800230 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800231 shared_libs: [
232 "liblog",
233 "libbase",
234 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700235 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700236 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700237 "libcutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000238 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700239 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000240 export_header_lib_headers: [
241 "libcutils_headers",
242 "libprocessgroup_headers",
243 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700244 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000245
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700246 cflags: [
247 "-Werror",
248 "-Wall",
249 "-Wextra",
250 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700251}
252
Elliott Hughes01705e42019-02-07 12:41:37 -0800253cc_defaults {
254 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800255 srcs: [
256 "native_handle_test.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530257 "properties_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800258 "sockets_test.cpp",
259 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800260
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",
Elliott Hughes01705e42019-02-07 12:41:37 -0800268 "multiuser_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800269 "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
289test_libraries = [
290 "libcutils",
291 "liblog",
292 "libbase",
293 "libjsoncpp",
294 "libprocessgroup",
Yifan Hong53e0deb2019-03-22 17:01:08 -0700295 "libcgrouprc",
Elliott Hughes01705e42019-02-07 12:41:37 -0800296]
297
298cc_test {
299 name: "libcutils_test",
300 test_suites: ["device-tests"],
301 defaults: ["libcutils_test_default"],
302 host_supported: true,
303 shared_libs: test_libraries,
Tom Cherrye41aded2019-11-07 14:06:21 -0800304 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800305}
306
nelsonlid83f3902020-01-16 17:20:18 +0800307cc_defaults {
308 name: "libcutils_test_static_defaults",
Elliott Hughes01705e42019-02-07 12:41:37 -0800309 defaults: ["libcutils_test_default"],
Yifan Hong53e0deb2019-03-22 17:01:08 -0700310 static_libs: [
311 "libc",
312 "libcgrouprc_format",
313 ] + test_libraries,
Elliott Hughes01705e42019-02-07 12:41:37 -0800314 stl: "libc++_static",
Tom Cherrye41aded2019-11-07 14:06:21 -0800315 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800316
317 target: {
318 android: {
319 static_executable: true,
320 },
321 windows: {
322 host_ldlibs: ["-lws2_32"],
323
324 enabled: true,
325 },
326 },
327}
nelsonlid83f3902020-01-16 17:20:18 +0800328
329cc_test {
330 name: "libcutils_test_static",
331 test_suites: ["device-tests"],
332 defaults: ["libcutils_test_static_defaults"],
333}
334
335cc_test {
336 name: "KernelLibcutilsTest",
Dan Shia7b9a2b2020-04-06 16:11:29 -0700337 test_suites: ["general-tests", "vts"],
nelsonlid83f3902020-01-16 17:20:18 +0800338 defaults: ["libcutils_test_static_defaults"],
339 test_config: "KernelLibcutilsTest.xml",
340}