blob: bc1543b9abe1239e69a1c71a2e8cd02663eec392 [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",
29 ],
Pirama Arumuga Nainar53f59452018-09-18 14:58:17 -070030
31 // Enable -Wold-style-cast only for non-Windows targets. _islower_l,
32 // _isupper_l etc. in MinGW locale_win32.h (included from
33 // libcxx/include/__locale) has an old-style-cast.
34 target: {
35 not_windows: {
36 cppflags: [
37 "-Wold-style-cast",
38 ],
39 },
40 },
Nick Kralevich30dec072019-03-20 13:04:02 -070041 sanitize: {
42 misc_undefined: [
43 "signed-integer-overflow",
44 "unsigned-integer-overflow",
45 "shift",
46 "integer-divide-by-zero",
47 "implicit-signed-integer-truncation",
48 // TODO: Fix crash when we enable this option
49 // "implicit-unsigned-integer-truncation",
50 // TODO: not tested yet.
51 // "implicit-integer-sign-change",
52 ],
53 },
Colin Cross45566ba2016-07-12 18:45:19 -070054}
55
56cc_defaults {
57 name: "libziparchive_defaults",
58 srcs: [
59 "zip_archive.cc",
60 "zip_archive_stream_entry.cc",
61 "zip_writer.cc",
62 ],
63
64 target: {
65 windows: {
66 cflags: ["-mno-ms-bitfields"],
67
68 enabled: true,
69 },
70 },
71
72 shared_libs: [
73 "libbase",
74 "liblog",
75 ],
Andreas Gampea10a7e72017-07-05 22:02:54 -070076
77 export_include_dirs: ["include"],
Colin Cross45566ba2016-07-12 18:45:19 -070078}
79
Colin Cross45566ba2016-07-12 18:45:19 -070080cc_library {
81 name: "libziparchive",
82 host_supported: true,
Elliott Hughes55fd2932017-05-28 22:59:04 -070083 vendor_available: true,
Jiyong Park011ee122018-05-29 16:41:30 +090084 recovery_available: true,
Justin Yun096114d2017-08-03 15:51:33 +090085 vndk: {
86 enabled: true,
87 },
Jiyong Park91687872018-04-09 12:20:48 +090088 double_loadable: true,
Elliott Hughesa56a7292018-10-26 10:34:53 -070089 export_shared_lib_headers: ["libbase"],
Jayant Chowdhary2c87bcc2017-05-16 13:09:54 -070090
Elliott Hughes55fd2932017-05-28 22:59:04 -070091 defaults: [
92 "libziparchive_defaults",
93 "libziparchive_flags",
94 ],
95 shared_libs: [
96 "liblog",
97 "libbase",
Dan Willemsen5cfa0062017-09-27 16:24:45 -070098 "libz",
Elliott Hughes55fd2932017-05-28 22:59:04 -070099 ],
Colin Cross45566ba2016-07-12 18:45:19 -0700100 target: {
Dan Willemsenab34b472016-11-29 13:32:55 -0800101 linux_bionic: {
Dan Willemsenab34b472016-11-29 13:32:55 -0800102 enabled: true,
103 },
Colin Cross45566ba2016-07-12 18:45:19 -0700104 },
105}
106
Colin Cross45566ba2016-07-12 18:45:19 -0700107// Tests.
108cc_test {
109 name: "ziparchive-tests",
110 host_supported: true,
111 defaults: ["libziparchive_flags"],
112
Elliott Hughesbde0ec92018-04-25 12:49:19 -0700113 data: [
114 "testdata/**/*",
115 ],
116
Colin Cross45566ba2016-07-12 18:45:19 -0700117 srcs: [
118 "entry_name_utils_test.cc",
119 "zip_archive_test.cc",
120 "zip_writer_test.cc",
121 ],
122 shared_libs: [
123 "libbase",
124 "liblog",
125 ],
126
127 static_libs: [
128 "libziparchive",
129 "libz",
130 "libutils",
131 ],
132
133 target: {
134 host: {
135 cppflags: ["-Wno-unnamed-type-template-args"],
136 },
137 windows: {
138 enabled: true,
139 },
140 },
Elliott Hughese038f492018-10-29 12:29:34 -0700141 test_suites: ["device-tests"],
Colin Cross45566ba2016-07-12 18:45:19 -0700142}
Sebastian Pop0a94c562017-05-30 09:14:20 -0500143
144// Performance benchmarks.
145cc_benchmark {
146 name: "ziparchive-benchmarks",
147 defaults: ["libziparchive_flags"],
148
149 srcs: [
150 "zip_archive_benchmark.cpp",
151 ],
152 shared_libs: [
153 "libbase",
154 "liblog",
155 ],
156
157 static_libs: [
158 "libziparchive",
159 "libz",
160 "libutils",
161 ],
162
163 target: {
164 host: {
165 cppflags: ["-Wno-unnamed-type-template-args"],
166 },
167 },
168}
Elliott Hughes55fd2932017-05-28 22:59:04 -0700169
170cc_binary {
171 name: "unzip",
172 defaults: ["libziparchive_flags"],
173 srcs: ["unzip.cpp"],
174 shared_libs: [
175 "libbase",
176 "libziparchive",
177 ],
Elliott Hughesab089332018-09-04 13:33:30 -0700178 recovery_available: true,
Elliott Hughes55fd2932017-05-28 22:59:04 -0700179}