blob: 8226d3930e3dcacced376e1e1d1cd2b0b1cc3371 [file] [log] [blame]
Colin Crosse802a312016-07-12 18:45:19 -07001//
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 Badourc7b498f2021-02-03 19:53:26 -080016package {
17 default_applicable_licenses: ["Android-Apache-2.0"],
18}
19
Colin Crosse802a312016-07-12 18:45:19 -070020cc_defaults {
21 name: "libziparchive_flags",
Yurii Zubrytskyi3c793c42021-02-22 16:22:01 -080022 cpp_std: "c++2a",
Colin Crosse802a312016-07-12 18:45:19 -070023 cflags: [
24 // ZLIB_CONST turns on const for input buffers, which is pretty standard.
25 "-DZLIB_CONST",
26 "-Werror",
27 "-Wall",
Christian Poetzsch935432d2016-12-20 16:13:41 +000028 "-D_FILE_OFFSET_BITS=64",
Colin Crosse802a312016-07-12 18:45:19 -070029 ],
30 cppflags: [
Colin Crosse802a312016-07-12 18:45:19 -070031 // 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 Gampe5a5ffb52019-04-05 13:48:02 -070034 "-Wconversion",
35 "-Wno-sign-conversion",
Colin Crosse802a312016-07-12 18:45:19 -070036 ],
Pirama Arumuga Nainar3680cce2018-09-18 14:58:17 -070037
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 Kralevich5ca6bec2019-03-20 13:04:02 -070048 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 Crosse802a312016-07-12 18:45:19 -070061}
62
63cc_defaults {
64 name: "libziparchive_defaults",
Yurii Zubrytskyi3c793c42021-02-22 16:22:01 -080065 local_include_dirs: ["incfs_support/include/"],
Colin Crosse802a312016-07-12 18:45:19 -070066 srcs: [
67 "zip_archive.cc",
68 "zip_archive_stream_entry.cc",
Tianjie Xu91caafe2020-03-13 16:16:24 -070069 "zip_cd_entry_map.cc",
Elliott Hughes8cdfb162020-03-17 14:10:59 -070070 "zip_error.cpp",
Colin Crosse802a312016-07-12 18:45:19 -070071 "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 Gampea54290a2017-07-05 22:02:54 -070086
Donald Chai322a60b2019-07-02 17:25:03 -070087 // for FRIEND_TEST
Elliott Hughes03abb6e2021-04-20 15:28:22 -070088 header_libs: ["libgtest_prod_headers"],
89 export_header_lib_headers: ["libgtest_prod_headers"],
Donald Chai322a60b2019-07-02 17:25:03 -070090
Andreas Gampea54290a2017-07-05 22:02:54 -070091 export_include_dirs: ["include"],
Colin Crosse802a312016-07-12 18:45:19 -070092}
93
Yurii Zubrytskyi3c793c42021-02-22 16:22:01 -080094cc_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",
Colin Crosse802a312016-07-12 18:45:19 -0700117 host_supported: true,
Elliott Hughes6702cef2017-05-28 22:59:04 -0700118 vendor_available: true,
Justin Yune12cb492020-11-11 19:25:27 +0900119 product_available: true,
Jiyong Park77d95a82018-05-29 16:41:30 +0900120 recovery_available: true,
Yifan Hong71075532020-10-27 16:46:33 -0700121 vendor_ramdisk_available: true,
dimitryf0ca1182019-05-06 14:01:58 +0200122 native_bridge_supported: true,
Justin Yun6bade562017-08-03 15:51:33 +0900123 vndk: {
124 enabled: true,
125 },
Jiyong Park9ad9bf12018-04-09 12:20:48 +0900126 double_loadable: true,
Elliott Hughes4db8b382018-10-26 10:34:53 -0700127 export_shared_lib_headers: ["libbase"],
Jayant Chowdhary80476bd2017-05-16 13:09:54 -0700128
Elliott Hughes6702cef2017-05-28 22:59:04 -0700129 defaults: [
130 "libziparchive_defaults",
131 "libziparchive_flags",
132 ],
133 shared_libs: [
134 "liblog",
135 "libbase",
Dan Willemsend13406c2017-09-27 16:24:45 -0700136 "libz",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700137 ],
Colin Crosse802a312016-07-12 18:45:19 -0700138 target: {
Dan Willemsen152215c2016-11-29 13:32:55 -0800139 linux_bionic: {
Dan Willemsen152215c2016-11-29 13:32:55 -0800140 enabled: true,
141 },
Colin Crosse802a312016-07-12 18:45:19 -0700142 },
Jiyong Park3cbe5572020-05-25 20:57:43 +0900143
144 apex_available: [
145 "//apex_available:platform",
Martin Stjernholm394a24d2020-10-12 15:11:16 +0100146 "com.android.art",
Jiyong Park3cbe5572020-05-25 20:57:43 +0900147 "com.android.art.debug",
Jiyong Park07fc7e62021-01-05 14:46:31 +0900148 "com.android.virt",
Jiyong Park3cbe5572020-05-25 20:57:43 +0900149 ],
Nicolas Geoffrayc7d36d02021-03-03 21:53:19 +0000150 min_sdk_version: "apex_inherit",
Colin Crosse802a312016-07-12 18:45:19 -0700151}
152
Yurii Zubrytskyi3c793c42021-02-22 16:22:01 -0800153cc_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
Colin Crosse802a312016-07-12 18:45:19 -0700170// Tests.
171cc_test {
172 name: "ziparchive-tests",
173 host_supported: true,
174 defaults: ["libziparchive_flags"],
175
Elliott Hughes2ddb3ae2018-04-25 12:49:19 -0700176 data: [
177 "testdata/**/*",
178 ],
179
Colin Crosse802a312016-07-12 18:45:19 -0700180 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 Hughes0a60efe2018-10-29 12:29:34 -0700204 test_suites: ["device-tests"],
Colin Crosse802a312016-07-12 18:45:19 -0700205}
Sebastian Pop7a4752d2017-05-30 09:14:20 -0500206
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}
Elliott Hughes6702cef2017-05-28 22:59:04 -0700232
233cc_binary {
Elliott Hughesdcd3f922019-10-25 09:57:58 -0700234 name: "ziptool",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700235 defaults: ["libziparchive_flags"],
Elliott Hughes224c21d2019-12-13 16:45:55 -0800236 srcs: ["ziptool.cpp"],
Elliott Hughes6702cef2017-05-28 22:59:04 -0700237 shared_libs: [
238 "libbase",
239 "libziparchive",
Elliott Hughesb75c9f32020-09-25 13:30:37 -0700240 "libz",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700241 ],
Elliott Hughes8fe93d12018-09-04 13:33:30 -0700242 recovery_available: true,
Elliott Hughesdcd3f922019-10-25 09:57:58 -0700243 host_supported: true,
244 target: {
245 android: {
246 symlinks: ["unzip", "zipinfo"],
247 },
248 },
Elliott Hughes6702cef2017-05-28 22:59:04 -0700249}
Elliott Hughes62c2d532019-10-22 11:44:50 -0700250
251cc_fuzz {
252 name: "libziparchive_fuzzer",
253 srcs: ["libziparchive_fuzzer.cpp"],
Yurii Zubrytskyi3c793c42021-02-22 16:22:01 -0800254 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 ],
Elliott Hughes62c2d532019-10-22 11:44:50 -0700273 host_supported: true,
Elliott Hughesd95e8dd2019-11-07 14:24:04 -0800274 corpus: ["testdata/*"],
Elliott Hughes62c2d532019-10-22 11:44:50 -0700275}
Elliott Hughes00725992019-11-15 15:07:00 -0800276
Huizi Yangb3c85b62021-03-15 15:47:48 -0700277cc_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 Hughes00725992019-11-15 15:07:00 -0800285sh_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 Hughes00725992019-11-15 15:07:00 -0800292 data: ["cli-tests/**/*"],
293 target_required: ["cli-test", "ziptool"],
Frank Feng49f01892020-10-12 23:06:31 +0000294 data_device_bins: ["cli-test"],
Elliott Hughes00725992019-11-15 15:07:00 -0800295}
Tianjie439a46f2020-03-18 17:44:30 -0700296
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"],
Julien Desprez6e2b2b92021-04-02 01:52:34 +0000312 test_options: {
313 unit_test: false,
314 },
Tianjie439a46f2020-03-18 17:44:30 -0700315}