blob: 3d4e86e4612a2e9bc7f1eff190fc373cc509fc25 [file] [log] [blame]
Colin Cross45566ba2016-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 Poetzsch3081c5e2016-12-20 16:13:41 +000023 "-D_FILE_OFFSET_BITS=64",
Colin Cross45566ba2016-07-12 18:45:19 -070024 ],
25 cppflags: [
Colin Cross45566ba2016-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 Gampe964b95c2019-04-05 13:48:02 -070029 "-Wconversion",
30 "-Wno-sign-conversion",
Colin Cross45566ba2016-07-12 18:45:19 -070031 ],
Pirama Arumuga Nainar53f59452018-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 Kralevich30dec072019-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 Cross45566ba2016-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 Xu323c09c2020-03-13 16:16:24 -070063 "zip_cd_entry_map.cc",
Colin Cross45566ba2016-07-12 18:45:19 -070064 "zip_writer.cc",
65 ],
66
67 target: {
68 windows: {
69 cflags: ["-mno-ms-bitfields"],
70
71 enabled: true,
72 },
73 },
74
75 shared_libs: [
76 "libbase",
77 "liblog",
78 ],
Andreas Gampea10a7e72017-07-05 22:02:54 -070079
Donald Chaie170d7f2019-07-02 17:25:03 -070080 // for FRIEND_TEST
81 static_libs: ["libgtest_prod"],
82 export_static_lib_headers: ["libgtest_prod"],
83
Andreas Gampea10a7e72017-07-05 22:02:54 -070084 export_include_dirs: ["include"],
Colin Cross45566ba2016-07-12 18:45:19 -070085}
86
Colin Cross45566ba2016-07-12 18:45:19 -070087cc_library {
88 name: "libziparchive",
89 host_supported: true,
Elliott Hughes55fd2932017-05-28 22:59:04 -070090 vendor_available: true,
Jiyong Park011ee122018-05-29 16:41:30 +090091 recovery_available: true,
dimitrya808b112019-05-06 14:01:58 +020092 native_bridge_supported: true,
Justin Yun096114d2017-08-03 15:51:33 +090093 vndk: {
94 enabled: true,
95 },
Jiyong Park91687872018-04-09 12:20:48 +090096 double_loadable: true,
Elliott Hughesa56a7292018-10-26 10:34:53 -070097 export_shared_lib_headers: ["libbase"],
Jayant Chowdhary2c87bcc2017-05-16 13:09:54 -070098
Elliott Hughes55fd2932017-05-28 22:59:04 -070099 defaults: [
100 "libziparchive_defaults",
101 "libziparchive_flags",
102 ],
103 shared_libs: [
104 "liblog",
105 "libbase",
Dan Willemsen5cfa0062017-09-27 16:24:45 -0700106 "libz",
Elliott Hughes55fd2932017-05-28 22:59:04 -0700107 ],
Colin Cross45566ba2016-07-12 18:45:19 -0700108 target: {
Dan Willemsenab34b472016-11-29 13:32:55 -0800109 linux_bionic: {
Dan Willemsenab34b472016-11-29 13:32:55 -0800110 enabled: true,
111 },
Colin Cross45566ba2016-07-12 18:45:19 -0700112 },
113}
114
Colin Cross45566ba2016-07-12 18:45:19 -0700115// Tests.
116cc_test {
117 name: "ziparchive-tests",
118 host_supported: true,
119 defaults: ["libziparchive_flags"],
120
Elliott Hughesbde0ec92018-04-25 12:49:19 -0700121 data: [
122 "testdata/**/*",
123 ],
124
Colin Cross45566ba2016-07-12 18:45:19 -0700125 srcs: [
126 "entry_name_utils_test.cc",
127 "zip_archive_test.cc",
128 "zip_writer_test.cc",
129 ],
130 shared_libs: [
131 "libbase",
132 "liblog",
133 ],
134
135 static_libs: [
136 "libziparchive",
137 "libz",
138 "libutils",
139 ],
140
141 target: {
142 host: {
143 cppflags: ["-Wno-unnamed-type-template-args"],
144 },
145 windows: {
146 enabled: true,
147 },
148 },
Elliott Hughese038f492018-10-29 12:29:34 -0700149 test_suites: ["device-tests"],
Colin Cross45566ba2016-07-12 18:45:19 -0700150}
Sebastian Pop0a94c562017-05-30 09:14:20 -0500151
152// Performance benchmarks.
153cc_benchmark {
154 name: "ziparchive-benchmarks",
155 defaults: ["libziparchive_flags"],
156
157 srcs: [
158 "zip_archive_benchmark.cpp",
159 ],
160 shared_libs: [
161 "libbase",
162 "liblog",
163 ],
164
165 static_libs: [
166 "libziparchive",
167 "libz",
168 "libutils",
169 ],
170
171 target: {
172 host: {
173 cppflags: ["-Wno-unnamed-type-template-args"],
174 },
175 },
176}
Elliott Hughes55fd2932017-05-28 22:59:04 -0700177
178cc_binary {
Elliott Hughes26724132019-10-25 09:57:58 -0700179 name: "ziptool",
Elliott Hughes55fd2932017-05-28 22:59:04 -0700180 defaults: ["libziparchive_flags"],
Elliott Hughes8748bcc2019-12-13 16:45:55 -0800181 srcs: ["ziptool.cpp"],
Elliott Hughes55fd2932017-05-28 22:59:04 -0700182 shared_libs: [
183 "libbase",
184 "libziparchive",
185 ],
Elliott Hughesab089332018-09-04 13:33:30 -0700186 recovery_available: true,
Elliott Hughes26724132019-10-25 09:57:58 -0700187 host_supported: true,
188 target: {
189 android: {
190 symlinks: ["unzip", "zipinfo"],
191 },
192 },
Elliott Hughes55fd2932017-05-28 22:59:04 -0700193}
Elliott Hughesf66460b2019-10-22 11:44:50 -0700194
195cc_fuzz {
196 name: "libziparchive_fuzzer",
197 srcs: ["libziparchive_fuzzer.cpp"],
198 static_libs: ["libziparchive", "libbase", "libz", "liblog"],
199 host_supported: true,
Elliott Hughes9e63ba72019-11-07 14:24:04 -0800200 corpus: ["testdata/*"],
Elliott Hughesf66460b2019-10-22 11:44:50 -0700201}
Elliott Hughesf2761402019-11-15 15:07:00 -0800202
203sh_test {
204 name: "ziptool-tests",
205 src: "run-ziptool-tests-on-android.sh",
206 filename: "run-ziptool-tests-on-android.sh",
207 test_suites: ["general-tests"],
208 host_supported: true,
209 device_supported: false,
210 test_config: "ziptool-tests.xml",
211 data: ["cli-tests/**/*"],
212 target_required: ["cli-test", "ziptool"],
213}