Colin Cross | 45566ba | 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 | 3081c5e | 2016-12-20 16:13:41 +0000 | [diff] [blame] | 23 | "-D_FILE_OFFSET_BITS=64", |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 24 | ], |
| 25 | cppflags: [ |
Colin Cross | 45566ba | 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 | 964b95c | 2019-04-05 13:48:02 -0700 | [diff] [blame] | 29 | "-Wconversion", |
| 30 | "-Wno-sign-conversion", |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 31 | ], |
Pirama Arumuga Nainar | 53f5945 | 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 | 30dec07 | 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 | 45566ba | 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 | 323c09c | 2020-03-13 16:16:24 -0700 | [diff] [blame] | 63 | "zip_cd_entry_map.cc", |
Elliott Hughes | bda2686 | 2020-03-17 14:10:59 -0700 | [diff] [blame] | 64 | "zip_error.cpp", |
Colin Cross | 45566ba | 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 | a10a7e7 | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 80 | |
Donald Chai | e170d7f | 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 | a10a7e7 | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 85 | export_include_dirs: ["include"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 88 | cc_library { |
| 89 | name: "libziparchive", |
| 90 | host_supported: true, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 91 | vendor_available: true, |
Jiyong Park | 011ee12 | 2018-05-29 16:41:30 +0900 | [diff] [blame] | 92 | recovery_available: true, |
dimitry | a808b11 | 2019-05-06 14:01:58 +0200 | [diff] [blame] | 93 | native_bridge_supported: true, |
Justin Yun | 096114d | 2017-08-03 15:51:33 +0900 | [diff] [blame] | 94 | vndk: { |
| 95 | enabled: true, |
| 96 | }, |
Jiyong Park | 9168787 | 2018-04-09 12:20:48 +0900 | [diff] [blame] | 97 | double_loadable: true, |
Elliott Hughes | a56a729 | 2018-10-26 10:34:53 -0700 | [diff] [blame] | 98 | export_shared_lib_headers: ["libbase"], |
Jayant Chowdhary | 2c87bcc | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 99 | |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 100 | defaults: [ |
| 101 | "libziparchive_defaults", |
| 102 | "libziparchive_flags", |
| 103 | ], |
| 104 | shared_libs: [ |
| 105 | "liblog", |
| 106 | "libbase", |
Dan Willemsen | 5cfa006 | 2017-09-27 16:24:45 -0700 | [diff] [blame] | 107 | "libz", |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 108 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 109 | target: { |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 110 | linux_bionic: { |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 111 | enabled: true, |
| 112 | }, |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 113 | }, |
Jiyong Park | 16a932a | 2020-04-28 18:22:23 +0900 | [diff] [blame] | 114 | |
| 115 | apex_available: [ |
| 116 | "//apex_available:platform", |
| 117 | "com.android.art.debug", |
| 118 | "com.android.art.release", |
| 119 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 122 | // Tests. |
| 123 | cc_test { |
| 124 | name: "ziparchive-tests", |
| 125 | host_supported: true, |
| 126 | defaults: ["libziparchive_flags"], |
| 127 | |
Elliott Hughes | bde0ec9 | 2018-04-25 12:49:19 -0700 | [diff] [blame] | 128 | data: [ |
| 129 | "testdata/**/*", |
| 130 | ], |
| 131 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 132 | srcs: [ |
| 133 | "entry_name_utils_test.cc", |
| 134 | "zip_archive_test.cc", |
| 135 | "zip_writer_test.cc", |
| 136 | ], |
| 137 | shared_libs: [ |
| 138 | "libbase", |
| 139 | "liblog", |
| 140 | ], |
| 141 | |
| 142 | static_libs: [ |
| 143 | "libziparchive", |
| 144 | "libz", |
| 145 | "libutils", |
| 146 | ], |
| 147 | |
| 148 | target: { |
| 149 | host: { |
| 150 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 151 | }, |
| 152 | windows: { |
| 153 | enabled: true, |
| 154 | }, |
| 155 | }, |
Elliott Hughes | e038f49 | 2018-10-29 12:29:34 -0700 | [diff] [blame] | 156 | test_suites: ["device-tests"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 157 | } |
Sebastian Pop | 0a94c56 | 2017-05-30 09:14:20 -0500 | [diff] [blame] | 158 | |
| 159 | // Performance benchmarks. |
| 160 | cc_benchmark { |
| 161 | name: "ziparchive-benchmarks", |
| 162 | defaults: ["libziparchive_flags"], |
| 163 | |
| 164 | srcs: [ |
| 165 | "zip_archive_benchmark.cpp", |
| 166 | ], |
| 167 | shared_libs: [ |
| 168 | "libbase", |
| 169 | "liblog", |
| 170 | ], |
| 171 | |
| 172 | static_libs: [ |
| 173 | "libziparchive", |
| 174 | "libz", |
| 175 | "libutils", |
| 176 | ], |
| 177 | |
| 178 | target: { |
| 179 | host: { |
| 180 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 181 | }, |
| 182 | }, |
| 183 | } |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 184 | |
| 185 | cc_binary { |
Elliott Hughes | 2672413 | 2019-10-25 09:57:58 -0700 | [diff] [blame] | 186 | name: "ziptool", |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 187 | defaults: ["libziparchive_flags"], |
Elliott Hughes | 8748bcc | 2019-12-13 16:45:55 -0800 | [diff] [blame] | 188 | srcs: ["ziptool.cpp"], |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 189 | shared_libs: [ |
| 190 | "libbase", |
| 191 | "libziparchive", |
| 192 | ], |
Elliott Hughes | ab08933 | 2018-09-04 13:33:30 -0700 | [diff] [blame] | 193 | recovery_available: true, |
Elliott Hughes | 2672413 | 2019-10-25 09:57:58 -0700 | [diff] [blame] | 194 | host_supported: true, |
| 195 | target: { |
| 196 | android: { |
| 197 | symlinks: ["unzip", "zipinfo"], |
| 198 | }, |
| 199 | }, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 200 | } |
Elliott Hughes | f66460b | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 201 | |
| 202 | cc_fuzz { |
| 203 | name: "libziparchive_fuzzer", |
| 204 | srcs: ["libziparchive_fuzzer.cpp"], |
| 205 | static_libs: ["libziparchive", "libbase", "libz", "liblog"], |
| 206 | host_supported: true, |
Elliott Hughes | 9e63ba7 | 2019-11-07 14:24:04 -0800 | [diff] [blame] | 207 | corpus: ["testdata/*"], |
Elliott Hughes | f66460b | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 208 | } |
Elliott Hughes | f276140 | 2019-11-15 15:07:00 -0800 | [diff] [blame] | 209 | |
| 210 | sh_test { |
| 211 | name: "ziptool-tests", |
| 212 | src: "run-ziptool-tests-on-android.sh", |
| 213 | filename: "run-ziptool-tests-on-android.sh", |
| 214 | test_suites: ["general-tests"], |
| 215 | host_supported: true, |
| 216 | device_supported: false, |
| 217 | test_config: "ziptool-tests.xml", |
| 218 | data: ["cli-tests/**/*"], |
| 219 | target_required: ["cli-test", "ziptool"], |
| 220 | } |
Tianjie | 6ab2912 | 2020-03-18 17:44:30 -0700 | [diff] [blame] | 221 | |
| 222 | python_test_host { |
| 223 | name: "ziparchive_tests_large", |
| 224 | srcs: ["test_ziparchive_large.py"], |
| 225 | main: "test_ziparchive_large.py", |
| 226 | version: { |
| 227 | py2: { |
| 228 | enabled: true, |
| 229 | embedded_launcher: false, |
| 230 | }, |
| 231 | py3: { |
| 232 | enabled: false, |
| 233 | embedded_launcher: false, |
| 234 | }, |
| 235 | }, |
| 236 | test_suites: ["general-tests"], |
| 237 | } |