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 | |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 54 | cc_defaults { |
| 55 | name: "libz_defaults", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 56 | |
| 57 | cflags: [ |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 58 | // We do support hidden visibility, so turn that on. |
Elliott Hughes | 35329cd | 2019-04-10 14:56:06 -0700 | [diff] [blame] | 59 | "-DHAVE_HIDDEN", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 60 | // We do support const, so turn that on. |
Tao Bao | 5604dec | 2016-12-19 13:29:53 -0800 | [diff] [blame] | 61 | "-DZLIB_CONST", |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 62 | "-Wall", |
| 63 | "-Werror", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 64 | "-Wno-unused", |
| 65 | "-Wno-unused-parameter", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 66 | ], |
| 67 | stl: "none", |
| 68 | export_include_dirs: ["."], |
| 69 | srcs: [ |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 70 | "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 Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 79 | "inffast.c", |
Zhen Zhang | fed86a7 | 2020-01-16 20:15:30 +0000 | [diff] [blame] | 80 | "inflate.c", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 81 | "inftrees.c", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 82 | "trees.c", |
| 83 | "uncompr.c", |
| 84 | "zutil.c", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 85 | ], |
| 86 | |
| 87 | arch: { |
| 88 | arm: { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 89 | // TODO: This is to work around b/24465209. Remove after root cause |
| 90 | // is fixed. |
Chih-Hung Hsieh | 19b536b | 2018-05-23 18:52:18 -0700 | [diff] [blame] | 91 | pack_relocations: false, |
Ian Pedowitz | cca7bd4 | 2018-01-18 16:22:54 -0800 | [diff] [blame] | 92 | ldflags: ["-Wl,--hash-style=both"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 93 | |
| 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 Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 111 | }, |
| 112 | }, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | cc_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 Hong | d4b6e52 | 2020-01-21 19:28:33 -0800 | [diff] [blame] | 128 | ramdisk_available: true, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 129 | recovery_available: true, |
| 130 | native_bridge_supported: true, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 131 | |
| 132 | target: { |
Dan Willemsen | 0bb579c | 2016-11-04 12:27:30 -0700 | [diff] [blame] | 133 | linux_bionic: { |
| 134 | enabled: true, |
| 135 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 136 | windows: { |
| 137 | enabled: true, |
| 138 | }, |
| 139 | }, |
Jiyong Park | d8ff0c7 | 2020-05-18 09:30:14 +0000 | [diff] [blame^] | 140 | |
| 141 | stubs: { |
| 142 | versions: [ |
| 143 | "29", |
| 144 | "30", |
| 145 | ], |
| 146 | symbol_file: "libz.map.txt", |
| 147 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 150 | cc_binary_host { |
| 151 | name: "minigzip", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 152 | srcs: ["contrib/minigzip/minigzip.c"], |
| 153 | cflags: ["-Wall", "-Werror", "-DUSE_MMAP"], |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 154 | static_libs: ["libz"], |
| 155 | stl: "none", |
| 156 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 157 | |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 158 | cc_binary { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 159 | name: "zlib_bench", |
| 160 | srcs: ["contrib/bench/zlib_bench.cc"], |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 161 | cflags: ["-Wall", "-Werror"], |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 162 | host_supported: true, |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 163 | shared_libs: ["libz"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 164 | // 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 Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Elliott Hughes | 58b328a | 2020-05-01 15:46:14 -0700 | [diff] [blame] | 172 | ndk_headers { |
| 173 | name: "libz_headers", |
| 174 | from: "", |
| 175 | to: "", |
| 176 | srcs: [ |
| 177 | "zconf.h", |
| 178 | "zlib.h", |
| 179 | ], |
| 180 | license: "LICENSE", |
| 181 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 182 | |
| 183 | ndk_library { |
Dan Willemsen | 67ce327 | 2017-04-07 15:34:26 -0700 | [diff] [blame] | 184 | name: "libz", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 185 | symbol_file: "libz.map.txt", |
| 186 | first_version: "9", |
Dan Albert | 40f22ad | 2017-01-05 15:55:02 -0800 | [diff] [blame] | 187 | unversioned_until: "current", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 188 | } |