• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_applicable_licenses: ["system_core_libcutils_license"],
3}
4
5license {
6    name: "system_core_libcutils_license",
7    visibility: [":__subpackages__"],
8    license_kinds: [
9        "SPDX-license-identifier-Apache-2.0",
10        "SPDX-license-identifier-BSD",
11        "SPDX-license-identifier-MIT", // strlcpy.c
12    ],
13    license_text: [
14        "NOTICE",
15    ],
16}
17
18filegroup {
19    name: "android_filesystem_config_header",
20    srcs: ["include/private/android_filesystem_config.h"],
21}
22
23cc_defaults {
24    name: "libcutils_defaults",
25    cflags: [
26        "-Wno-exit-time-destructors",
27    ],
28
29    product_available: true,
30    ramdisk_available: true,
31    recovery_available: true,
32    vendor_available: true,
33    vendor_ramdisk_available: true,
34
35    host_supported: true,
36    native_bridge_supported: true,
37
38    apex_available: [
39        "//apex_available:platform",
40        "//apex_available:anyapex",
41    ],
42    min_sdk_version: "29",
43}
44
45cc_library_headers {
46    name: "libcutils_headers",
47    defaults: ["libcutils_defaults"],
48
49    export_include_dirs: ["include"],
50    target: {
51        vendor: {
52            override_export_include_dirs: ["include_outside_system"],
53        },
54        product: {
55            override_export_include_dirs: ["include_outside_system"],
56        },
57        linux_bionic: {
58            enabled: true,
59        },
60        windows: {
61            enabled: true,
62        },
63    },
64}
65
66// Socket specific parts of libcutils that are safe to statically link into an APEX.
67cc_library {
68    name: "libcutils_sockets",
69    defaults: ["libcutils_defaults"],
70
71    export_include_dirs: ["include"],
72
73    shared_libs: ["liblog"],
74    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
140// 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
150cc_library {
151    name: "libcutils",
152    defaults: ["libcutils_defaults"],
153    vndk: {
154        enabled: true,
155        support_system_process: true,
156    },
157    srcs: [
158        "config_utils.cpp",
159        "canned_fs_config.cpp",
160        "iosched_policy.cpp",
161        "load_file.cpp",
162        "native_handle.cpp",
163        "properties.cpp",
164        "record_stream.cpp",
165        "strlcpy.c",
166        "threads.cpp",
167    ],
168
169    target: {
170        linux_bionic: {
171            enabled: true,
172        },
173        not_windows: {
174            srcs: libcutils_nonwindows_sources + [
175                "ashmem-host.cpp",
176                "fs_config.cpp",
177                "trace-host.cpp",
178            ],
179        },
180        windows: {
181            host_ldlibs: ["-lws2_32"],
182
183            srcs: [
184                "trace-host.cpp",
185            ],
186
187            enabled: true,
188            cflags: [
189                "-D_GNU_SOURCE",
190            ],
191        },
192        android: {
193            srcs: libcutils_nonwindows_sources + [
194                "android_reboot.cpp",
195                "ashmem-dev.cpp",
196                "fs_config.cpp",
197                "klog.cpp",
198                "partition_utils.cpp",
199                "qtaguid.cpp",
200                "trace-dev.cpp",
201                "uevent.cpp",
202            ],
203        },
204
205        android_arm: {
206            sanitize: {
207                misc_undefined: ["integer"],
208            },
209        },
210        android_arm64: {
211            sanitize: {
212                misc_undefined: ["integer"],
213            },
214        },
215
216        android_x86: {
217            // TODO: This is to work around b/29412086.
218            // Remove once __mulodi4 is available and move the "sanitize" block
219            // to the android target.
220            sanitize: {
221                misc_undefined: [],
222            },
223        },
224
225        android_x86_64: {
226            sanitize: {
227                misc_undefined: ["integer"],
228            },
229        },
230
231        // qtaguid.cpp loads libnetd_client.so with dlopen().  Since
232        // the interface of libnetd_client.so may vary between AOSP
233        // releases, exclude qtaguid.cpp from the VNDK-SP variant.
234        vendor: {
235            exclude_srcs: [
236                "qtaguid.cpp",
237            ],
238        },
239        product: {
240            exclude_srcs: [
241                "qtaguid.cpp",
242            ],
243        },
244    },
245
246    whole_static_libs: ["libcutils_sockets"],
247    shared_libs: [
248        "liblog",
249        "libbase",
250    ],
251    header_libs: [
252        "libbase_headers",
253        "libcutils_headers",
254        "libprocessgroup_headers",
255    ],
256    export_header_lib_headers: [
257        "libcutils_headers",
258        "libprocessgroup_headers",
259    ],
260    local_include_dirs: ["include"],
261
262    cflags: [
263        "-Werror",
264        "-Wall",
265        "-Wextra",
266    ],
267}
268
269cc_defaults {
270    name: "libcutils_test_default",
271    srcs: [
272        "native_handle_test.cpp",
273        "properties_test.cpp",
274        "sockets_test.cpp",
275    ],
276
277    target: {
278        android: {
279            srcs: [
280                "android_get_control_file_test.cpp",
281                "android_get_control_socket_test.cpp",
282                "ashmem_test.cpp",
283                "fs_config_test.cpp",
284                "multiuser_test.cpp",
285                "sched_policy_test.cpp",
286                "str_parms_test.cpp",
287                "trace-dev_test.cpp",
288            ],
289        },
290
291        not_windows: {
292            srcs: [
293                "str_parms_test.cpp",
294            ],
295        },
296    },
297
298    cflags: [
299        "-Wall",
300        "-Wextra",
301        "-Werror",
302    ],
303}
304
305test_libraries = [
306    "libcutils",
307    "liblog",
308    "libbase",
309    "libjsoncpp",
310    "libprocessgroup",
311    "libcgrouprc",
312]
313
314cc_test {
315    name: "libcutils_test",
316    test_suites: ["device-tests"],
317    defaults: ["libcutils_test_default"],
318    host_supported: true,
319    shared_libs: test_libraries,
320    require_root: true,
321}
322
323cc_defaults {
324    name: "libcutils_test_static_defaults",
325    defaults: ["libcutils_test_default"],
326    static_libs: [
327        "libc",
328        "libcgrouprc_format",
329    ] + test_libraries,
330    stl: "libc++_static",
331    require_root: true,
332
333    target: {
334        android: {
335            static_executable: true,
336        },
337        windows: {
338            host_ldlibs: ["-lws2_32"],
339
340            enabled: true,
341        },
342    },
343}
344
345cc_test {
346    name: "libcutils_test_static",
347    test_suites: ["device-tests"],
348    defaults: ["libcutils_test_static_defaults"],
349}
350
351cc_test {
352    name: "KernelLibcutilsTest",
353    test_suites: ["general-tests", "vts"],
354    defaults: ["libcutils_test_static_defaults"],
355    test_config: "KernelLibcutilsTest.xml",
356}
357
358rust_bindgen {
359    name: "libcutils_bindgen",
360    wrapper_src: "rust/cutils.h",
361    crate_name: "cutils_bindgen",
362    source_stem: "bindings",
363    local_include_dirs: ["include"],
364    bindgen_flags: [
365        "--allowlist-function", "multiuser_get_app_id",
366        "--allowlist-function", "multiuser_get_uid",
367        "--allowlist-function", "multiuser_get_user_id",
368        "--allowlist-var", "AID_KEYSTORE",
369        "--allowlist-var", "AID_USER_OFFSET",
370    ],
371}
372