blob: dccf58880944f7ab62d2c004d2a2e1f7cba92c9c [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 ],
dimitry051d5cb2019-05-16 14:17:00 +020036 native_bridge_supported: true,
Vijay Venkatraman651f8382017-01-25 18:52:17 +000037 export_include_dirs: ["include"],
38 target: {
Steven Moreland385fe692017-04-13 14:29:58 -070039 vendor: {
Steven Morelande1c834d2018-01-05 14:42:12 -080040 override_export_include_dirs: ["include_vndk"],
Steven Moreland385fe692017-04-13 14:29:58 -070041 },
Dan Willemsene0cd1e02017-03-15 15:23:36 -070042 linux_bionic: {
43 enabled: true,
44 },
45 windows: {
46 enabled: true,
47 },
Vijay Venkatraman651f8382017-01-25 18:52:17 +000048 },
49}
50
Josh Gaoa9b62d52020-02-19 13:50:57 -080051// Socket specific parts of libcutils that are safe to statically link into an APEX.
Josh Gao7f8a37c2020-03-09 15:20:55 -070052cc_library {
Josh Gaoa9b62d52020-02-19 13:50:57 -080053 name: "libcutils_sockets",
54 vendor_available: true,
Josh Gaoa9b62d52020-02-19 13:50:57 -080055 recovery_available: true,
56 host_supported: true,
57 native_bridge_supported: true,
58 apex_available: [
59 "//apex_available:platform",
60 "//apex_available:anyapex",
61 ],
62
63 export_include_dirs: ["include"],
64
Josh Gao7f8a37c2020-03-09 15:20:55 -070065 shared_libs: ["liblog"],
Josh Gaoa9b62d52020-02-19 13:50:57 -080066 srcs: ["sockets.cpp"],
67 target: {
68 linux_bionic: {
69 enabled: true,
70 },
71
72 not_windows: {
73 srcs: [
74 "socket_inaddr_any_server_unix.cpp",
75 "socket_local_client_unix.cpp",
76 "socket_local_server_unix.cpp",
77 "socket_network_client_unix.cpp",
78 "sockets_unix.cpp",
79 ],
80 },
81
82 // "not_windows" means "non-Windows host".
83 android: {
84 srcs: [
85 "android_get_control_file.cpp",
86 "socket_inaddr_any_server_unix.cpp",
87 "socket_local_client_unix.cpp",
88 "socket_local_server_unix.cpp",
89 "socket_network_client_unix.cpp",
90 "sockets_unix.cpp",
91 ],
92 static_libs: ["libbase"],
93 },
94
95 windows: {
96 host_ldlibs: ["-lws2_32"],
97 srcs: [
98 "socket_inaddr_any_server_windows.cpp",
99 "socket_network_client_windows.cpp",
100 "sockets_windows.cpp",
101 ],
102
103 enabled: true,
104 cflags: [
105 "-D_GNU_SOURCE",
106 ],
107 },
108 },
109}
110
111cc_test {
112 name: "libcutils_sockets_test",
113 test_suites: ["device-tests"],
114 static_libs: ["libbase", "libcutils_sockets"],
115 cflags: [
116 "-Wall",
117 "-Wextra",
118 "-Werror",
119 ],
120
121 srcs: ["sockets_test.cpp"],
122 target: {
123 android: {
124 srcs: [
125 "android_get_control_file_test.cpp",
126 "android_get_control_socket_test.cpp",
127 ],
128 },
129 },
130}
131
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700132cc_library {
133 name: "libcutils",
Steven Moreland385fe692017-04-13 14:29:58 -0700134 vendor_available: true,
Justin Yun9ca92452017-07-31 15:41:10 +0900135 vndk: {
136 enabled: true,
137 support_system_process: true,
138 },
Jiyong Park612210c2018-04-27 21:48:43 +0900139 recovery_available: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700140 host_supported: true,
Jiyong Park8bf9b162020-03-07 16:36:09 +0900141 apex_available: [
142 "//apex_available:platform",
143 "//apex_available:anyapex",
144 ],
dimitry051d5cb2019-05-16 14:17:00 +0200145 native_bridge_supported: true,
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700146 srcs: [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800147 "config_utils.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800148 "canned_fs_config.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800149 "iosched_policy.cpp",
150 "load_file.cpp",
151 "native_handle.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800152 "record_stream.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700153 "strlcpy.c",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800154 "threads.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700155 ],
156
157 target: {
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700158 linux_bionic: {
159 enabled: true,
Dan Willemsene0cd1e02017-03-15 15:23:36 -0700160 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700161 not_windows: {
162 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800163 "ashmem-host.cpp",
Jiyong Parka2159c42019-02-03 00:34:29 +0900164 "fs_config.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800165 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700166 ],
167 },
168 windows: {
Steven Morelande6132be2019-03-25 20:38:56 -0700169 host_ldlibs: ["-lws2_32"],
170
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700171 srcs: [
David Sehreb2dd202018-12-20 12:59:36 -0800172 "trace-host.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700173 ],
174
175 enabled: true,
Mark Salyzyn163ecc62017-05-02 08:56:15 -0700176 cflags: [
177 "-D_GNU_SOURCE",
178 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700179 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700180 android: {
181 srcs: libcutils_nonwindows_sources + [
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800182 "android_reboot.cpp",
183 "ashmem-dev.cpp",
Jiyong Parka2159c42019-02-03 00:34:29 +0900184 "fs_config.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700185 "klog.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800186 "partition_utils.cpp",
Elliott Hughes4eacd702017-01-26 17:31:40 -0800187 "properties.cpp",
Chenbo Fengbaede732017-10-25 12:31:43 -0700188 "qtaguid.cpp",
Elliott Hughes8e9aeb92017-11-10 10:22:07 -0800189 "trace-dev.cpp",
Luis Hector Chaveze97a4b92017-11-02 14:17:43 -0700190 "uevent.cpp",
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700191 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700192 },
193
194 android_arm: {
195 srcs: ["arch-arm/memset32.S"],
196 sanitize: {
197 misc_undefined: ["integer"],
198 },
199 },
200 android_arm64: {
201 srcs: ["arch-arm64/android_memset.S"],
Evgenii Stepanov54c78862017-01-31 16:33:53 -0800202 sanitize: {
203 misc_undefined: ["integer"],
204 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700205 },
206
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700207 android_x86: {
208 srcs: [
209 "arch-x86/android_memset16.S",
210 "arch-x86/android_memset32.S",
211 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700212 // TODO: This is to work around b/29412086.
213 // Remove once __mulodi4 is available and move the "sanitize" block
214 // to the android target.
215 sanitize: {
216 misc_undefined: [],
217 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700218 },
219
220 android_x86_64: {
221 srcs: [
222 "arch-x86_64/android_memset16.S",
223 "arch-x86_64/android_memset32.S",
224 ],
Luis Hector Chavezfae195b2017-11-03 16:22:05 -0700225 sanitize: {
226 misc_undefined: ["integer"],
227 },
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700228 },
Logan Chien25b742c2018-05-08 17:37:29 +0800229
230 vendor: {
231 exclude_srcs: [
232 // qtaguid.cpp loads libnetd_client.so with dlopen(). Since
233 // the interface of libnetd_client.so may vary between AOSP
234 // releases, exclude qtaguid.cpp from the VNDK-SP variant.
235 "qtaguid.cpp",
236 ],
237 }
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700238 },
239
Josh Gaoa9b62d52020-02-19 13:50:57 -0800240 whole_static_libs: ["libcutils_sockets"],
Joel Fernandes51944042018-12-18 13:32:31 -0800241 shared_libs: [
242 "liblog",
243 "libbase",
244 ],
Steven Morelandd73be1b2017-04-13 23:48:57 -0700245 header_libs: [
Elliott Hughes9f495082018-04-25 14:52:50 -0700246 "libbase_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700247 "libcutils_headers",
248 "libutils_headers",
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000249 "libprocessgroup_headers",
Steven Morelandd73be1b2017-04-13 23:48:57 -0700250 ],
Suren Baghdasaryan1bd127b2019-01-25 05:30:52 +0000251 export_header_lib_headers: [
252 "libcutils_headers",
253 "libprocessgroup_headers",
254 ],
Yifan Hongb6807122017-07-25 15:24:04 -0700255 local_include_dirs: ["include"],
Vijay Venkatraman651f8382017-01-25 18:52:17 +0000256
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700257 cflags: [
258 "-Werror",
259 "-Wall",
260 "-Wextra",
261 ],
Dan Willemseneee8e7f2016-06-06 22:31:58 -0700262}
263
Elliott Hughes01705e42019-02-07 12:41:37 -0800264cc_defaults {
265 name: "libcutils_test_default",
Elliott Hughes7e424842019-11-12 20:20:42 -0800266 srcs: [
267 "native_handle_test.cpp",
268 "sockets_test.cpp",
269 ],
Elliott Hughes01705e42019-02-07 12:41:37 -0800270
271 target: {
272 android: {
273 srcs: [
274 "android_get_control_file_test.cpp",
275 "android_get_control_socket_test.cpp",
276 "ashmem_test.cpp",
277 "fs_config_test.cpp",
278 "memset_test.cpp",
279 "multiuser_test.cpp",
280 "properties_test.cpp",
281 "sched_policy_test.cpp",
282 "str_parms_test.cpp",
283 "trace-dev_test.cpp",
284 ],
285 },
286
287 not_windows: {
288 srcs: [
289 "str_parms_test.cpp",
290 ],
291 },
292 },
293
294 cflags: [
295 "-Wall",
296 "-Wextra",
297 "-Werror",
298 ],
299}
300
301test_libraries = [
302 "libcutils",
303 "liblog",
304 "libbase",
305 "libjsoncpp",
306 "libprocessgroup",
Yifan Hong53e0deb2019-03-22 17:01:08 -0700307 "libcgrouprc",
Elliott Hughes01705e42019-02-07 12:41:37 -0800308]
309
310cc_test {
311 name: "libcutils_test",
312 test_suites: ["device-tests"],
313 defaults: ["libcutils_test_default"],
314 host_supported: true,
315 shared_libs: test_libraries,
Tom Cherrye41aded2019-11-07 14:06:21 -0800316 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800317}
318
nelsonlid83f3902020-01-16 17:20:18 +0800319cc_defaults {
320 name: "libcutils_test_static_defaults",
Elliott Hughes01705e42019-02-07 12:41:37 -0800321 defaults: ["libcutils_test_default"],
Yifan Hong53e0deb2019-03-22 17:01:08 -0700322 static_libs: [
323 "libc",
324 "libcgrouprc_format",
325 ] + test_libraries,
Elliott Hughes01705e42019-02-07 12:41:37 -0800326 stl: "libc++_static",
Tom Cherrye41aded2019-11-07 14:06:21 -0800327 require_root: true,
Elliott Hughes01705e42019-02-07 12:41:37 -0800328
329 target: {
330 android: {
331 static_executable: true,
332 },
333 windows: {
334 host_ldlibs: ["-lws2_32"],
335
336 enabled: true,
337 },
338 },
339}
nelsonlid83f3902020-01-16 17:20:18 +0800340
341cc_test {
342 name: "libcutils_test_static",
343 test_suites: ["device-tests"],
344 defaults: ["libcutils_test_static_defaults"],
345}
346
347cc_test {
348 name: "KernelLibcutilsTest",
349 test_suites: ["general-tests", "vts-core"],
350 defaults: ["libcutils_test_static_defaults"],
351 test_config: "KernelLibcutilsTest.xml",
352}