• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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",
23        "-D_FILE_OFFSET_BITS=64",
24    ],
25    cppflags: [
26        // 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        "-Wconversion",
30        "-Wno-sign-conversion",
31    ],
32
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    },
43    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    },
56}
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    ],
78
79    // for FRIEND_TEST
80    static_libs: ["libgtest_prod"],
81    export_static_lib_headers: ["libgtest_prod"],
82
83    export_include_dirs: ["include"],
84}
85
86cc_library {
87    name: "libziparchive",
88    host_supported: true,
89    vendor_available: true,
90    recovery_available: true,
91    native_bridge_supported: true,
92    vndk: {
93        enabled: true,
94    },
95    double_loadable: true,
96    export_shared_lib_headers: ["libbase"],
97
98    defaults: [
99        "libziparchive_defaults",
100        "libziparchive_flags",
101    ],
102    shared_libs: [
103        "liblog",
104        "libbase",
105        "libz",
106    ],
107    target: {
108        linux_bionic: {
109            enabled: true,
110        },
111    },
112
113    apex_available: [
114        "//apex_available:platform",
115        "com.android.art.debug",
116        "com.android.art.release",
117    ],
118}
119
120// Tests.
121cc_test {
122    name: "ziparchive-tests",
123    host_supported: true,
124    defaults: ["libziparchive_flags"],
125
126    data: [
127        "testdata/**/*",
128    ],
129
130    srcs: [
131        "entry_name_utils_test.cc",
132        "zip_archive_test.cc",
133        "zip_writer_test.cc",
134    ],
135    shared_libs: [
136        "libbase",
137        "liblog",
138    ],
139
140    static_libs: [
141        "libziparchive",
142        "libz",
143        "libutils",
144    ],
145
146    target: {
147        host: {
148            cppflags: ["-Wno-unnamed-type-template-args"],
149        },
150        windows: {
151            enabled: true,
152        },
153    },
154    test_suites: ["device-tests"],
155}
156
157// Performance benchmarks.
158cc_benchmark {
159    name: "ziparchive-benchmarks",
160    defaults: ["libziparchive_flags"],
161
162    srcs: [
163        "zip_archive_benchmark.cpp",
164    ],
165    shared_libs: [
166        "libbase",
167        "liblog",
168    ],
169
170    static_libs: [
171        "libziparchive",
172        "libz",
173        "libutils",
174    ],
175
176    target: {
177        host: {
178            cppflags: ["-Wno-unnamed-type-template-args"],
179        },
180    },
181}
182
183cc_binary {
184    name: "ziptool",
185    defaults: ["libziparchive_flags"],
186    srcs: ["ziptool.cpp"],
187    shared_libs: [
188        "libbase",
189        "libziparchive",
190    ],
191    recovery_available: true,
192    host_supported: true,
193    target: {
194        android: {
195            symlinks: ["unzip", "zipinfo"],
196        },
197    },
198}
199
200cc_fuzz {
201    name: "libziparchive_fuzzer",
202    srcs: ["libziparchive_fuzzer.cpp"],
203    static_libs: ["libziparchive", "libbase", "libz", "liblog"],
204    host_supported: true,
205    corpus: ["testdata/*"],
206}
207
208sh_test {
209    name: "ziptool-tests",
210    src: "run-ziptool-tests-on-android.sh",
211    filename: "run-ziptool-tests-on-android.sh",
212    test_suites: ["general-tests"],
213    host_supported: true,
214    device_supported: false,
215    test_config: "ziptool-tests.xml",
216    data: ["cli-tests/**/*"],
217    target_required: ["cli-test", "ziptool"],
218}
219