Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 1 | srcs_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 | |
| 12 | cflags_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 | ] |
| 21 | cflags_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 | ] |
| 30 | cflags_arm64 = cflags_arm + cflags_arm_neon |
| 31 | |
| 32 | cflags_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 | ] |
| 46 | srcs_x86 = [ |
| 47 | "crc_folding.c", |
| 48 | "fill_window_sse.c", |
| 49 | ] + srcs_opt |
| 50 | |
| 51 | // This optimization is applicable to arm64 and x86-64. |
| 52 | cflags_64 = ["-DINFLATE_CHUNK_READ_64LE"] |
| 53 | |
xNombre | 0d184e7 | 2020-07-03 18:50:21 +0200 | [diff] [blame] | 54 | cc_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 Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 67 | |
| 68 | cflags: [ |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 69 | // We do support hidden visibility, so turn that on. |
Elliott Hughes | 35329cd | 2019-04-10 14:56:06 -0700 | [diff] [blame] | 70 | "-DHAVE_HIDDEN", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 71 | // We do support const, so turn that on. |
Tao Bao | 5604dec | 2016-12-19 13:29:53 -0800 | [diff] [blame] | 72 | "-DZLIB_CONST", |
Park Ju Hyung | 1517f08 | 2017-05-15 03:44:27 +0900 | [diff] [blame] | 73 | "-DUNALIGNED_OK", |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 74 | "-Wall", |
| 75 | "-Werror", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 76 | "-Wno-unused", |
| 77 | "-Wno-unused-parameter", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 78 | ], |
| 79 | stl: "none", |
| 80 | export_include_dirs: ["."], |
| 81 | srcs: [ |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 82 | "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 Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 91 | "inffast.c", |
Zhen Zhang | fed86a7 | 2020-01-16 20:15:30 +0000 | [diff] [blame] | 92 | "inflate.c", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 93 | "inftrees.c", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 94 | "trees.c", |
| 95 | "uncompr.c", |
| 96 | "zutil.c", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 97 | ], |
| 98 | |
| 99 | arch: { |
| 100 | arm: { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 101 | // TODO: This is to work around b/24465209. Remove after root cause |
| 102 | // is fixed. |
Chih-Hung Hsieh | 19b536b | 2018-05-23 18:52:18 -0700 | [diff] [blame] | 103 | pack_relocations: false, |
Ian Pedowitz | cca7bd4 | 2018-01-18 16:22:54 -0800 | [diff] [blame] | 104 | ldflags: ["-Wl,--hash-style=both"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 105 | |
| 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 Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 123 | }, |
| 124 | }, |
| 125 | |
| 126 | target: { |
Dan Willemsen | 0bb579c | 2016-11-04 12:27:30 -0700 | [diff] [blame] | 127 | linux_bionic: { |
| 128 | enabled: true, |
| 129 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 130 | windows: { |
| 131 | enabled: true, |
| 132 | }, |
| 133 | }, |
| 134 | } |
| 135 | |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 136 | cc_binary_host { |
| 137 | name: "minigzip", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 138 | srcs: ["contrib/minigzip/minigzip.c"], |
| 139 | cflags: ["-Wall", "-Werror", "-DUSE_MMAP"], |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 140 | static_libs: ["libz"], |
| 141 | stl: "none", |
| 142 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 143 | |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 144 | cc_binary { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 145 | name: "zlib_bench", |
| 146 | srcs: ["contrib/bench/zlib_bench.cc"], |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 147 | cflags: ["-Wall", "-Werror"], |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 148 | host_supported: true, |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 149 | shared_libs: ["libz"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 150 | // 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 Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 156 | } |
| 157 | |
Elliott Hughes | 822a4b8 | 2020-06-17 09:01:27 -0700 | [diff] [blame] | 158 | cc_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 | |
xNombre | 29e632f | 2020-07-03 18:46:49 +0200 | [diff] [blame] | 175 | // 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 Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 194 | |
| 195 | ndk_library { |
Dan Willemsen | 67ce327 | 2017-04-07 15:34:26 -0700 | [diff] [blame] | 196 | name: "libz", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 197 | symbol_file: "libz.map.txt", |
| 198 | first_version: "9", |
Dan Albert | 40f22ad | 2017-01-05 15:55:02 -0800 | [diff] [blame] | 199 | unversioned_until: "current", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 200 | } |