blob: 858c0bb4745ad050ee84b1d6c68bbf55aed95e17 [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",
63 "zip_writer.cc",
64 ],
65
66 target: {
67 windows: {
68 cflags: ["-mno-ms-bitfields"],
69
70 enabled: true,
71 },
72 },
73
74 shared_libs: [
75 "libbase",
76 "liblog",
77 ],
Andreas Gampea10a7e72017-07-05 22:02:54 -070078
79 export_include_dirs: ["include"],
Colin Cross45566ba2016-07-12 18:45:19 -070080}
81
Colin Cross45566ba2016-07-12 18:45:19 -070082cc_library {
83 name: "libziparchive",
84 host_supported: true,
Elliott Hughes55fd2932017-05-28 22:59:04 -070085 vendor_available: true,
Jiyong Park011ee122018-05-29 16:41:30 +090086 recovery_available: true,
Justin Yun096114d2017-08-03 15:51:33 +090087 vndk: {
88 enabled: true,
89 },
Jiyong Park91687872018-04-09 12:20:48 +090090 double_loadable: true,
Elliott Hughesa56a7292018-10-26 10:34:53 -070091 export_shared_lib_headers: ["libbase"],
Jayant Chowdhary2c87bcc2017-05-16 13:09:54 -070092
Elliott Hughes55fd2932017-05-28 22:59:04 -070093 defaults: [
94 "libziparchive_defaults",
95 "libziparchive_flags",
96 ],
97 shared_libs: [
98 "liblog",
99 "libbase",
Dan Willemsen5cfa0062017-09-27 16:24:45 -0700100 "libz",
Elliott Hughes55fd2932017-05-28 22:59:04 -0700101 ],
Colin Cross45566ba2016-07-12 18:45:19 -0700102 target: {
Dan Willemsenab34b472016-11-29 13:32:55 -0800103 linux_bionic: {
Dan Willemsenab34b472016-11-29 13:32:55 -0800104 enabled: true,
105 },
Colin Cross45566ba2016-07-12 18:45:19 -0700106 },
107}
108
Colin Cross45566ba2016-07-12 18:45:19 -0700109// Tests.
110cc_test {
111 name: "ziparchive-tests",
112 host_supported: true,
113 defaults: ["libziparchive_flags"],
114
Elliott Hughesbde0ec92018-04-25 12:49:19 -0700115 data: [
116 "testdata/**/*",
117 ],
118
Colin Cross45566ba2016-07-12 18:45:19 -0700119 srcs: [
120 "entry_name_utils_test.cc",
121 "zip_archive_test.cc",
122 "zip_writer_test.cc",
123 ],
124 shared_libs: [
125 "libbase",
126 "liblog",
127 ],
128
129 static_libs: [
130 "libziparchive",
131 "libz",
132 "libutils",
133 ],
134
135 target: {
136 host: {
137 cppflags: ["-Wno-unnamed-type-template-args"],
138 },
139 windows: {
140 enabled: true,
141 },
142 },
Elliott Hughese038f492018-10-29 12:29:34 -0700143 test_suites: ["device-tests"],
Colin Cross45566ba2016-07-12 18:45:19 -0700144}
Sebastian Pop0a94c562017-05-30 09:14:20 -0500145
146// Performance benchmarks.
147cc_benchmark {
148 name: "ziparchive-benchmarks",
149 defaults: ["libziparchive_flags"],
150
151 srcs: [
152 "zip_archive_benchmark.cpp",
153 ],
154 shared_libs: [
155 "libbase",
156 "liblog",
157 ],
158
159 static_libs: [
160 "libziparchive",
161 "libz",
162 "libutils",
163 ],
164
165 target: {
166 host: {
167 cppflags: ["-Wno-unnamed-type-template-args"],
168 },
169 },
170}
Elliott Hughes55fd2932017-05-28 22:59:04 -0700171
172cc_binary {
173 name: "unzip",
174 defaults: ["libziparchive_flags"],
175 srcs: ["unzip.cpp"],
176 shared_libs: [
177 "libbase",
178 "libziparchive",
179 ],
Elliott Hughesab089332018-09-04 13:33:30 -0700180 recovery_available: true,
Elliott Hughes55fd2932017-05-28 22:59:04 -0700181}