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 17cc_defaults { 18 name: "libbase_cflags_defaults", 19 cflags: [ 20 "-Wall", 21 "-Werror", 22 "-Wextra", 23 ], 24 target: { 25 android: { 26 cflags: [ 27 "-D_FILE_OFFSET_BITS=64", 28 ], 29 }, 30 }, 31} 32 33cc_library_headers { 34 name: "libbase_headers", 35 vendor_available: true, 36 ramdisk_available: true, 37 recovery_available: true, 38 host_supported: true, 39 native_bridge_supported: true, 40 export_include_dirs: ["include"], 41 42 target: { 43 linux_bionic: { 44 enabled: true, 45 }, 46 windows: { 47 enabled: true, 48 }, 49 }, 50 apex_available: [ 51 "//apex_available:anyapex", 52 "//apex_available:platform", 53 ], 54 min_sdk_version: "29", 55} 56 57cc_defaults { 58 name: "libbase_defaults", 59 defaults: ["libbase_cflags_defaults"], 60 srcs: [ 61 "abi_compatibility.cpp", 62 "chrono_utils.cpp", 63 "cmsg.cpp", 64 "file.cpp", 65 "liblog_symbols.cpp", 66 "logging.cpp", 67 "mapped_file.cpp", 68 "parsebool.cpp", 69 "parsenetaddress.cpp", 70 "process.cpp", 71 "properties.cpp", 72 "stringprintf.cpp", 73 "strings.cpp", 74 "threads.cpp", 75 "test_utils.cpp", 76 ], 77 78 cppflags: ["-Wexit-time-destructors"], 79 shared_libs: ["liblog"], 80 target: { 81 android: { 82 sanitize: { 83 misc_undefined: ["integer"], 84 }, 85 86 }, 87 linux: { 88 srcs: [ 89 "errors_unix.cpp", 90 ], 91 }, 92 darwin: { 93 srcs: [ 94 "errors_unix.cpp", 95 ], 96 }, 97 linux_bionic: { 98 enabled: true, 99 }, 100 windows: { 101 srcs: [ 102 "errors_windows.cpp", 103 "utf8.cpp", 104 ], 105 exclude_srcs: [ 106 "cmsg.cpp", 107 ], 108 enabled: true, 109 }, 110 }, 111} 112 113cc_library { 114 name: "libbase", 115 defaults: ["libbase_defaults"], 116 vendor_available: true, 117 ramdisk_available: true, 118 recovery_available: true, 119 host_supported: true, 120 native_bridge_supported: true, 121 vndk: { 122 enabled: true, 123 support_system_process: true, 124 }, 125 header_libs: [ 126 "libbase_headers", 127 ], 128 export_header_lib_headers: ["libbase_headers"], 129 static_libs: ["fmtlib"], 130 whole_static_libs: ["fmtlib"], 131 export_static_lib_headers: ["fmtlib"], 132 apex_available: [ 133 "//apex_available:anyapex", 134 "//apex_available:platform", 135 ], 136 min_sdk_version: "29", 137} 138 139cc_library_static { 140 name: "libbase_ndk", 141 defaults: ["libbase_defaults"], 142 sdk_version: "current", 143 stl: "c++_static", 144 export_include_dirs: ["include"], 145 static_libs: ["fmtlib_ndk"], 146 whole_static_libs: ["fmtlib_ndk"], 147 export_static_lib_headers: ["fmtlib_ndk"], 148} 149 150// Tests 151// ------------------------------------------------------------------------------ 152cc_test { 153 name: "libbase_test", 154 defaults: ["libbase_cflags_defaults"], 155 host_supported: true, 156 require_root: true, 157 srcs: [ 158 "cmsg_test.cpp", 159 "endian_test.cpp", 160 "errors_test.cpp", 161 "expected_test.cpp", 162 "file_test.cpp", 163 "logging_splitters_test.cpp", 164 "logging_test.cpp", 165 "macros_test.cpp", 166 "mapped_file_test.cpp", 167 "no_destructor_test.cpp", 168 "parsedouble_test.cpp", 169 "parsebool_test.cpp", 170 "parseint_test.cpp", 171 "parsenetaddress_test.cpp", 172 "process_test.cpp", 173 "properties_test.cpp", 174 "result_test.cpp", 175 "scopeguard_test.cpp", 176 "stringprintf_test.cpp", 177 "strings_test.cpp", 178 "test_main.cpp", 179 "test_utils_test.cpp", 180 ], 181 target: { 182 android: { 183 sanitize: { 184 misc_undefined: ["integer"], 185 }, 186 }, 187 linux: { 188 srcs: ["chrono_utils_test.cpp"], 189 }, 190 windows: { 191 srcs: ["utf8_test.cpp"], 192 cflags: ["-Wno-unused-parameter"], 193 enabled: true, 194 }, 195 }, 196 local_include_dirs: ["."], 197 shared_libs: ["libbase"], 198 compile_multilib: "both", 199 multilib: { 200 lib32: { 201 suffix: "32", 202 }, 203 lib64: { 204 suffix: "64", 205 }, 206 }, 207 test_suites: ["device-tests"], 208} 209 210cc_test { 211 name: "libbase_tidy_test", 212 defaults: ["libbase_cflags_defaults"], 213 host_supported: true, 214 215 tidy: true, 216 tidy_checks_as_errors: ["bugprone-use-after-move"], 217 218 srcs: [ 219 "tidy/unique_fd_test.cpp", 220 "tidy/unique_fd_test2.cpp", 221 ], 222 223 shared_libs: ["libbase"], 224 test_suites: ["device_tests"], 225} 226 227cc_benchmark { 228 name: "libbase_benchmark", 229 defaults: ["libbase_cflags_defaults"], 230 231 srcs: ["format_benchmark.cpp"], 232 shared_libs: ["libbase"], 233 234 compile_multilib: "both", 235 multilib: { 236 lib32: { 237 suffix: "32", 238 }, 239 lib64: { 240 suffix: "64", 241 }, 242 }, 243} 244