• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2015 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
17package {
18    default_applicable_licenses: ["system_libbase_license"],
19}
20
21license {
22    name: "system_libbase_license",
23    visibility: [":__subpackages__"],
24    license_kinds: [
25        "SPDX-license-identifier-Apache-2.0",
26        "SPDX-license-identifier-BSD",
27    ],
28    license_text: [
29        "NOTICE",
30    ],
31}
32
33cc_defaults {
34    name: "libbase_cflags_defaults",
35    cflags: [
36        "-Wall",
37        "-Werror",
38        "-Wextra",
39    ],
40    target: {
41        android: {
42            cflags: [
43                "-D_FILE_OFFSET_BITS=64",
44            ],
45        },
46    },
47}
48
49cc_library_headers {
50    name: "libbase_headers",
51    vendor_available: true,
52    product_available: true,
53    ramdisk_available: true,
54    vendor_ramdisk_available: true,
55    recovery_available: true,
56    host_supported: true,
57    native_bridge_supported: true,
58    export_include_dirs: ["include"],
59
60    header_libs: ["fmtlib_headers"],
61    export_header_lib_headers: ["fmtlib_headers"],
62
63    target: {
64        linux_bionic: {
65            enabled: true,
66        },
67        windows: {
68            enabled: true,
69        },
70    },
71    apex_available: [
72        "//apex_available:anyapex",
73        "//apex_available:platform",
74    ],
75    min_sdk_version: "29",
76}
77
78cc_defaults {
79    name: "libbase_defaults",
80    defaults: ["libbase_cflags_defaults"],
81    srcs: [
82        "abi_compatibility.cpp",
83        "chrono_utils.cpp",
84        "cmsg.cpp",
85        "file.cpp",
86        "hex.cpp",
87        "logging.cpp",
88        "mapped_file.cpp",
89        "parsebool.cpp",
90        "parsenetaddress.cpp",
91        "posix_strerror_r.cpp",
92        "process.cpp",
93        "properties.cpp",
94        "stringprintf.cpp",
95        "strings.cpp",
96        "threads.cpp",
97        "test_utils.cpp",
98    ],
99
100    cppflags: ["-Wexit-time-destructors"],
101    shared_libs: ["liblog"],
102    target: {
103        android: {
104            sanitize: {
105                misc_undefined: ["integer"],
106            },
107
108        },
109        linux: {
110            srcs: [
111                "errors_unix.cpp",
112            ],
113        },
114        darwin: {
115            srcs: [
116                "errors_unix.cpp",
117            ],
118        },
119        linux_bionic: {
120            enabled: true,
121        },
122        windows: {
123            srcs: [
124                "errors_windows.cpp",
125                "utf8.cpp",
126            ],
127            exclude_srcs: [
128                "cmsg.cpp",
129            ],
130            enabled: true,
131        },
132    },
133    min_sdk_version: "29",
134}
135
136cc_library {
137    name: "libbase",
138    defaults: ["libbase_defaults"],
139    vendor_available: true,
140    product_available: true,
141    ramdisk_available: true,
142    vendor_ramdisk_available: true,
143    recovery_available: true,
144    host_supported: true,
145    native_bridge_supported: true,
146    vndk: {
147        enabled: true,
148        support_system_process: true,
149    },
150    header_libs: [
151        "libbase_headers",
152    ],
153    export_header_lib_headers: ["libbase_headers"],
154    whole_static_libs: ["fmtlib"],
155    export_static_lib_headers: ["fmtlib"],
156    apex_available: [
157        "//apex_available:anyapex",
158        "//apex_available:platform",
159    ],
160}
161
162cc_library_static {
163    name: "libbase_ndk",
164    defaults: ["libbase_defaults"],
165    sdk_version: "current",
166    stl: "c++_static",
167    export_include_dirs: ["include"],
168    whole_static_libs: ["fmtlib_ndk"],
169}
170
171// Tests
172// ------------------------------------------------------------------------------
173cc_test {
174    name: "libbase_test",
175    defaults: ["libbase_cflags_defaults"],
176    host_supported: true,
177    require_root: true,
178    srcs: [
179        "cmsg_test.cpp",
180        "endian_test.cpp",
181        "errors_test.cpp",
182        "expected_test.cpp",
183        "file_test.cpp",
184        "function_ref_test.cpp",
185        "hex_test.cpp",
186        "logging_splitters_test.cpp",
187        "logging_test.cpp",
188        "macros_test.cpp",
189        "mapped_file_test.cpp",
190        "no_destructor_test.cpp",
191        "parsedouble_test.cpp",
192        "parsebool_test.cpp",
193        "parseint_test.cpp",
194        "parsenetaddress_test.cpp",
195        "process_test.cpp",
196        "properties_test.cpp",
197        "result_test.cpp",
198        "scopeguard_test.cpp",
199        "stringprintf_test.cpp",
200        "strings_test.cpp",
201        "test_main.cpp",
202        "test_utils_test.cpp",
203    ],
204    target: {
205        android: {
206            sanitize: {
207                misc_undefined: ["integer"],
208            },
209        },
210        linux: {
211            srcs: ["chrono_utils_test.cpp"],
212        },
213        windows: {
214            srcs: ["utf8_test.cpp"],
215            cflags: ["-Wno-unused-parameter"],
216            enabled: true,
217        },
218    },
219    local_include_dirs: ["."],
220    shared_libs: ["libbase"],
221    static_libs: ["libgmock"],
222    compile_multilib: "both",
223    multilib: {
224        lib32: {
225            suffix: "32",
226        },
227        lib64: {
228            suffix: "64",
229        },
230    },
231    test_suites: ["device-tests"],
232}
233
234cc_test {
235    name: "libbase_tidy_test",
236    defaults: ["libbase_cflags_defaults"],
237    host_supported: true,
238
239    tidy: true,
240    tidy_checks_as_errors: ["bugprone-use-after-move"],
241
242    srcs: [
243        "tidy/unique_fd_test.cpp",
244        "tidy/unique_fd_test2.cpp",
245    ],
246
247    shared_libs: ["libbase"],
248    test_suites: ["device_tests"],
249}
250
251// Can be removed when we move to c++20
252cc_test {
253    name: "libbase_result_constraint_test",
254    defaults: ["libbase_cflags_defaults"],
255    host_supported: true,
256    srcs: [
257        "result_test_constraint.cpp",
258    ],
259    target: {
260        android: {
261            sanitize: {
262                misc_undefined: ["integer"],
263            },
264        },
265    },
266    cpp_std: "gnu++20",
267    local_include_dirs: ["."],
268    shared_libs: ["libbase"],
269    static_libs: ["libgmock"],
270    compile_multilib: "both",
271    multilib: {
272        lib32: {
273            suffix: "32",
274        },
275        lib64: {
276            suffix: "64",
277        },
278    },
279    test_suites: ["device-tests"],
280}
281
282cc_benchmark {
283    name: "libbase_benchmark",
284    defaults: ["libbase_cflags_defaults"],
285
286    srcs: [
287        "file_benchmark.cpp",
288        "format_benchmark.cpp",
289        "function_ref_benchmark.cpp",
290    ],
291    shared_libs: ["libbase"],
292
293    compile_multilib: "both",
294    multilib: {
295        lib32: {
296            suffix: "32",
297        },
298        lib64: {
299            suffix: "64",
300        },
301    },
302}
303
304cc_fuzz {
305    name: "libbase_parsenetaddress_fuzzer",
306    shared_libs: ["libbase"],
307    host_supported: true,
308    srcs: ["parsenetaddress_fuzzer.cpp"],
309    dictionary: "parsenetaddress_fuzzer.dict",
310
311    fuzz_config: {
312        cc: [
313            "android-bionic@google.com",
314        ],
315        componentid: 128577
316    }
317}
318