blob: 74470f42d8b0dae4a76277be2262758e81ac6892 [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
Dan Albertca7b4152019-06-11 16:32:07 -070054cc_defaults {
55 name: "libz_defaults",
Dan Willemsenc1b393b2016-07-06 19:05:32 -070056
57 cflags: [
Elliott Hughesce1c0372020-02-14 00:58:28 +000058 // We do support hidden visibility, so turn that on.
Elliott Hughes35329cd2019-04-10 14:56:06 -070059 "-DHAVE_HIDDEN",
Elliott Hughesce1c0372020-02-14 00:58:28 +000060 // We do support const, so turn that on.
Tao Bao5604dec2016-12-19 13:29:53 -080061 "-DZLIB_CONST",
Chih-Hung Hsieh3e5deb42017-09-29 11:41:33 -070062 "-Wall",
63 "-Werror",
Elliott Hughese7091dd2019-06-06 12:47:16 -070064 "-Wno-unused",
65 "-Wno-unused-parameter",
Dan Willemsenc1b393b2016-07-06 19:05:32 -070066 ],
67 stl: "none",
68 export_include_dirs: ["."],
69 srcs: [
Elliott Hughese7091dd2019-06-06 12:47:16 -070070 "adler32.c",
71 "compress.c",
72 "crc32.c",
73 "deflate.c",
74 "gzclose.c",
75 "gzlib.c",
76 "gzread.c",
77 "gzwrite.c",
78 "infback.c",
Elliott Hughesce1c0372020-02-14 00:58:28 +000079 "inffast.c",
Zhen Zhangfed86a72020-01-16 20:15:30 +000080 "inflate.c",
Elliott Hughese7091dd2019-06-06 12:47:16 -070081 "inftrees.c",
Elliott Hughese7091dd2019-06-06 12:47:16 -070082 "trees.c",
83 "uncompr.c",
84 "zutil.c",
Dan Willemsenc1b393b2016-07-06 19:05:32 -070085 ],
86
87 arch: {
88 arm: {
Elliott Hughese7091dd2019-06-06 12:47:16 -070089 // TODO: This is to work around b/24465209. Remove after root cause
90 // is fixed.
Chih-Hung Hsieh19b536b2018-05-23 18:52:18 -070091 pack_relocations: false,
Ian Pedowitzcca7bd42018-01-18 16:22:54 -080092 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesce1c0372020-02-14 00:58:28 +000093
94 cflags: cflags_arm,
95 neon: {
96 cflags: cflags_arm_neon,
97 srcs: srcs_opt,
98 }
99 },
100 arm64: {
101 cflags: cflags_arm64 + cflags_64,
102 srcs: srcs_opt,
103 },
104 x86: {
105 cflags: cflags_x86,
106 srcs: srcs_x86,
107 },
108 x86_64: {
109 cflags: cflags_x86 + cflags_64,
110 srcs: srcs_x86,
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700111 },
112 },
Dan Albertca7b4152019-06-11 16:32:07 -0700113}
114
115cc_library {
116 name: "libz",
117 defaults: ["libz_defaults"],
118
119 host_supported: true,
120 unique_host_soname: true,
121 static_ndk_lib: true,
122
123 vendor_available: true,
124 vndk: {
125 enabled: true,
126 support_system_process: true,
127 },
Yifan Hongd4b6e522020-01-21 19:28:33 -0800128 ramdisk_available: true,
Dan Albertca7b4152019-06-11 16:32:07 -0700129 recovery_available: true,
130 native_bridge_supported: true,
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700131
132 target: {
Dan Willemsen0bb579c2016-11-04 12:27:30 -0700133 linux_bionic: {
134 enabled: true,
135 },
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700136 windows: {
137 enabled: true,
138 },
139 },
Jiyong Parkd8ff0c72020-05-18 09:30:14 +0000140
141 stubs: {
142 versions: [
143 "29",
144 "30",
145 ],
146 symbol_file: "libz.map.txt",
147 },
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700148}
149
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700150cc_binary_host {
151 name: "minigzip",
Elliott Hughese7091dd2019-06-06 12:47:16 -0700152 srcs: ["contrib/minigzip/minigzip.c"],
153 cflags: ["-Wall", "-Werror", "-DUSE_MMAP"],
Dan Willemsenc1b393b2016-07-06 19:05:32 -0700154 static_libs: ["libz"],
155 stl: "none",
156}
Dan Alberte405a262016-09-15 16:24:19 -0700157
Narayan Kamath1a14eb32017-01-06 12:49:24 +0000158cc_binary {
Elliott Hughese7091dd2019-06-06 12:47:16 -0700159 name: "zlib_bench",
160 srcs: ["contrib/bench/zlib_bench.cc"],
Chih-Hung Hsieh3e5deb42017-09-29 11:41:33 -0700161 cflags: ["-Wall", "-Werror"],
Elliott Hughese7091dd2019-06-06 12:47:16 -0700162 host_supported: true,
Narayan Kamath1a14eb32017-01-06 12:49:24 +0000163 shared_libs: ["libz"],
Elliott Hughesce1c0372020-02-14 00:58:28 +0000164 // We build zlib_bench32 and zlib_bench64 so it's easy to test LP32.
165 compile_multilib: "both",
166 multilib: {
167 lib32: { suffix: "32", },
168 lib64: { suffix: "64", },
169 },
Narayan Kamath1a14eb32017-01-06 12:49:24 +0000170}
171
Elliott Hughes822a4b82020-06-17 09:01:27 -0700172cc_test {
173 name: "zlib_tests",
174 srcs: [
175 "contrib/tests/infcover.cc",
176 "contrib/tests/utils_unittest.cc",
177 "google/compression_utils_portable.cc",
178 ],
179 include_dirs: [
180 "external/zlib/google",
181 // These tests include "gtest.h" rather than the usual "gtest/gtest.h".
182 "external/googletest/googletest/include/gtest/",
183 ],
184 shared_libs: ["libz"],
185 host_supported: true,
186 test_suites: ["device-tests"],
187}
188
Elliott Hughes58b328a2020-05-01 15:46:14 -0700189ndk_headers {
190 name: "libz_headers",
191 from: "",
192 to: "",
193 srcs: [
194 "zconf.h",
195 "zlib.h",
196 ],
197 license: "LICENSE",
198}
Dan Alberte405a262016-09-15 16:24:19 -0700199
200ndk_library {
Dan Willemsen67ce3272017-04-07 15:34:26 -0700201 name: "libz",
Dan Alberte405a262016-09-15 16:24:19 -0700202 symbol_file: "libz.map.txt",
203 first_version: "9",
Dan Albert40f22ad2017-01-05 15:55:02 -0800204 unversioned_until: "current",
Dan Alberte405a262016-09-15 16:24:19 -0700205}