blob: 10392889d8a40b4955590adf2bc15453ce7aa4fc [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
Elliott Hughes527d71f2021-03-04 09:18:19 -080024cc_defaults {
25 name: "libcutils_defaults",
26 cflags: [
27 "-Wno-exit-time-destructors",
28 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -070029
Justin Yunfeef4d32020-11-11 19:17:40 +090030 product_available: true,
Tom Cherrya5edc0f2020-09-17 09:38:42 -070031 ramdisk_available: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080032 recovery_available: true,
33 vendor_available: true,
Yifan Hong55015ff2020-10-27 16:37:06 -070034 vendor_ramdisk_available: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080035
Vijay Venkatraman651f8382017-01-25 18:52:17 +000036 host_supported: true,
Elliott Hughes527d71f2021-03-04 09:18:19 -080037 native_bridge_supported: true,
38
Jiyong Park8bf9b162020-03-07 16:36:09 +090039 apex_available: [
40 "//apex_available:platform",
41 "//apex_available:anyapex",
42 ],
Jooyung Han88f00f22020-04-16 18:48:33 +090043 min_sdk_version: "29",
Elliott Hughes527d71f2021-03-04 09:18:19 -080044}
45
46cc_library_headers {
47 name: "libcutils_headers",
48 defaults: ["libcutils_defaults"],
49
Vijay Venkatraman651f8382017-01-25 18:52:17 +000050 export_include_dirs: ["include"],
T.J. Mercier1fd79932024-06-21 22:17:12 +000051 header_libs: ["libprocessgroup_headers"],
52 export_header_lib_headers: ["libprocessgroup_headers"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +000053 target: {
Steven Moreland385fe692017-04-13 14:29:58 -070054 vendor: {
Justin Yunfeef4d32020-11-11 19:17:40 +090055 override_export_include_dirs: ["include_outside_system"],
56 },
57 product: {
58 override_export_include_dirs: ["include_outside_system"],
Steven Moreland385fe692017-04-13 14:29:58 -070059 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070060 linux_bionic: {
61 enabled: true,
62 },
63 windows: {
64 enabled: true,
65 },
Vijay Venkatraman651f8382017-01-25 18:52:17 +000066 },
67}
68
Josh Gaoa9b62d52020-02-19 13:50:57 -080069// Socket specific parts of libcutils that are safe to statically link into an APEX.
Josh Gao7f8a37c2020-03-09 15:20:55 -070070cc_library {
Josh Gaoa9b62d52020-02-19 13:50:57 -080071 name: "libcutils_sockets",
Elliott Hughes527d71f2021-03-04 09:18:19 -080072 defaults: ["libcutils_defaults"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080073
74 export_include_dirs: ["include"],
75
Josh Gao7f8a37c2020-03-09 15:20:55 -070076 shared_libs: ["liblog"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080077 srcs: ["sockets.cpp"],
78 target: {
79 linux_bionic: {
80 enabled: true,
81 },
82
83 not_windows: {
84 srcs: [
85 "socket_inaddr_any_server_unix.cpp",
86 "socket_local_client_unix.cpp",
87 "socket_local_server_unix.cpp",
88 "socket_network_client_unix.cpp",
89 "sockets_unix.cpp",
90 ],
91 },
92
93 // "not_windows" means "non-Windows host".
94 android: {
95 srcs: [
96 "android_get_control_file.cpp",
97 "socket_inaddr_any_server_unix.cpp",
98 "socket_local_client_unix.cpp",
99 "socket_local_server_unix.cpp",
100 "socket_network_client_unix.cpp",
101 "sockets_unix.cpp",
102 ],
103 static_libs: ["libbase"],
104 },
105
106 windows: {
107 host_ldlibs: ["-lws2_32"],
108 srcs: [
109 "socket_inaddr_any_server_windows.cpp",
110 "socket_network_client_windows.cpp",
111 "sockets_windows.cpp",
112 ],
113
114 enabled: true,
115 cflags: [
116 "-D_GNU_SOURCE",
117 ],
118 },
119 },
120}
121
Elliott Hughes527d71f2021-03-04 09:18:19 -0800122// some files must not be compiled when building against Mingw
123// they correspond to features not used by our host development tools
124// which are also hard or even impossible to port to native Win32
125libcutils_nonwindows_sources = [
126 "fs.cpp",
127 "hashmap.cpp",
128 "multiuser.cpp",
129 "str_parms.cpp",
130]
131
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700132cc_library {
133 name: "libcutils",
Elliott Hughes527d71f2021-03-04 09:18:19 -0800134 defaults: ["libcutils_defaults"],
Kiyoung Kimad8cf522024-03-11 13:04:38 +0900135 double_loadable: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700136 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800137 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800138 "iosched_policy.cpp",
139 "load_file.cpp",
140 "native_handle.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530141 "properties.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800142 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700143 "strlcpy.c",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700144 ],
145
146 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700147 linux_bionic: {
148 enabled: true,
Brian Duddie9f2af692022-08-24 19:52:08 +0000149 static_libs: [
150 "libasync_safe",
151 ],
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700152 },
Elliott Hughes94ccdc02023-09-22 18:44:28 +0000153 linux: {
154 srcs: [
155 "canned_fs_config.cpp",
156 "fs_config.cpp",
157 ],
158 },
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000159 host: {
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700160 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800161 "trace-host.cpp",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000162 "ashmem-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700163 ],
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000164 },
165 not_windows: {
166 srcs: libcutils_nonwindows_sources,
167 },
168 windows: {
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700169 enabled: true,
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000170 host_ldlibs: ["-lws2_32"],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700171 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700172 android: {
Elliott Hughes06a839f2022-10-18 16:31:04 +0000173 sanitize: {
174 misc_undefined: ["integer"],
175 },
Brian Duddie9f2af692022-08-24 19:52:08 +0000176 static_libs: [
177 "libasync_safe",
178 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700179 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800180 "android_reboot.cpp",
181 "ashmem-dev.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700182 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800183 "partition_utils.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700184 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800185 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700186 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700187 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700188 },
189
Justin Yunfeef4d32020-11-11 19:17:40 +0900190 // qtaguid.cpp loads libnetd_client.so with dlopen(). Since
191 // the interface of libnetd_client.so may vary between AOSP
192 // releases, exclude qtaguid.cpp from the VNDK-SP variant.
Logan Chien25b742c2018-05-08 17:37:29 +0800193 vendor: {
194 exclude_srcs: [
Logan Chien25b742c2018-05-08 17:37:29 +0800195 "qtaguid.cpp",
196 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900197 header_abi_checker: {
198 enabled: true,
199 ref_dump_dirs: ["abi-dumps"],
200 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900201 },
202 product: {
203 exclude_srcs: [
204 "qtaguid.cpp",
205 ],
Kiyoung Kima4648c22023-06-23 11:12:38 +0900206 header_abi_checker: {
207 enabled: true,
208 ref_dump_dirs: ["abi-dumps"],
209 },
Justin Yunfeef4d32020-11-11 19:17:40 +0900210 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700211 },
212
Josh Gaoa9b62d52020-02-19 13:50:57 -0800213 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800214 shared_libs: [
215 "liblog",
216 "libbase",
217 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700218 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700219 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700220 "libcutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000221 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700222 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000223 export_header_lib_headers: [
224 "libcutils_headers",
225 "libprocessgroup_headers",
226 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700227 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000228
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700229 cflags: [
230 "-Werror",
231 "-Wall",
232 "-Wextra",
233 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700234}
235
Elliott Hughes01705e42019-02-07 12:41:37 -0800236cc_defaults {
237 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800238 srcs: [
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000239 "ashmem_base_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800240 "native_handle_test.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530241 "properties_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800242 "sockets_test.cpp",
243 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800244
245 target: {
246 android: {
247 srcs: [
248 "android_get_control_file_test.cpp",
249 "android_get_control_socket_test.cpp",
250 "ashmem_test.cpp",
251 "fs_config_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800252 "multiuser_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800253 "sched_policy_test.cpp",
254 "str_parms_test.cpp",
255 "trace-dev_test.cpp",
256 ],
257 },
258
259 not_windows: {
260 srcs: [
261 "str_parms_test.cpp",
262 ],
263 },
264 },
265
266 cflags: [
267 "-Wall",
268 "-Wextra",
269 "-Werror",
270 ],
271}
272
Steven Moreland40b59a62023-06-06 17:52:39 +0000273always_static_test_libraries = [
274 "libjsoncpp",
275]
276
Elliott Hughes01705e42019-02-07 12:41:37 -0800277test_libraries = [
278 "libcutils",
279 "liblog",
280 "libbase",
Elliott Hughes01705e42019-02-07 12:41:37 -0800281 "libprocessgroup",
282]
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: [
T.J. Merciera09ee8e2024-10-08 23:41:27 +0000304 "libprocessgroup_util",
Michael Hoisie7c4beee2024-01-12 19:18:19 +0000305 ] + 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}