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 | |
| 16 | cc_defaults { |
| 17 | name: "libziparchive_flags", |
| 18 | cflags: [ |
| 19 | // ZLIB_CONST turns on const for input buffers, which is pretty standard. |
| 20 | "-DZLIB_CONST", |
| 21 | "-Werror", |
| 22 | "-Wall", |
Christian Poetzsch | 935432d | 2016-12-20 16:13:41 +0000 | [diff] [blame] | 23 | "-D_FILE_OFFSET_BITS=64", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 24 | ], |
| 25 | cppflags: [ |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 26 | // Incorrectly warns when C++11 empty brace {} initializer is used. |
| 27 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489 |
| 28 | "-Wno-missing-field-initializers", |
Andreas Gampe | 5a5ffb5 | 2019-04-05 13:48:02 -0700 | [diff] [blame] | 29 | "-Wconversion", |
| 30 | "-Wno-sign-conversion", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 31 | ], |
Pirama Arumuga Nainar | 3680cce | 2018-09-18 14:58:17 -0700 | [diff] [blame] | 32 | |
| 33 | // Enable -Wold-style-cast only for non-Windows targets. _islower_l, |
| 34 | // _isupper_l etc. in MinGW locale_win32.h (included from |
| 35 | // libcxx/include/__locale) has an old-style-cast. |
| 36 | target: { |
| 37 | not_windows: { |
| 38 | cppflags: [ |
| 39 | "-Wold-style-cast", |
| 40 | ], |
| 41 | }, |
| 42 | }, |
Nick Kralevich | 5ca6bec | 2019-03-20 13:04:02 -0700 | [diff] [blame] | 43 | sanitize: { |
| 44 | misc_undefined: [ |
| 45 | "signed-integer-overflow", |
| 46 | "unsigned-integer-overflow", |
| 47 | "shift", |
| 48 | "integer-divide-by-zero", |
| 49 | "implicit-signed-integer-truncation", |
| 50 | // TODO: Fix crash when we enable this option |
| 51 | // "implicit-unsigned-integer-truncation", |
| 52 | // TODO: not tested yet. |
| 53 | // "implicit-integer-sign-change", |
| 54 | ], |
| 55 | }, |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | cc_defaults { |
| 59 | name: "libziparchive_defaults", |
| 60 | srcs: [ |
| 61 | "zip_archive.cc", |
| 62 | "zip_archive_stream_entry.cc", |
Tianjie Xu | 91caafe | 2020-03-13 16:16:24 -0700 | [diff] [blame] | 63 | "zip_cd_entry_map.cc", |
Elliott Hughes | 8cdfb16 | 2020-03-17 14:10:59 -0700 | [diff] [blame] | 64 | "zip_error.cpp", |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 65 | "zip_writer.cc", |
| 66 | ], |
| 67 | |
| 68 | target: { |
| 69 | windows: { |
| 70 | cflags: ["-mno-ms-bitfields"], |
| 71 | |
| 72 | enabled: true, |
| 73 | }, |
| 74 | }, |
| 75 | |
| 76 | shared_libs: [ |
| 77 | "libbase", |
| 78 | "liblog", |
| 79 | ], |
Andreas Gampe | a54290a | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 80 | |
Donald Chai | 322a60b | 2019-07-02 17:25:03 -0700 | [diff] [blame] | 81 | // for FRIEND_TEST |
| 82 | static_libs: ["libgtest_prod"], |
| 83 | export_static_lib_headers: ["libgtest_prod"], |
| 84 | |
Andreas Gampe | a54290a | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 85 | export_include_dirs: ["include"], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 88 | cc_library { |
| 89 | name: "libziparchive", |
| 90 | host_supported: true, |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 91 | vendor_available: true, |
Justin Yun | e12cb49 | 2020-11-11 19:25:27 +0900 | [diff] [blame] | 92 | product_available: true, |
Jiyong Park | 77d95a8 | 2018-05-29 16:41:30 +0900 | [diff] [blame] | 93 | recovery_available: true, |
Yifan Hong | 7107553 | 2020-10-27 16:46:33 -0700 | [diff] [blame] | 94 | vendor_ramdisk_available: true, |
dimitry | f0ca118 | 2019-05-06 14:01:58 +0200 | [diff] [blame] | 95 | native_bridge_supported: true, |
Justin Yun | 6bade56 | 2017-08-03 15:51:33 +0900 | [diff] [blame] | 96 | vndk: { |
| 97 | enabled: true, |
| 98 | }, |
Jiyong Park | 9ad9bf1 | 2018-04-09 12:20:48 +0900 | [diff] [blame] | 99 | double_loadable: true, |
Elliott Hughes | 4db8b38 | 2018-10-26 10:34:53 -0700 | [diff] [blame] | 100 | export_shared_lib_headers: ["libbase"], |
Jayant Chowdhary | 80476bd | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 101 | |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 102 | defaults: [ |
| 103 | "libziparchive_defaults", |
| 104 | "libziparchive_flags", |
| 105 | ], |
| 106 | shared_libs: [ |
| 107 | "liblog", |
| 108 | "libbase", |
Dan Willemsen | d13406c | 2017-09-27 16:24:45 -0700 | [diff] [blame] | 109 | "libz", |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 110 | ], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 111 | target: { |
Dan Willemsen | 152215c | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 112 | linux_bionic: { |
Dan Willemsen | 152215c | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 113 | enabled: true, |
| 114 | }, |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 115 | }, |
Jiyong Park | 3cbe557 | 2020-05-25 20:57:43 +0900 | [diff] [blame] | 116 | |
| 117 | apex_available: [ |
| 118 | "//apex_available:platform", |
Martin Stjernholm | 394a24d | 2020-10-12 15:11:16 +0100 | [diff] [blame] | 119 | "com.android.art", |
Jiyong Park | 3cbe557 | 2020-05-25 20:57:43 +0900 | [diff] [blame] | 120 | "com.android.art.debug", |
Jiyong Park | 07fc7e6 | 2021-01-05 14:46:31 +0900 | [diff] [blame^] | 121 | "com.android.virt", |
Jiyong Park | 3cbe557 | 2020-05-25 20:57:43 +0900 | [diff] [blame] | 122 | ], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 125 | // Tests. |
| 126 | cc_test { |
| 127 | name: "ziparchive-tests", |
| 128 | host_supported: true, |
| 129 | defaults: ["libziparchive_flags"], |
| 130 | |
Elliott Hughes | 2ddb3ae | 2018-04-25 12:49:19 -0700 | [diff] [blame] | 131 | data: [ |
| 132 | "testdata/**/*", |
| 133 | ], |
| 134 | |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 135 | srcs: [ |
| 136 | "entry_name_utils_test.cc", |
| 137 | "zip_archive_test.cc", |
| 138 | "zip_writer_test.cc", |
| 139 | ], |
| 140 | shared_libs: [ |
| 141 | "libbase", |
| 142 | "liblog", |
| 143 | ], |
| 144 | |
| 145 | static_libs: [ |
| 146 | "libziparchive", |
| 147 | "libz", |
| 148 | "libutils", |
| 149 | ], |
| 150 | |
| 151 | target: { |
| 152 | host: { |
| 153 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 154 | }, |
| 155 | windows: { |
| 156 | enabled: true, |
| 157 | }, |
| 158 | }, |
Elliott Hughes | 0a60efe | 2018-10-29 12:29:34 -0700 | [diff] [blame] | 159 | test_suites: ["device-tests"], |
Colin Cross | e802a31 | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 160 | } |
Sebastian Pop | 7a4752d | 2017-05-30 09:14:20 -0500 | [diff] [blame] | 161 | |
| 162 | // Performance benchmarks. |
| 163 | cc_benchmark { |
| 164 | name: "ziparchive-benchmarks", |
| 165 | defaults: ["libziparchive_flags"], |
| 166 | |
| 167 | srcs: [ |
| 168 | "zip_archive_benchmark.cpp", |
| 169 | ], |
| 170 | shared_libs: [ |
| 171 | "libbase", |
| 172 | "liblog", |
| 173 | ], |
| 174 | |
| 175 | static_libs: [ |
| 176 | "libziparchive", |
| 177 | "libz", |
| 178 | "libutils", |
| 179 | ], |
| 180 | |
| 181 | target: { |
| 182 | host: { |
| 183 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 184 | }, |
| 185 | }, |
| 186 | } |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 187 | |
| 188 | cc_binary { |
Elliott Hughes | dcd3f92 | 2019-10-25 09:57:58 -0700 | [diff] [blame] | 189 | name: "ziptool", |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 190 | defaults: ["libziparchive_flags"], |
Elliott Hughes | 224c21d | 2019-12-13 16:45:55 -0800 | [diff] [blame] | 191 | srcs: ["ziptool.cpp"], |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 192 | shared_libs: [ |
| 193 | "libbase", |
| 194 | "libziparchive", |
Elliott Hughes | b75c9f3 | 2020-09-25 13:30:37 -0700 | [diff] [blame] | 195 | "libz", |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 196 | ], |
Elliott Hughes | 8fe93d1 | 2018-09-04 13:33:30 -0700 | [diff] [blame] | 197 | recovery_available: true, |
Elliott Hughes | dcd3f92 | 2019-10-25 09:57:58 -0700 | [diff] [blame] | 198 | host_supported: true, |
| 199 | target: { |
| 200 | android: { |
| 201 | symlinks: ["unzip", "zipinfo"], |
| 202 | }, |
| 203 | }, |
Elliott Hughes | 6702cef | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 204 | } |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 205 | |
| 206 | cc_fuzz { |
| 207 | name: "libziparchive_fuzzer", |
| 208 | srcs: ["libziparchive_fuzzer.cpp"], |
| 209 | static_libs: ["libziparchive", "libbase", "libz", "liblog"], |
| 210 | host_supported: true, |
Elliott Hughes | d95e8dd | 2019-11-07 14:24:04 -0800 | [diff] [blame] | 211 | corpus: ["testdata/*"], |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 212 | } |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 213 | |
| 214 | sh_test { |
| 215 | name: "ziptool-tests", |
| 216 | src: "run-ziptool-tests-on-android.sh", |
| 217 | filename: "run-ziptool-tests-on-android.sh", |
| 218 | test_suites: ["general-tests"], |
| 219 | host_supported: true, |
| 220 | device_supported: false, |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 221 | data: ["cli-tests/**/*"], |
| 222 | target_required: ["cli-test", "ziptool"], |
Frank Feng | 49f0189 | 2020-10-12 23:06:31 +0000 | [diff] [blame] | 223 | data_device_bins: ["cli-test"], |
Elliott Hughes | 0072599 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 224 | } |
Tianjie | 439a46f | 2020-03-18 17:44:30 -0700 | [diff] [blame] | 225 | |
| 226 | python_test_host { |
| 227 | name: "ziparchive_tests_large", |
| 228 | srcs: ["test_ziparchive_large.py"], |
| 229 | main: "test_ziparchive_large.py", |
| 230 | version: { |
| 231 | py2: { |
| 232 | enabled: true, |
| 233 | embedded_launcher: false, |
| 234 | }, |
| 235 | py3: { |
| 236 | enabled: false, |
| 237 | embedded_launcher: false, |
| 238 | }, |
| 239 | }, |
| 240 | test_suites: ["general-tests"], |
| 241 | } |