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_team: "trendy_team_native_tools_libraries", 18 default_applicable_licenses: ["Android-Apache-2.0"], 19} 20 21cc_defaults { 22 name: "libziparchive_flags", 23 cpp_std: "c++2a", 24 cflags: [ 25 // ZLIB_CONST turns on const for input buffers, which is pretty standard. 26 "-DZLIB_CONST", 27 "-Werror", 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 double_loadable: true, 124 export_shared_lib_headers: ["libbase"], 125 126 defaults: [ 127 "libziparchive_defaults", 128 "libziparchive_flags", 129 ], 130 shared_libs: [ 131 "liblog", 132 "libbase", 133 "libz", 134 ], 135 target: { 136 linux_bionic: { 137 enabled: true, 138 }, 139 }, 140 141 apex_available: [ 142 "//apex_available:platform", 143 "com.android.art", 144 "com.android.art.debug", 145 "com.android.virt", 146 ], 147 min_sdk_version: "apex_inherit", 148} 149 150cc_library { 151 name: "libziparchive", 152 defaults: ["libziparchive_lib_defaults"], 153 cflags: [ 154 // Disable incfs hardending code for the default library 155 "-DINCFS_SUPPORT_DISABLED=1", 156 ], 157 apex_available: ["com.android.runtime"], 158} 159 160cc_library_static { 161 name: "libziparchive_for_incfs", 162 defaults: [ 163 "libziparchive_lib_defaults", 164 "incfs_support_defaults", 165 ], 166 srcs: [ 167 "incfs_support/signal_handling.cpp", 168 ], 169} 170 171// Tests. 172cc_test { 173 name: "ziparchive-tests", 174 host_supported: true, 175 defaults: ["libziparchive_flags"], 176 177 data: [ 178 "testdata/**/*", 179 ], 180 181 srcs: [ 182 "entry_name_utils_test.cc", 183 "zip_archive_test.cc", 184 "zip_writer_test.cc", 185 ], 186 shared_libs: [ 187 "libbase", 188 "liblog", 189 ], 190 191 static_libs: [ 192 "libziparchive", 193 "libz", 194 "libutils", 195 ], 196 197 target: { 198 host: { 199 cppflags: ["-Wno-unnamed-type-template-args"], 200 }, 201 windows: { 202 enabled: true, 203 }, 204 }, 205 test_suites: ["device-tests"], 206} 207 208// Performance benchmarks. 209cc_benchmark { 210 name: "ziparchive-benchmarks", 211 defaults: ["libziparchive_flags"], 212 213 srcs: [ 214 "zip_archive_benchmark.cpp", 215 ], 216 shared_libs: [ 217 "libbase", 218 "liblog", 219 ], 220 221 static_libs: [ 222 "libziparchive", 223 "libz", 224 "libutils", 225 ], 226 227 target: { 228 host: { 229 cppflags: ["-Wno-unnamed-type-template-args"], 230 }, 231 }, 232} 233 234cc_defaults { 235 name: "ziptool_defaults", 236 defaults: ["libziparchive_flags"], 237 srcs: ["ziptool.cpp"], 238 shared_libs: [ 239 "libbase", 240 "libziparchive", 241 "libz", 242 ], 243 target: { 244 android: { 245 symlinks: [ 246 "unzip", 247 "zipinfo", 248 ], 249 }, 250 }, 251} 252 253cc_binary { 254 name: "ziptool", 255 defaults: ["ziptool_defaults"], 256 host_supported: true, 257} 258 259cc_binary { 260 name: "ziptool.recovery", 261 defaults: ["ziptool_defaults"], 262 recovery: true, 263 stem: "ziptool", 264} 265 266cc_fuzz { 267 name: "libziparchive_fuzzer", 268 srcs: ["libziparchive_fuzzer.cpp"], 269 static_libs: [ 270 "libziparchive", 271 "libbase", 272 "libz", 273 "liblog", 274 ], 275 host_supported: true, 276 corpus: ["testdata/*"], 277} 278 279cc_fuzz { 280 name: "libziparchive_for_incfs_fuzzer", 281 srcs: ["libziparchive_fuzzer.cpp"], 282 static_libs: [ 283 "libziparchive_for_incfs", 284 "libbase", 285 "libz", 286 "liblog", 287 ], 288 host_supported: true, 289 corpus: ["testdata/*"], 290} 291 292cc_fuzz { 293 name: "libziparchive_writer_fuzzer", 294 srcs: ["libziparchive_writer_fuzzer.cpp"], 295 static_libs: [ 296 "libziparchive", 297 "libbase", 298 "libz", 299 "liblog", 300 ], 301 host_supported: true, 302 corpus: ["testdata/*"], 303} 304 305sh_test { 306 name: "ziptool-tests", 307 src: "run-ziptool-tests-on-android.sh", 308 filename: "run-ziptool-tests-on-android.sh", 309 test_suites: ["general-tests"], 310 host_supported: true, 311 device_supported: false, 312 data: ["cli-tests/**/*"], 313 target_required: [ 314 "cli-test", 315 "ziptool", 316 ], 317 data_device_bins: ["cli-test"], 318} 319 320python_test_host { 321 name: "ziparchive_tests_large", 322 srcs: ["test_ziparchive_large.py"], 323 main: "test_ziparchive_large.py", 324 test_suites: ["general-tests"], 325 test_options: { 326 unit_test: false, 327 }, 328} 329