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    target: {
61        linux_bionic: {
62            enabled: true,
63        },
64        windows: {
65            enabled: true,
66        },
67    },
68    apex_available: [
69        "//apex_available:anyapex",
70        "//apex_available:platform",
71    ],
72    min_sdk_version: "29",
73}
74
75cc_defaults {
76    name: "libbase_defaults",
77    defaults: ["libbase_cflags_defaults"],
78    srcs: [
79        "abi_compatibility.cpp",
80        "chrono_utils.cpp",
81        "cmsg.cpp",
82        "file.cpp",
83        "logging.cpp",
84        "mapped_file.cpp",
85        "parsebool.cpp",
86        "parsenetaddress.cpp",
87        "process.cpp",
88        "properties.cpp",
89        "stringprintf.cpp",
90        "strings.cpp",
91        "threads.cpp",
92        "test_utils.cpp",
93    ],
94
95    cppflags: ["-Wexit-time-destructors"],
96    shared_libs: ["liblog"],
97    target: {
98        android: {
99            sanitize: {
100                misc_undefined: ["integer"],
101            },
102
103        },
104        linux: {
105            srcs: [
106                "errors_unix.cpp",
107            ],
108        },
109        darwin: {
110            srcs: [
111                "errors_unix.cpp",
112            ],
113        },
114        linux_bionic: {
115            enabled: true,
116        },
117        windows: {
118            srcs: [
119                "errors_windows.cpp",
120                "utf8.cpp",
121            ],
122            exclude_srcs: [
123                "cmsg.cpp",
124            ],
125            enabled: true,
126        },
127    },
128    min_sdk_version: "29",
129}
130
131cc_library {
132    name: "libbase",
133    defaults: ["libbase_defaults"],
134    vendor_available: true,
135    product_available: true,
136    ramdisk_available: true,
137    vendor_ramdisk_available: true,
138    recovery_available: true,
139    host_supported: true,
140    native_bridge_supported: true,
141    vndk: {
142        enabled: true,
143        support_system_process: true,
144    },
145    header_libs: [
146        "libbase_headers",
147    ],
148    export_header_lib_headers: ["libbase_headers"],
149    static_libs: ["fmtlib"],
150    whole_static_libs: ["fmtlib"],
151    export_static_lib_headers: ["fmtlib"],
152    apex_available: [
153        "//apex_available:anyapex",
154        "//apex_available:platform",
155    ],
156}
157
158cc_library_static {
159    name: "libbase_ndk",
160    defaults: ["libbase_defaults"],
161    sdk_version: "current",
162    stl: "c++_static",
163    export_include_dirs: ["include"],
164    static_libs: ["fmtlib_ndk"],
165    whole_static_libs: ["fmtlib_ndk"],
166    export_static_lib_headers: ["fmtlib_ndk"],
167}
168
169// Tests
170// ------------------------------------------------------------------------------
171cc_test {
172    name: "libbase_test",
173    defaults: ["libbase_cflags_defaults"],
174    host_supported: true,
175    require_root: true,
176    srcs: [
177        "cmsg_test.cpp",
178        "endian_test.cpp",
179        "errors_test.cpp",
180        "expected_test.cpp",
181        "file_test.cpp",
182        "function_ref_test.cpp",
183        "logging_splitters_test.cpp",
184        "logging_test.cpp",
185        "macros_test.cpp",
186        "mapped_file_test.cpp",
187        "no_destructor_test.cpp",
188        "parsedouble_test.cpp",
189        "parsebool_test.cpp",
190        "parseint_test.cpp",
191        "parsenetaddress_test.cpp",
192        "process_test.cpp",
193        "properties_test.cpp",
194        "result_test.cpp",
195        "scopeguard_test.cpp",
196        "stringprintf_test.cpp",
197        "strings_test.cpp",
198        "test_main.cpp",
199        "test_utils_test.cpp",
200    ],
201    target: {
202        android: {
203            sanitize: {
204                misc_undefined: ["integer"],
205            },
206        },
207        linux: {
208            srcs: ["chrono_utils_test.cpp"],
209        },
210        windows: {
211            srcs: ["utf8_test.cpp"],
212            cflags: ["-Wno-unused-parameter"],
213            enabled: true,
214        },
215    },
216    local_include_dirs: ["."],
217    shared_libs: ["libbase"],
218    compile_multilib: "both",
219    multilib: {
220        lib32: {
221            suffix: "32",
222        },
223        lib64: {
224            suffix: "64",
225        },
226    },
227    test_suites: ["device-tests"],
228}
229
230cc_test {
231    name: "libbase_tidy_test",
232    defaults: ["libbase_cflags_defaults"],
233    host_supported: true,
234
235    tidy: true,
236    tidy_checks_as_errors: ["bugprone-use-after-move"],
237
238    srcs: [
239        "tidy/unique_fd_test.cpp",
240        "tidy/unique_fd_test2.cpp",
241    ],
242
243    shared_libs: ["libbase"],
244    test_suites: ["device_tests"],
245}
246
247cc_benchmark {
248    name: "libbase_benchmark",
249    defaults: ["libbase_cflags_defaults"],
250
251    srcs: ["format_benchmark.cpp"],
252    shared_libs: ["libbase"],
253
254    compile_multilib: "both",
255    multilib: {
256        lib32: {
257            suffix: "32",
258        },
259        lib64: {
260            suffix: "64",
261        },
262    },
263}
264
265cc_fuzz {
266    name: "libbase_parsenetaddress_fuzzer",
267    shared_libs: ["libbase"],
268    host_supported: true,
269    srcs: ["parsenetaddress_fuzzer.cpp"],
270    dictionary: "parsenetaddress_fuzzer.dict",
271
272    fuzz_config: {
273        cc: [
274            "android-bionic@google.com",
275        ],
276        componentid: 128577
277    }
278}
279