blob: 4081b21f4d9d5c76ed1b10d63a2dc09f6c5f34e6 [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,
Jiyong Park77d95a82018-05-29 16:41:30 +090092 recovery_available: true,
dimitryf0ca1182019-05-06 14:01:58 +020093 native_bridge_supported: true,
Justin Yun6bade562017-08-03 15:51:33 +090094 vndk: {
95 enabled: true,
96 },
Jiyong Park9ad9bf12018-04-09 12:20:48 +090097 double_loadable: true,
Elliott Hughes4db8b382018-10-26 10:34:53 -070098 export_shared_lib_headers: ["libbase"],
Jayant Chowdhary80476bd2017-05-16 13:09:54 -070099
Elliott Hughes6702cef2017-05-28 22:59:04 -0700100 defaults: [
101 "libziparchive_defaults",
102 "libziparchive_flags",
103 ],
104 shared_libs: [
105 "liblog",
106 "libbase",
Dan Willemsend13406c2017-09-27 16:24:45 -0700107 "libz",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700108 ],
Colin Crosse802a312016-07-12 18:45:19 -0700109 target: {
Dan Willemsen152215c2016-11-29 13:32:55 -0800110 linux_bionic: {
Dan Willemsen152215c2016-11-29 13:32:55 -0800111 enabled: true,
112 },
Colin Crosse802a312016-07-12 18:45:19 -0700113 },
114}
115
Colin Crosse802a312016-07-12 18:45:19 -0700116// Tests.
117cc_test {
118 name: "ziparchive-tests",
119 host_supported: true,
120 defaults: ["libziparchive_flags"],
121
Elliott Hughes2ddb3ae2018-04-25 12:49:19 -0700122 data: [
123 "testdata/**/*",
124 ],
125
Colin Crosse802a312016-07-12 18:45:19 -0700126 srcs: [
127 "entry_name_utils_test.cc",
128 "zip_archive_test.cc",
129 "zip_writer_test.cc",
130 ],
131 shared_libs: [
132 "libbase",
133 "liblog",
134 ],
135
136 static_libs: [
137 "libziparchive",
138 "libz",
139 "libutils",
140 ],
141
142 target: {
143 host: {
144 cppflags: ["-Wno-unnamed-type-template-args"],
145 },
146 windows: {
147 enabled: true,
148 },
149 },
Elliott Hughes0a60efe2018-10-29 12:29:34 -0700150 test_suites: ["device-tests"],
Colin Crosse802a312016-07-12 18:45:19 -0700151}
Sebastian Pop7a4752d2017-05-30 09:14:20 -0500152
153// Performance benchmarks.
154cc_benchmark {
155 name: "ziparchive-benchmarks",
156 defaults: ["libziparchive_flags"],
157
158 srcs: [
159 "zip_archive_benchmark.cpp",
160 ],
161 shared_libs: [
162 "libbase",
163 "liblog",
164 ],
165
166 static_libs: [
167 "libziparchive",
168 "libz",
169 "libutils",
170 ],
171
172 target: {
173 host: {
174 cppflags: ["-Wno-unnamed-type-template-args"],
175 },
176 },
177}
Elliott Hughes6702cef2017-05-28 22:59:04 -0700178
179cc_binary {
Elliott Hughesdcd3f922019-10-25 09:57:58 -0700180 name: "ziptool",
Elliott Hughes6702cef2017-05-28 22:59:04 -0700181 defaults: ["libziparchive_flags"],
Elliott Hughes224c21d2019-12-13 16:45:55 -0800182 srcs: ["ziptool.cpp"],
Elliott Hughes6702cef2017-05-28 22:59:04 -0700183 shared_libs: [
184 "libbase",
185 "libziparchive",
186 ],
Elliott Hughes8fe93d12018-09-04 13:33:30 -0700187 recovery_available: true,
Elliott Hughesdcd3f922019-10-25 09:57:58 -0700188 host_supported: true,
189 target: {
190 android: {
191 symlinks: ["unzip", "zipinfo"],
192 },
193 },
Elliott Hughes6702cef2017-05-28 22:59:04 -0700194}
Elliott Hughes62c2d532019-10-22 11:44:50 -0700195
196cc_fuzz {
197 name: "libziparchive_fuzzer",
198 srcs: ["libziparchive_fuzzer.cpp"],
199 static_libs: ["libziparchive", "libbase", "libz", "liblog"],
200 host_supported: true,
Elliott Hughesd95e8dd2019-11-07 14:24:04 -0800201 corpus: ["testdata/*"],
Elliott Hughes62c2d532019-10-22 11:44:50 -0700202}
Elliott Hughes00725992019-11-15 15:07:00 -0800203
204sh_test {
205 name: "ziptool-tests",
206 src: "run-ziptool-tests-on-android.sh",
207 filename: "run-ziptool-tests-on-android.sh",
208 test_suites: ["general-tests"],
209 host_supported: true,
210 device_supported: false,
211 test_config: "ziptool-tests.xml",
212 data: ["cli-tests/**/*"],
213 target_required: ["cli-test", "ziptool"],
214}