blob: 776a7e1e32e6de20d9e8dcd681313712c6115e6f [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
16cc_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 Poetzsch935432d2016-12-20 16:13:41 +000023 "-D_FILE_OFFSET_BITS=64",
Colin Crosse802a312016-07-12 18:45:19 -070024 ],
25 cppflags: [
Colin Crosse802a312016-07-12 18:45:19 -070026 // 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 Gampe5a5ffb52019-04-05 13:48:02 -070029 "-Wconversion",
30 "-Wno-sign-conversion",
Colin Crosse802a312016-07-12 18:45:19 -070031 ],
Pirama Arumuga Nainar3680cce2018-09-18 14:58:17 -070032
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 Kralevich5ca6bec2019-03-20 13:04:02 -070043 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 Crosse802a312016-07-12 18:45:19 -070056}
57
58cc_defaults {
59 name: "libziparchive_defaults",
60 srcs: [
61 "zip_archive.cc",
62 "zip_archive_stream_entry.cc",
Tianjie Xu91caafe2020-03-13 16:16:24 -070063 "zip_cd_entry_map.cc",
Elliott Hughes8cdfb162020-03-17 14:10:59 -070064 "zip_error.cpp",
Colin Crosse802a312016-07-12 18:45:19 -070065 "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 Gampea54290a2017-07-05 22:02:54 -070080
Donald Chai322a60b2019-07-02 17:25:03 -070081 // for FRIEND_TEST
82 static_libs: ["libgtest_prod"],
83 export_static_lib_headers: ["libgtest_prod"],
84
Andreas Gampea54290a2017-07-05 22:02:54 -070085 export_include_dirs: ["include"],
Colin Crosse802a312016-07-12 18:45:19 -070086}
87
Colin Crosse802a312016-07-12 18:45:19 -070088cc_library {
89 name: "libziparchive",
90 host_supported: true,
Elliott Hughes6702cef2017-05-28 22:59:04 -070091 vendor_available: true,
Justin Yune12cb492020-11-11 19:25:27 +090092 product_available: true,
Jiyong Park77d95a82018-05-29 16:41:30 +090093 recovery_available: true,
Yifan Hong71075532020-10-27 16:46:33 -070094 vendor_ramdisk_available: true,
dimitryf0ca1182019-05-06 14:01:58 +020095 native_bridge_supported: true,
Justin Yun6bade562017-08-03 15:51:33 +090096 vndk: {
97 enabled: true,
98 },
Jiyong Park9ad9bf12018-04-09 12:20:48 +090099 double_loadable: true,
Elliott Hughes4db8b382018-10-26 10:34:53 -0700100 export_shared_lib_headers: ["libbase"],
Jayant Chowdhary80476bd2017-05-16 13:09:54 -0700101
Elliott Hughes6702cef2017-05-28 22:59:04 -0700102 defaults: [
103 "libziparchive_defaults",
104 "libziparchive_flags",
105 ],
106 shared_libs: [
107 "liblog",
108 "libbase",
Dan Willemsend13406c2017-09-27 16:24:45 -0700109 "libz",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700110 ],
Colin Crosse802a312016-07-12 18:45:19 -0700111 target: {
Dan Willemsen152215c2016-11-29 13:32:55 -0800112 linux_bionic: {
Dan Willemsen152215c2016-11-29 13:32:55 -0800113 enabled: true,
114 },
Colin Crosse802a312016-07-12 18:45:19 -0700115 },
Jiyong Park3cbe5572020-05-25 20:57:43 +0900116
117 apex_available: [
118 "//apex_available:platform",
Martin Stjernholm394a24d2020-10-12 15:11:16 +0100119 "com.android.art",
Jiyong Park3cbe5572020-05-25 20:57:43 +0900120 "com.android.art.debug",
Jiyong Park3cbe5572020-05-25 20:57:43 +0900121 ],
Colin Crosse802a312016-07-12 18:45:19 -0700122}
123
Colin Crosse802a312016-07-12 18:45:19 -0700124// Tests.
125cc_test {
126 name: "ziparchive-tests",
127 host_supported: true,
128 defaults: ["libziparchive_flags"],
129
Elliott Hughes2ddb3ae2018-04-25 12:49:19 -0700130 data: [
131 "testdata/**/*",
132 ],
133
Colin Crosse802a312016-07-12 18:45:19 -0700134 srcs: [
135 "entry_name_utils_test.cc",
136 "zip_archive_test.cc",
137 "zip_writer_test.cc",
138 ],
139 shared_libs: [
140 "libbase",
141 "liblog",
142 ],
143
144 static_libs: [
145 "libziparchive",
146 "libz",
147 "libutils",
148 ],
149
150 target: {
151 host: {
152 cppflags: ["-Wno-unnamed-type-template-args"],
153 },
154 windows: {
155 enabled: true,
156 },
157 },
Elliott Hughes0a60efe2018-10-29 12:29:34 -0700158 test_suites: ["device-tests"],
Colin Crosse802a312016-07-12 18:45:19 -0700159}
Sebastian Pop7a4752d2017-05-30 09:14:20 -0500160
161// Performance benchmarks.
162cc_benchmark {
163 name: "ziparchive-benchmarks",
164 defaults: ["libziparchive_flags"],
165
166 srcs: [
167 "zip_archive_benchmark.cpp",
168 ],
169 shared_libs: [
170 "libbase",
171 "liblog",
172 ],
173
174 static_libs: [
175 "libziparchive",
176 "libz",
177 "libutils",
178 ],
179
180 target: {
181 host: {
182 cppflags: ["-Wno-unnamed-type-template-args"],
183 },
184 },
185}
Elliott Hughes6702cef2017-05-28 22:59:04 -0700186
187cc_binary {
Elliott Hughesdcd3f922019-10-25 09:57:58 -0700188 name: "ziptool",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700189 defaults: ["libziparchive_flags"],
Elliott Hughes224c21d2019-12-13 16:45:55 -0800190 srcs: ["ziptool.cpp"],
Elliott Hughes6702cef2017-05-28 22:59:04 -0700191 shared_libs: [
192 "libbase",
193 "libziparchive",
Elliott Hughesb75c9f32020-09-25 13:30:37 -0700194 "libz",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700195 ],
Elliott Hughes8fe93d12018-09-04 13:33:30 -0700196 recovery_available: true,
Elliott Hughesdcd3f922019-10-25 09:57:58 -0700197 host_supported: true,
198 target: {
199 android: {
200 symlinks: ["unzip", "zipinfo"],
201 },
202 },
Elliott Hughes6702cef2017-05-28 22:59:04 -0700203}
Elliott Hughes62c2d532019-10-22 11:44:50 -0700204
205cc_fuzz {
206 name: "libziparchive_fuzzer",
207 srcs: ["libziparchive_fuzzer.cpp"],
208 static_libs: ["libziparchive", "libbase", "libz", "liblog"],
209 host_supported: true,
Elliott Hughesd95e8dd2019-11-07 14:24:04 -0800210 corpus: ["testdata/*"],
Elliott Hughes62c2d532019-10-22 11:44:50 -0700211}
Elliott Hughes00725992019-11-15 15:07:00 -0800212
213sh_test {
214 name: "ziptool-tests",
215 src: "run-ziptool-tests-on-android.sh",
216 filename: "run-ziptool-tests-on-android.sh",
217 test_suites: ["general-tests"],
218 host_supported: true,
219 device_supported: false,
Elliott Hughes00725992019-11-15 15:07:00 -0800220 data: ["cli-tests/**/*"],
221 target_required: ["cli-test", "ziptool"],
Frank Feng49f01892020-10-12 23:06:31 +0000222 data_device_bins: ["cli-test"],
Elliott Hughes00725992019-11-15 15:07:00 -0800223}
Tianjie439a46f2020-03-18 17:44:30 -0700224
225python_test_host {
226 name: "ziparchive_tests_large",
227 srcs: ["test_ziparchive_large.py"],
228 main: "test_ziparchive_large.py",
229 version: {
230 py2: {
231 enabled: true,
232 embedded_launcher: false,
233 },
234 py3: {
235 enabled: false,
236 embedded_launcher: false,
237 },
238 },
239 test_suites: ["general-tests"],
240}