blob: a91b35daef77ded03f28009ca851bbbdd1a630bc [file] [log] [blame]
Elliott Hughesce1c0372020-02-14 00:58:28 +00001srcs_opt = [
2 "adler32_simd.c",
3 // See https://chromium-review.googlesource.com/749732.
4// TODO: causes `atest org.apache.harmony.tests.java.util.zip.DeflaterTest` failures.
5// "contrib/optimizations/inffast_chunk.c",
6// "contrib/optimizations/inflate.c",
7 // This file doesn't build for non-neon, so it can't be in the main srcs.
8 "cpu_features.c",
9 "crc32_simd.c",
10]
11
12cflags_arm = [
13 // Since we're building for the platform, we claim to be Linux rather than
14 // Android so we use getauxval() directly instead of the NDK
15 // android_getCpuFeatures which isn't available to us anyway.
16 "-DARMV8_OS_LINUX",
17 // Testing with zlib_bench shows -O3 is a win for ARM but a bit of a wash
18 // for x86, so match the BUILD file in only enabling this for ARM.
19 "-O3",
20]
21cflags_arm_neon = [
22 // We no longer support non-Neon platform builds, but the NDK just has one libz.
23 "-DADLER32_SIMD_NEON",
24// TODO: causes `atest org.apache.harmony.tests.java.util.zip.DeflaterTest` failures.
25// "-DINFLATE_CHUNK_SIMD_NEON",
26 // HWCAP_CRC32 is checked at runtime, so it's okay to turn crc32
27 // acceleration on for both 32- and 64-bit.
28 "-DCRC32_ARMV8_CRC32",
29]
30cflags_arm64 = cflags_arm + cflags_arm_neon
31
32cflags_x86 = [
33 // See ARMV8_OS_LINUX above.
34 "-DX86_NOT_WINDOWS",
35 // Android's x86/x86-64 ABI includes SSE2 and SSSE3.
36 "-DADLER32_SIMD_SSSE3",
37// TODO: see arm above.
38// "-DINFLATE_CHUNK_SIMD_SSE2",
39 // TODO: ...but the host build system defaults don't match our official ABI.
40 "-mssse3",
41 // PCLMUL isn't in the ABI, but it won't actually be used unless CPUID
42 // reports that the processor really does have the instruction.
43 "-mpclmul",
44 "-DCRC32_SIMD_SSE42_PCLMUL",
45]
46srcs_x86 = [
47 "crc_folding.c",
48 "fill_window_sse.c",
49] + srcs_opt
50
51// This optimization is applicable to arm64 and x86-64.
52cflags_64 = ["-DINFLATE_CHUNK_READ_64LE"]
53
xNombre0d184e72020-07-03 18:50:21 +020054cc_library {
55 name: "libz",
56
57 host_supported: true,
58 unique_host_soname: true,
59 static_ndk_lib: true,
60
61 vendor_available: true,
62 vndk: {
63 enabled: true,
64 support_system_process: true,
65 },
66 recovery_available: true,
Dan Willemsenc1b393b2016-07-06 19:05:32 -070067
68 cflags: [
Elliott Hughesce1c0372020-02-14 00:58:28 +000069 // We do support hidden visibility, so turn that on.
Elliott Hughes35329cd2019-04-10 14:56:06 -070070 "-DHAVE_HIDDEN",
Elliott Hughesce1c0372020-02-14 00:58:28 +000071 // We do support const, so turn that on.
Tao Bao5604dec2016-12-19 13:29:53 -080072 "-DZLIB_CONST",
Park Ju Hyung1517f082017-05-15 03:44:27 +090073 "-DUNALIGNED_OK",
Chih-Hung Hsieh3e5deb42017-09-29 11:41:33 -070074 "-Wall",
75 "-Werror",
Elliott Hughese7091dd2019-06-06 12:47:16 -070076 "-Wno-unused",
77 "-Wno-unused-parameter",
Dan Willemsenc1b393b2016-07-06 19:05:32 -070078 ],
79 stl: "none",
80 export_include_dirs: ["."],
81 srcs: [
Elliott Hughese7091dd2019-06-06 12:47:16 -070082 "adler32.c",
83 "compress.c",
84 "crc32.c",
85 "deflate.c",
86 "gzclose.c",
87 "gzlib.c",
88 "gzread.c",
89 "gzwrite.c",
90 "infback.c",
Elliott Hughesce1c0372020-02-14 00:58:28 +000091 "inffast.c",
Zhen Zhangfed86a72020-01-16 20:15:30 +000092 "inflate.c",
Elliott Hughese7091dd2019-06-06 12:47:16 -070093 "inftrees.c",
Elliott Hughese7091dd2019-06-06 12:47:16 -070094 "trees.c",
95 "uncompr.c",
96 "zutil.c",
Dan Willemsenc1b393b2016-07-06 19:05:32 -070097 ],
98
99 arch: {
100 arm: {
Elliott Hughese7091dd2019-06-06 12:47:16 -0700101 // TODO: This is to work around b/24465209. Remove after root cause
102 // is fixed.
Chih-Hung Hsieh19b536b2018-05-23 18:52:18 -0700103 pack_relocations: false,
Ian Pedowitzcca7bd42018-01-18 16:22:54 -0800104 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesce1c0372020-02-14 00:58:28 +0000105
106 cflags: cflags_arm,
107 neon: {
108 cflags: cflags_arm_neon,
109 srcs: srcs_opt,
110 }
111 },
112 arm64: {
113 cflags: cflags_arm64 + cflags_64,
114 srcs: srcs_opt,
115 },
116 x86: {
117 cflags: cflags_x86,
118 srcs: srcs_x86,
119 },
120 x86_64: {
121 cflags: cflags_x86 + cflags_64,
122 srcs: srcs_x86,
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700123 },
124 },
125
126 target: {
Dan Willemsen0bb579c2016-11-04 12:27:30 -0700127 linux_bionic: {
128 enabled: true,
129 },
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700130 windows: {
131 enabled: true,
132 },
133 },
134}
135
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700136cc_binary_host {
137 name: "minigzip",
Elliott Hughese7091dd2019-06-06 12:47:16 -0700138 srcs: ["contrib/minigzip/minigzip.c"],
139 cflags: ["-Wall", "-Werror", "-DUSE_MMAP"],
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700140 static_libs: ["libz"],
141 stl: "none",
142}
Dan Alberte405a262016-09-15 16:24:19 -0700143
Narayan Kamath1a14eb32017-01-06 12:49:24 +0000144cc_binary {
Elliott Hughese7091dd2019-06-06 12:47:16 -0700145 name: "zlib_bench",
146 srcs: ["contrib/bench/zlib_bench.cc"],
Chih-Hung Hsieh3e5deb42017-09-29 11:41:33 -0700147 cflags: ["-Wall", "-Werror"],
Elliott Hughese7091dd2019-06-06 12:47:16 -0700148 host_supported: true,
Narayan Kamath1a14eb32017-01-06 12:49:24 +0000149 shared_libs: ["libz"],
Elliott Hughesce1c0372020-02-14 00:58:28 +0000150 // We build zlib_bench32 and zlib_bench64 so it's easy to test LP32.
151 compile_multilib: "both",
152 multilib: {
153 lib32: { suffix: "32", },
154 lib64: { suffix: "64", },
155 },
Narayan Kamath1a14eb32017-01-06 12:49:24 +0000156}
157
Elliott Hughes822a4b82020-06-17 09:01:27 -0700158cc_test {
159 name: "zlib_tests",
160 srcs: [
161 "contrib/tests/infcover.cc",
162 "contrib/tests/utils_unittest.cc",
163 "google/compression_utils_portable.cc",
164 ],
165 include_dirs: [
166 "external/zlib/google",
167 // These tests include "gtest.h" rather than the usual "gtest/gtest.h".
168 "external/googletest/googletest/include/gtest/",
169 ],
170 shared_libs: ["libz"],
171 host_supported: true,
172 test_suites: ["device-tests"],
173}
174
xNombre29e632f2020-07-03 18:46:49 +0200175// This module is defined in development/ndk/Android.bp. Updating these headers
176// to be usable for any API level is going to be some work (at the very least,
177// there's a ZLIB_VERNUM that will need to be handled since early versions of
178// Android did not have all the APIs that calling code will use if this is set
179// to the current value.
180//
181// The NDK never updated the zlib headers when the platform updated, so until we
182// solve this the NDK will continue shipping the old headers.
183//
184// ndk_headers {
185// name: "libz_headers",
186// from: "src",
187// to: "",
188// srcs: [
189// "src/zconf.h",
190// "src/zlib.h",
191// ],
192// license: "NOTICE",
193// }
Dan Alberte405a262016-09-15 16:24:19 -0700194
195ndk_library {
Dan Willemsen67ce3272017-04-07 15:34:26 -0700196 name: "libz",
Dan Alberte405a262016-09-15 16:24:19 -0700197 symbol_file: "libz.map.txt",
198 first_version: "9",
Dan Albert40f22ad2017-01-05 15:55:02 -0800199 unversioned_until: "current",
Dan Alberte405a262016-09-15 16:24:19 -0700200}