1// 2// Copyright (C) 2013 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 16package { 17 default_applicable_licenses: ["Android-Apache-2.0"], 18} 19 20cc_defaults { 21 name: "libziparchive_flags", 22 cpp_std: "c++2a", 23 cflags: [ 24 // ZLIB_CONST turns on const for input buffers, which is pretty standard. 25 "-DZLIB_CONST", 26 "-Werror", 27 "-Wall", 28 "-D_FILE_OFFSET_BITS=64", 29 ], 30 cppflags: [ 31 // Incorrectly warns when C++11 empty brace {} initializer is used. 32 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489 33 "-Wno-missing-field-initializers", 34 "-Wconversion", 35 "-Wno-sign-conversion", 36 ], 37 38 // Enable -Wold-style-cast only for non-Windows targets. _islower_l, 39 // _isupper_l etc. in MinGW locale_win32.h (included from 40 // libcxx/include/__locale) has an old-style-cast. 41 target: { 42 not_windows: { 43 cppflags: [ 44 "-Wold-style-cast", 45 ], 46 }, 47 }, 48 sanitize: { 49 misc_undefined: [ 50 "signed-integer-overflow", 51 "unsigned-integer-overflow", 52 "shift", 53 "integer-divide-by-zero", 54 "implicit-signed-integer-truncation", 55 // TODO: Fix crash when we enable this option 56 // "implicit-unsigned-integer-truncation", 57 // TODO: not tested yet. 58 // "implicit-integer-sign-change", 59 ], 60 }, 61} 62 63cc_defaults { 64 name: "libziparchive_defaults", 65 local_include_dirs: ["incfs_support/include/"], 66 srcs: [ 67 "zip_archive.cc", 68 "zip_archive_stream_entry.cc", 69 "zip_cd_entry_map.cc", 70 "zip_error.cpp", 71 "zip_writer.cc", 72 ], 73 74 target: { 75 windows: { 76 cflags: ["-mno-ms-bitfields"], 77 78 enabled: true, 79 }, 80 }, 81 82 shared_libs: [ 83 "libbase", 84 "liblog", 85 ], 86 87 // for FRIEND_TEST 88 header_libs: ["libgtest_prod_headers"], 89 export_header_lib_headers: ["libgtest_prod_headers"], 90 91 export_include_dirs: ["include"], 92} 93 94cc_defaults { 95 name: "incfs_support_defaults", 96 cflags: ["-DZIPARCHIVE_DISABLE_CALLBACK_API=1"], 97 export_include_dirs: ["incfs_support/include/"], 98 tidy: true, 99 tidy_checks: [ 100 "android-*", 101 "cert-*", 102 "clang-analyzer-security*", 103 "-cert-err34-c", 104 "clang-analyzer-security*", 105 // Disabling due to many unavoidable warnings from POSIX API usage. 106 "-google-runtime-int", 107 "-google-explicit-constructor", 108 // do not call 'longjmp'; consider using exception handling instead - library relies on it 109 "-cert-err52-cpp", 110 // typedef pointer used with const: all Zip* typedefs generate this when declared as const 111 "-misc-misplaced-const", 112 ], 113} 114 115cc_defaults { 116 name: "libziparchive_lib_defaults", 117 host_supported: true, 118 vendor_available: true, 119 product_available: true, 120 recovery_available: true, 121 vendor_ramdisk_available: true, 122 native_bridge_supported: true, 123 vndk: { 124 enabled: true, 125 }, 126 double_loadable: true, 127 export_shared_lib_headers: ["libbase"], 128 129 defaults: [ 130 "libziparchive_defaults", 131 "libziparchive_flags", 132 ], 133 shared_libs: [ 134 "liblog", 135 "libbase", 136 "libz", 137 ], 138 target: { 139 linux_bionic: { 140 enabled: true, 141 }, 142 }, 143 144 apex_available: [ 145 "//apex_available:platform", 146 "com.android.art", 147 "com.android.art.debug", 148 "com.android.virt", 149 ], 150 min_sdk_version: "apex_inherit", 151} 152 153cc_library { 154 name: "libziparchive", 155 defaults: ["libziparchive_lib_defaults"], 156 cflags: [ 157 // Disable incfs hardending code for the default library 158 "-DINCFS_SUPPORT_DISABLED=1", 159 ], 160} 161 162cc_library_static { 163 name: "libziparchive_for_incfs", 164 defaults: ["libziparchive_lib_defaults", "incfs_support_defaults"], 165 srcs: [ 166 "incfs_support/signal_handling.cpp", 167 ], 168} 169 170// Tests. 171cc_test { 172 name: "ziparchive-tests", 173 host_supported: true, 174 defaults: ["libziparchive_flags"], 175 176 data: [ 177 "testdata/**/*", 178 ], 179 180 srcs: [ 181 "entry_name_utils_test.cc", 182 "zip_archive_test.cc", 183 "zip_writer_test.cc", 184 ], 185 shared_libs: [ 186 "libbase", 187 "liblog", 188 ], 189 190 static_libs: [ 191 "libziparchive", 192 "libz", 193 "libutils", 194 ], 195 196 target: { 197 host: { 198 cppflags: ["-Wno-unnamed-type-template-args"], 199 }, 200 windows: { 201 enabled: true, 202 }, 203 }, 204 test_suites: ["device-tests"], 205} 206 207// Performance benchmarks. 208cc_benchmark { 209 name: "ziparchive-benchmarks", 210 defaults: ["libziparchive_flags"], 211 212 srcs: [ 213 "zip_archive_benchmark.cpp", 214 ], 215 shared_libs: [ 216 "libbase", 217 "liblog", 218 ], 219 220 static_libs: [ 221 "libziparchive", 222 "libz", 223 "libutils", 224 ], 225 226 target: { 227 host: { 228 cppflags: ["-Wno-unnamed-type-template-args"], 229 }, 230 }, 231} 232 233cc_binary { 234 name: "ziptool", 235 defaults: ["libziparchive_flags"], 236 srcs: ["ziptool.cpp"], 237 shared_libs: [ 238 "libbase", 239 "libziparchive", 240 "libz", 241 ], 242 recovery_available: true, 243 host_supported: true, 244 target: { 245 android: { 246 symlinks: ["unzip", "zipinfo"], 247 }, 248 }, 249} 250 251cc_fuzz { 252 name: "libziparchive_fuzzer", 253 srcs: ["libziparchive_fuzzer.cpp"], 254 static_libs: [ 255 "libziparchive", 256 "libbase", 257 "libz", 258 "liblog" 259 ], 260 host_supported: true, 261 corpus: ["testdata/*"], 262} 263 264cc_fuzz { 265 name: "libziparchive_for_incfs_fuzzer", 266 srcs: ["libziparchive_fuzzer.cpp"], 267 static_libs: [ 268 "libziparchive_for_incfs", 269 "libbase", 270 "libz", 271 "liblog" 272 ], 273 host_supported: true, 274 corpus: ["testdata/*"], 275} 276 277cc_fuzz { 278 name: "libziparchive_writer_fuzzer", 279 srcs: ["libziparchive_writer_fuzzer.cpp"], 280 static_libs: ["libziparchive", "libbase", "libz", "liblog"], 281 host_supported: true, 282 corpus: ["testdata/*"], 283} 284 285sh_test { 286 name: "ziptool-tests", 287 src: "run-ziptool-tests-on-android.sh", 288 filename: "run-ziptool-tests-on-android.sh", 289 test_suites: ["general-tests"], 290 host_supported: true, 291 device_supported: false, 292 data: ["cli-tests/**/*"], 293 target_required: ["cli-test", "ziptool"], 294 data_device_bins: ["cli-test"], 295} 296 297python_test_host { 298 name: "ziparchive_tests_large", 299 srcs: ["test_ziparchive_large.py"], 300 main: "test_ziparchive_large.py", 301 version: { 302 py2: { 303 enabled: true, 304 embedded_launcher: false, 305 }, 306 py3: { 307 enabled: false, 308 embedded_launcher: false, 309 }, 310 }, 311 test_suites: ["general-tests"], 312 test_options: { 313 unit_test: false, 314 }, 315} 316