blob: 60400c98cbb22557ebc3ef3efb3a29f7230b2915 [file] [log] [blame]
Dan Willemseneee8e7f2016-06-06 22:31:58 -07001//
2// Copyright (C) 2008 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// some files must not be compiled when building against Mingw
18// they correspond to features not used by our host development tools
19// which are also hard or even impossible to port to native Win32
20libcutils_nonwindows_sources = [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -080021 "fs.cpp",
Elliott Hughes9d127252018-07-13 10:54:49 -070022 "hashmap.cpp",
Jeff Sharkey53d37ba2017-11-09 17:41:09 -070023 "multiuser.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -080024 "str_parms.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -070025]
26
Vijay Venkatraman651f8382017-01-25 18:52:17 +000027cc_library_headers {
Vijay Venkatraman651f8382017-01-25 18:52:17 +000028 name: "libcutils_headers",
Steven Moreland385fe692017-04-13 14:29:58 -070029 vendor_available: true,
Jiyong Park612210c2018-04-27 21:48:43 +090030 recovery_available: true,
Vijay Venkatraman651f8382017-01-25 18:52:17 +000031 host_supported: true,
Jiyong Park8bf9b162020-03-07 16:36:09 +090032 apex_available: [
33 "//apex_available:platform",
34 "//apex_available:anyapex",
35 ],
Jooyung Han88f00f22020-04-16 18:48:33 +090036 min_sdk_version: "29",
dimitry051d5cb2019-05-16 14:17:00 +020037 native_bridge_supported: true,
Vijay Venkatraman651f8382017-01-25 18:52:17 +000038 export_include_dirs: ["include"],
39 target: {
Steven Moreland385fe692017-04-13 14:29:58 -070040 vendor: {
Steven Morelande1c834d2018-01-05 14:42:12 -080041 override_export_include_dirs: ["include_vndk"],
Steven Moreland385fe692017-04-13 14:29:58 -070042 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070043 linux_bionic: {
44 enabled: true,
45 },
46 windows: {
47 enabled: true,
48 },
Vijay Venkatraman651f8382017-01-25 18:52:17 +000049 },
50}
51
Josh Gaoa9b62d52020-02-19 13:50:57 -080052// Socket specific parts of libcutils that are safe to statically link into an APEX.
Josh Gao7f8a37c2020-03-09 15:20:55 -070053cc_library {
Josh Gaoa9b62d52020-02-19 13:50:57 -080054 name: "libcutils_sockets",
55 vendor_available: true,
Josh Gaoa9b62d52020-02-19 13:50:57 -080056 recovery_available: true,
57 host_supported: true,
58 native_bridge_supported: true,
59 apex_available: [
60 "//apex_available:platform",
61 "//apex_available:anyapex",
62 ],
Jooyung Han88f00f22020-04-16 18:48:33 +090063 min_sdk_version: "29",
Josh Gaoa9b62d52020-02-19 13:50:57 -080064
65 export_include_dirs: ["include"],
66
Josh Gao7f8a37c2020-03-09 15:20:55 -070067 shared_libs: ["liblog"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080068 srcs: ["sockets.cpp"],
69 target: {
70 linux_bionic: {
71 enabled: true,
72 },
73
74 not_windows: {
75 srcs: [
76 "socket_inaddr_any_server_unix.cpp",
77 "socket_local_client_unix.cpp",
78 "socket_local_server_unix.cpp",
79 "socket_network_client_unix.cpp",
80 "sockets_unix.cpp",
81 ],
82 },
83
84 // "not_windows" means "non-Windows host".
85 android: {
86 srcs: [
87 "android_get_control_file.cpp",
88 "socket_inaddr_any_server_unix.cpp",
89 "socket_local_client_unix.cpp",
90 "socket_local_server_unix.cpp",
91 "socket_network_client_unix.cpp",
92 "sockets_unix.cpp",
93 ],
94 static_libs: ["libbase"],
95 },
96
97 windows: {
98 host_ldlibs: ["-lws2_32"],
99 srcs: [
100 "socket_inaddr_any_server_windows.cpp",
101 "socket_network_client_windows.cpp",
102 "sockets_windows.cpp",
103 ],
104
105 enabled: true,
106 cflags: [
107 "-D_GNU_SOURCE",
108 ],
109 },
110 },
111}
112
113cc_test {
114 name: "libcutils_sockets_test",
115 test_suites: ["device-tests"],
116 static_libs: ["libbase", "libcutils_sockets"],
117 cflags: [
118 "-Wall",
119 "-Wextra",
120 "-Werror",
121 ],
122
123 srcs: ["sockets_test.cpp"],
124 target: {
125 android: {
126 srcs: [
127 "android_get_control_file_test.cpp",
128 "android_get_control_socket_test.cpp",
129 ],
130 },
131 },
132}
133
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700134cc_library {
135 name: "libcutils",
Steven Moreland385fe692017-04-13 14:29:58 -0700136 vendor_available: true,
Justin Yun9ca92452017-07-31 15:41:10 +0900137 vndk: {
138 enabled: true,
139 support_system_process: true,
140 },
Jiyong Park612210c2018-04-27 21:48:43 +0900141 recovery_available: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700142 host_supported: true,
Jiyong Park8bf9b162020-03-07 16:36:09 +0900143 apex_available: [
144 "//apex_available:platform",
145 "//apex_available:anyapex",
146 ],
Jooyung Han88f00f22020-04-16 18:48:33 +0900147 min_sdk_version: "29",
dimitry051d5cb2019-05-16 14:17:00 +0200148 native_bridge_supported: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700149 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800150 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800151 "canned_fs_config.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800152 "iosched_policy.cpp",
153 "load_file.cpp",
154 "native_handle.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530155 "properties.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800156 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700157 "strlcpy.c",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800158 "threads.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700159 ],
160
161 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700162 linux_bionic: {
163 enabled: true,
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700164 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700165 not_windows: {
166 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800167 "ashmem-host.cpp",
Jiyong Parka2159c42019-02-03 00:34:29 +0900168 "fs_config.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800169 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700170 ],
171 },
172 windows: {
Steven Morelande6132be2019-03-25 20:38:56 -0700173 host_ldlibs: ["-lws2_32"],
174
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700175 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800176 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700177 ],
178
179 enabled: true,
Mark Salyzyn163ecc62017-05-02 08:56:15 -0700180 cflags: [
181 "-D_GNU_SOURCE",
182 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700183 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700184 android: {
185 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800186 "android_reboot.cpp",
187 "ashmem-dev.cpp",
Jiyong Parka2159c42019-02-03 00:34:29 +0900188 "fs_config.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700189 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800190 "partition_utils.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700191 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800192 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700193 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700194 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700195 },
196
197 android_arm: {
198 srcs: ["arch-arm/memset32.S"],
199 sanitize: {
200 misc_undefined: ["integer"],
201 },
202 },
203 android_arm64: {
204 srcs: ["arch-arm64/android_memset.S"],
Evgenii Stepanov54c78862017-01-31 16:33:53 -0800205 sanitize: {
206 misc_undefined: ["integer"],
207 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700208 },
209
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700210 android_x86: {
211 srcs: [
212 "arch-x86/android_memset16.S",
213 "arch-x86/android_memset32.S",
214 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700215 // TODO: This is to work around b/29412086.
216 // Remove once __mulodi4 is available and move the "sanitize" block
217 // to the android target.
218 sanitize: {
219 misc_undefined: [],
220 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700221 },
222
223 android_x86_64: {
224 srcs: [
225 "arch-x86_64/android_memset16.S",
226 "arch-x86_64/android_memset32.S",
227 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700228 sanitize: {
229 misc_undefined: ["integer"],
230 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700231 },
Logan Chien25b742c2018-05-08 17:37:29 +0800232
233 vendor: {
234 exclude_srcs: [
235 // qtaguid.cpp loads libnetd_client.so with dlopen(). Since
236 // the interface of libnetd_client.so may vary between AOSP
237 // releases, exclude qtaguid.cpp from the VNDK-SP variant.
238 "qtaguid.cpp",
239 ],
240 }
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700241 },
242
Josh Gaoa9b62d52020-02-19 13:50:57 -0800243 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800244 shared_libs: [
245 "liblog",
246 "libbase",
247 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700248 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700249 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700250 "libcutils_headers",
251 "libutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000252 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700253 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000254 export_header_lib_headers: [
255 "libcutils_headers",
256 "libprocessgroup_headers",
257 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700258 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000259
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700260 cflags: [
261 "-Werror",
262 "-Wall",
263 "-Wextra",
264 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700265}
266
Elliott Hughes01705e42019-02-07 12:41:37 -0800267cc_defaults {
268 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800269 srcs: [
270 "native_handle_test.cpp",
S Vasudev Prasad100b08a2020-05-08 11:45:45 +0530271 "properties_test.cpp",
Elliott Hughes7e424842019-11-12 20:20:42 -0800272 "sockets_test.cpp",
273 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800274
275 target: {
276 android: {
277 srcs: [
278 "android_get_control_file_test.cpp",
279 "android_get_control_socket_test.cpp",
280 "ashmem_test.cpp",
281 "fs_config_test.cpp",
282 "memset_test.cpp",
283 "multiuser_test.cpp",
Elliott Hughes01705e42019-02-07 12:41:37 -0800284 "sched_policy_test.cpp",
285 "str_parms_test.cpp",
286 "trace-dev_test.cpp",
287 ],
288 },
289
290 not_windows: {
291 srcs: [
292 "str_parms_test.cpp",
293 ],
294 },
295 },
296
297 cflags: [
298 "-Wall",
299 "-Wextra",
300 "-Werror",
301 ],
302}
303
304test_libraries = [
305 "libcutils",
306 "liblog",
307 "libbase",
308 "libjsoncpp",
309 "libprocessgroup",
Yifan Hong53e0deb2019-03-22 17:01:08 -0700310 "libcgrouprc",
Elliott Hughes01705e42019-02-07 12:41:37 -0800311]
312
313cc_test {
314 name: "libcutils_test",
315 test_suites: ["device-tests"],
316 defaults: ["libcutils_test_default"],
317 host_supported: true,
318 shared_libs: test_libraries,
Tom Cherrye41aded2019-11-07 14:06:21 -0800319 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800320}
321
nelsonlid83f3902020-01-16 17:20:18 +0800322cc_defaults {
323 name: "libcutils_test_static_defaults",
Elliott Hughes01705e42019-02-07 12:41:37 -0800324 defaults: ["libcutils_test_default"],
Yifan Hong53e0deb2019-03-22 17:01:08 -0700325 static_libs: [
326 "libc",
327 "libcgrouprc_format",
328 ] + test_libraries,
Elliott Hughes01705e42019-02-07 12:41:37 -0800329 stl: "libc++_static",
Tom Cherrye41aded2019-11-07 14:06:21 -0800330 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800331
332 target: {
333 android: {
334 static_executable: true,
335 },
336 windows: {
337 host_ldlibs: ["-lws2_32"],
338
339 enabled: true,
340 },
341 },
342}
nelsonlid83f3902020-01-16 17:20:18 +0800343
344cc_test {
345 name: "libcutils_test_static",
346 test_suites: ["device-tests"],
347 defaults: ["libcutils_test_static_defaults"],
348}
349
350cc_test {
351 name: "KernelLibcutilsTest",
Dan Shiab8acae2020-03-26 11:51:48 -0700352 test_suites: ["general-tests", "vts"],
nelsonlid83f3902020-01-16 17:20:18 +0800353 defaults: ["libcutils_test_static_defaults"],
354 test_config: "KernelLibcutilsTest.xml",
355}