Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 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 | |
Bob Badour | c7b498f | 2021-02-03 19:53:26 -0800 | [diff] [blame] | 16 | package { |
| 17 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 18 | } |
| 19 | |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 20 | cc_defaults { |
| 21 | name: "libziparchive_flags", |
Yurii Zubrytskyi | 3c793c4 | 2021-02-22 16:22:01 -0800 | [diff] [blame] | 22 | cpp_std: "c++2a", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 23 | cflags: [ |
| 24 | // ZLIB_CONST turns on const for input buffers, which is pretty standard. |
| 25 | "-DZLIB_CONST", |
| 26 | "-Werror", |
| 27 | "-Wall", |
Christian Poetzsch | 935432d | 2016-12-20 16:13:41 +0000 | [diff] [blame] | 28 | "-D_FILE_OFFSET_BITS=64", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 29 | ], |
| 30 | cppflags: [ |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 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", |
Andreas Gampe | 5a5ffb5 | 2019-04-05 13:48:02 -0700 | [diff] [blame] | 34 | "-Wconversion", |
| 35 | "-Wno-sign-conversion", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 36 | ], |
Pirama Arumuga Nainar | 3680cce | 2018-09-18 14:58:17 -0700 | [diff] [blame] | 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 | }, |
Nick Kralevich | 5ca6bec | 2019-03-20 13:04:02 -0700 | [diff] [blame] | 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 | }, |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | cc_defaults { |
| 64 | name: "libziparchive_defaults", |
Yurii Zubrytskyi | 3c793c4 | 2021-02-22 16:22:01 -0800 | [diff] [blame] | 65 | local_include_dirs: ["incfs_support/include/"], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 66 | srcs: [ |
| 67 | "zip_archive.cc", |
| 68 | "zip_archive_stream_entry.cc", |
Tianjie Xu | 91caafe | 2020-03-13 16:16:24 -0700 | [diff] [blame] | 69 | "zip_cd_entry_map.cc", |
Elliott Hughes | 8cdfb16 | 2020-03-17 14:10:59 -0700 | [diff] [blame] | 70 | "zip_error.cpp", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 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 | ], |
Andreas Gampe | a54290a | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 86 | |
Donald Chai | 322a60b | 2019-07-02 17:25:03 -0700 | [diff] [blame] | 87 | // for FRIEND_TEST |
Elliott Hughes | 03abb6e | 2021-04-20 15:28:22 -0700 | [diff] [blame] | 88 | header_libs: ["libgtest_prod_headers"], |
| 89 | export_header_lib_headers: ["libgtest_prod_headers"], |
Donald Chai | 322a60b | 2019-07-02 17:25:03 -0700 | [diff] [blame] | 90 | |
Andreas Gampe | a54290a | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 91 | export_include_dirs: ["include"], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Yurii Zubrytskyi | 3c793c4 | 2021-02-22 16:22:01 -0800 | [diff] [blame] | 94 | cc_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 | |
| 115 | cc_defaults { |
| 116 | name: "libziparchive_lib_defaults", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 117 | host_supported: true, |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 118 | vendor_available: true, |
Justin Yun | e12cb49 | 2020-11-11 19:25:27 +0900 | [diff] [blame] | 119 | product_available: true, |
Jiyong Park | 77d95a8 | 2018-05-29 16:41:30 +0900 | [diff] [blame] | 120 | recovery_available: true, |
Yifan Hong | 7107553 | 2020-10-27 16:46:33 -0700 | [diff] [blame] | 121 | vendor_ramdisk_available: true, |
dimitry | f0ca118 | 2019-05-06 14:01:58 +0200 | [diff] [blame] | 122 | native_bridge_supported: true, |
Justin Yun | 6bade56 | 2017-08-03 15:51:33 +0900 | [diff] [blame] | 123 | vndk: { |
| 124 | enabled: true, |
| 125 | }, |
Jiyong Park | 9ad9bf1 | 2018-04-09 12:20:48 +0900 | [diff] [blame] | 126 | double_loadable: true, |
Elliott Hughes | 4db8b38 | 2018-10-26 10:34:53 -0700 | [diff] [blame] | 127 | export_shared_lib_headers: ["libbase"], |
Jayant Chowdhary | 80476bd | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 128 | |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 129 | defaults: [ |
| 130 | "libziparchive_defaults", |
| 131 | "libziparchive_flags", |
| 132 | ], |
| 133 | shared_libs: [ |
| 134 | "liblog", |
| 135 | "libbase", |
Dan Willemsen | d13406c | 2017-09-27 16:24:45 -0700 | [diff] [blame] | 136 | "libz", |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 137 | ], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 138 | target: { |
Dan Willemsen | 152215c | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 139 | linux_bionic: { |
Dan Willemsen | 152215c | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 140 | enabled: true, |
| 141 | }, |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 142 | }, |
Jiyong Park | 3cbe557 | 2020-05-25 20:57:43 +0900 | [diff] [blame] | 143 | |
| 144 | apex_available: [ |
| 145 | "//apex_available:platform", |
Martin Stjernholm | 394a24d | 2020-10-12 15:11:16 +0100 | [diff] [blame] | 146 | "com.android.art", |
Jiyong Park | 3cbe557 | 2020-05-25 20:57:43 +0900 | [diff] [blame] | 147 | "com.android.art.debug", |
Jiyong Park | 07fc7e6 | 2021-01-05 14:46:31 +0900 | [diff] [blame] | 148 | "com.android.virt", |
Jiyong Park | 3cbe557 | 2020-05-25 20:57:43 +0900 | [diff] [blame] | 149 | ], |
Nicolas Geoffray | c7d36d0 | 2021-03-03 21:53:19 +0000 | [diff] [blame] | 150 | min_sdk_version: "apex_inherit", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Yurii Zubrytskyi | 3c793c4 | 2021-02-22 16:22:01 -0800 | [diff] [blame] | 153 | cc_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 | |
| 162 | cc_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 | |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 170 | // Tests. |
| 171 | cc_test { |
| 172 | name: "ziparchive-tests", |
| 173 | host_supported: true, |
| 174 | defaults: ["libziparchive_flags"], |
| 175 | |
Elliott Hughes | 2ddb3ae | 2018-04-25 12:49:19 -0700 | [diff] [blame] | 176 | data: [ |
| 177 | "testdata/**/*", |
| 178 | ], |
| 179 | |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 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 | }, |
Elliott Hughes | 0a60efe | 2018-10-29 12:29:34 -0700 | [diff] [blame] | 204 | test_suites: ["device-tests"], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 205 | } |
Sebastian Pop | 7a4752d | 2017-05-30 09:14:20 -0500 | [diff] [blame] | 206 | |
| 207 | // Performance benchmarks. |
| 208 | cc_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 | } |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 232 | |
| 233 | cc_binary { |
Elliott Hughes | dcd3f92 | 2019-10-25 09:57:58 -0700 | [diff] [blame] | 234 | name: "ziptool", |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 235 | defaults: ["libziparchive_flags"], |
Elliott Hughes | 224c21d | 2019-12-13 16:45:55 -0800 | [diff] [blame] | 236 | srcs: ["ziptool.cpp"], |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 237 | shared_libs: [ |
| 238 | "libbase", |
| 239 | "libziparchive", |
Elliott Hughes | b75c9f3 | 2020-09-25 13:30:37 -0700 | [diff] [blame] | 240 | "libz", |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 241 | ], |
Elliott Hughes | 8fe93d1 | 2018-09-04 13:33:30 -0700 | [diff] [blame] | 242 | recovery_available: true, |
Elliott Hughes | dcd3f92 | 2019-10-25 09:57:58 -0700 | [diff] [blame] | 243 | host_supported: true, |
| 244 | target: { |
| 245 | android: { |
| 246 | symlinks: ["unzip", "zipinfo"], |
| 247 | }, |
| 248 | }, |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 249 | } |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 250 | |
| 251 | cc_fuzz { |
| 252 | name: "libziparchive_fuzzer", |
| 253 | srcs: ["libziparchive_fuzzer.cpp"], |
Yurii Zubrytskyi | 3c793c4 | 2021-02-22 16:22:01 -0800 | [diff] [blame] | 254 | static_libs: [ |
| 255 | "libziparchive", |
| 256 | "libbase", |
| 257 | "libz", |
| 258 | "liblog" |
| 259 | ], |
| 260 | host_supported: true, |
| 261 | corpus: ["testdata/*"], |
| 262 | } |
| 263 | |
| 264 | cc_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 | ], |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 273 | host_supported: true, |
Elliott Hughes | d95e8dd | 2019-11-07 14:24:04 -0800 | [diff] [blame] | 274 | corpus: ["testdata/*"], |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 275 | } |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 276 | |
Huizi Yang | b3c85b6 | 2021-03-15 15:47:48 -0700 | [diff] [blame] | 277 | cc_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 | |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 285 | sh_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, |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 292 | data: ["cli-tests/**/*"], |
| 293 | target_required: ["cli-test", "ziptool"], |
Frank Feng | 49f0189 | 2020-10-12 23:06:31 +0000 | [diff] [blame] | 294 | data_device_bins: ["cli-test"], |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 295 | } |
Tianjie | 439a46f | 2020-03-18 17:44:30 -0700 | [diff] [blame] | 296 | |
| 297 | python_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"], |
Julien Desprez | 6e2b2b9 | 2021-04-02 01:52:34 +0000 | [diff] [blame] | 312 | test_options: { |
| 313 | unit_test: false, |
| 314 | }, |
Tianjie | 439a46f | 2020-03-18 17:44:30 -0700 | [diff] [blame] | 315 | } |