Bob Badour | 3f2566f | 2021-02-11 17:09:40 -0800 | [diff] [blame] | 1 | package { |
| 2 | default_applicable_licenses: ["external_zlib_license"], |
| 3 | } |
| 4 | |
| 5 | license { |
| 6 | name: "external_zlib_license", |
| 7 | visibility: [":__subpackages__"], |
| 8 | license_kinds: [ |
| 9 | "SPDX-license-identifier-BSD", |
| 10 | "SPDX-license-identifier-Zlib", |
| 11 | ], |
| 12 | license_text: [ |
| 13 | "LICENSE", |
| 14 | ], |
| 15 | } |
| 16 | |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 17 | srcs_opt = [ |
| 18 | "adler32_simd.c", |
| 19 | // See https://chromium-review.googlesource.com/749732. |
| 20 | // TODO: causes `atest org.apache.harmony.tests.java.util.zip.DeflaterTest` failures. |
| 21 | // "contrib/optimizations/inffast_chunk.c", |
| 22 | // "contrib/optimizations/inflate.c", |
| 23 | // This file doesn't build for non-neon, so it can't be in the main srcs. |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 24 | "crc32_simd.c", |
| 25 | ] |
| 26 | |
| 27 | cflags_arm = [ |
| 28 | // Since we're building for the platform, we claim to be Linux rather than |
| 29 | // Android so we use getauxval() directly instead of the NDK |
| 30 | // android_getCpuFeatures which isn't available to us anyway. |
| 31 | "-DARMV8_OS_LINUX", |
| 32 | // Testing with zlib_bench shows -O3 is a win for ARM but a bit of a wash |
| 33 | // for x86, so match the BUILD file in only enabling this for ARM. |
| 34 | "-O3", |
Elliott Hughes | 784a86b | 2020-12-07 12:43:35 -0800 | [diff] [blame] | 35 | // We need a non-NEON libz.a for the NDK, and cpu_features.c won't build |
| 36 | // without this. |
| 37 | "-DCPU_NO_SIMD", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 38 | ] |
| 39 | cflags_arm_neon = [ |
Elliott Hughes | 784a86b | 2020-12-07 12:43:35 -0800 | [diff] [blame] | 40 | // Undo the -DCPU_NO_SIMD from the generic (non-NEON) ARM flags. |
| 41 | "-UCPU_NO_SIMD", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 42 | // We no longer support non-Neon platform builds, but the NDK just has one libz. |
| 43 | "-DADLER32_SIMD_NEON", |
| 44 | // TODO: causes `atest org.apache.harmony.tests.java.util.zip.DeflaterTest` failures. |
| 45 | // "-DINFLATE_CHUNK_SIMD_NEON", |
| 46 | // HWCAP_CRC32 is checked at runtime, so it's okay to turn crc32 |
| 47 | // acceleration on for both 32- and 64-bit. |
| 48 | "-DCRC32_ARMV8_CRC32", |
| 49 | ] |
| 50 | cflags_arm64 = cflags_arm + cflags_arm_neon |
| 51 | |
Elliott Hughes | 8472b6c | 2021-01-06 14:52:46 -0800 | [diff] [blame] | 52 | // The *host* x86 configuration (with *lower* CPU feature requirements). |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 53 | cflags_x86 = [ |
| 54 | // See ARMV8_OS_LINUX above. |
| 55 | "-DX86_NOT_WINDOWS", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 56 | // TODO: see arm above. |
| 57 | // "-DINFLATE_CHUNK_SIMD_SSE2", |
Elliott Hughes | 8472b6c | 2021-01-06 14:52:46 -0800 | [diff] [blame] | 58 | // Android's host CPU feature requirements are *lower* than the |
| 59 | // corresponding device CPU feature requirements, so it's easier to just |
| 60 | // say "no SIMD for you" rather than specificially disable SSSE3. |
| 61 | // We should have a conversation about that, but not until we at least have |
| 62 | // data on how many Studio users have CPUs that don't make the grade... |
| 63 | // https://issuetracker.google.com/171235570 |
| 64 | "-DCPU_NO_SIMD", |
| 65 | ] |
| 66 | // The *device* x86 configuration (with *higher* CPU feature requirements). |
| 67 | cflags_android_x86 = [ |
| 68 | // Android's x86/x86-64 ABI includes SSE2 and SSSE3. |
| 69 | "-UCPU_NO_SIMD", |
| 70 | "-DADLER32_SIMD_SSSE3", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 71 | // PCLMUL isn't in the ABI, but it won't actually be used unless CPUID |
| 72 | // reports that the processor really does have the instruction. |
| 73 | "-mpclmul", |
| 74 | "-DCRC32_SIMD_SSE42_PCLMUL", |
| 75 | ] |
| 76 | srcs_x86 = [ |
| 77 | "crc_folding.c", |
| 78 | "fill_window_sse.c", |
| 79 | ] + srcs_opt |
| 80 | |
| 81 | // This optimization is applicable to arm64 and x86-64. |
| 82 | cflags_64 = ["-DINFLATE_CHUNK_READ_64LE"] |
| 83 | |
Kelvin Zhang | e6a6dbd | 2021-01-12 14:54:06 -0500 | [diff] [blame] | 84 | libz_srcs = [ |
| 85 | "adler32.c", |
| 86 | "compress.c", |
| 87 | "cpu_features.c", |
| 88 | "crc32.c", |
| 89 | "deflate.c", |
| 90 | "gzclose.c", |
| 91 | "gzlib.c", |
| 92 | "gzread.c", |
| 93 | "gzwrite.c", |
| 94 | "infback.c", |
| 95 | "inffast.c", |
| 96 | "inflate.c", |
| 97 | "inftrees.c", |
| 98 | "trees.c", |
| 99 | "uncompr.c", |
| 100 | "zutil.c", |
| 101 | ] |
| 102 | |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 103 | cc_defaults { |
| 104 | name: "libz_defaults", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 105 | |
| 106 | cflags: [ |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 107 | // We do support hidden visibility, so turn that on. |
Elliott Hughes | 35329cd | 2019-04-10 14:56:06 -0700 | [diff] [blame] | 108 | "-DHAVE_HIDDEN", |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 109 | // We do support const, so turn that on. |
Tao Bao | 5604dec | 2016-12-19 13:29:53 -0800 | [diff] [blame] | 110 | "-DZLIB_CONST", |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 111 | "-Wall", |
| 112 | "-Werror", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 113 | "-Wno-unused", |
| 114 | "-Wno-unused-parameter", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 115 | ], |
| 116 | stl: "none", |
| 117 | export_include_dirs: ["."], |
Kelvin Zhang | e6a6dbd | 2021-01-12 14:54:06 -0500 | [diff] [blame] | 118 | srcs: libz_srcs, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 119 | |
| 120 | arch: { |
| 121 | arm: { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 122 | // TODO: This is to work around b/24465209. Remove after root cause |
| 123 | // is fixed. |
Chih-Hung Hsieh | 19b536b | 2018-05-23 18:52:18 -0700 | [diff] [blame] | 124 | pack_relocations: false, |
Ian Pedowitz | cca7bd4 | 2018-01-18 16:22:54 -0800 | [diff] [blame] | 125 | ldflags: ["-Wl,--hash-style=both"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 126 | |
| 127 | cflags: cflags_arm, |
| 128 | neon: { |
| 129 | cflags: cflags_arm_neon, |
| 130 | srcs: srcs_opt, |
| 131 | } |
| 132 | }, |
| 133 | arm64: { |
| 134 | cflags: cflags_arm64 + cflags_64, |
| 135 | srcs: srcs_opt, |
| 136 | }, |
| 137 | x86: { |
| 138 | cflags: cflags_x86, |
| 139 | srcs: srcs_x86, |
| 140 | }, |
| 141 | x86_64: { |
| 142 | cflags: cflags_x86 + cflags_64, |
| 143 | srcs: srcs_x86, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 144 | }, |
| 145 | }, |
Elliott Hughes | 8472b6c | 2021-01-06 14:52:46 -0800 | [diff] [blame] | 146 | target: { |
| 147 | android_x86: { |
| 148 | cflags: cflags_android_x86, |
| 149 | }, |
| 150 | android_x86_64: { |
| 151 | cflags: cflags_android_x86, |
| 152 | }, |
| 153 | }, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | cc_library { |
| 157 | name: "libz", |
| 158 | defaults: ["libz_defaults"], |
| 159 | |
| 160 | host_supported: true, |
| 161 | unique_host_soname: true, |
| 162 | static_ndk_lib: true, |
| 163 | |
| 164 | vendor_available: true, |
Justin Yun | e66fac5 | 2020-11-11 18:26:47 +0900 | [diff] [blame] | 165 | product_available: true, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 166 | vndk: { |
| 167 | enabled: true, |
| 168 | support_system_process: true, |
| 169 | }, |
Yifan Hong | d4b6e52 | 2020-01-21 19:28:33 -0800 | [diff] [blame] | 170 | ramdisk_available: true, |
Yifan Hong | c777f20 | 2020-10-21 18:44:36 -0700 | [diff] [blame] | 171 | vendor_ramdisk_available: true, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 172 | recovery_available: true, |
| 173 | native_bridge_supported: true, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 174 | |
| 175 | target: { |
Dan Willemsen | 0bb579c | 2016-11-04 12:27:30 -0700 | [diff] [blame] | 176 | linux_bionic: { |
| 177 | enabled: true, |
| 178 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 179 | windows: { |
| 180 | enabled: true, |
| 181 | }, |
| 182 | }, |
Jiyong Park | d8ff0c7 | 2020-05-18 09:30:14 +0000 | [diff] [blame] | 183 | |
| 184 | stubs: { |
| 185 | versions: [ |
| 186 | "29", |
| 187 | "30", |
| 188 | ], |
| 189 | symbol_file: "libz.map.txt", |
| 190 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Kelvin Zhang | e6a6dbd | 2021-01-12 14:54:06 -0500 | [diff] [blame] | 193 | // A more stable build of libz. Build configuration of this library should be |
| 194 | // the same for different targets. This is only used by imgdiff. |
| 195 | |
| 196 | cc_library { |
| 197 | name: "libz_stable", |
| 198 | visibility: [ |
| 199 | "//bootable/recovery/applypatch", |
| 200 | "//bootable/recovery/tests", |
| 201 | ], |
| 202 | cflags: [ |
| 203 | // We do support hidden visibility, so turn that on. |
| 204 | "-DHAVE_HIDDEN", |
| 205 | // We do support const, so turn that on. |
| 206 | "-DZLIB_CONST", |
| 207 | "-Wall", |
| 208 | "-Werror", |
| 209 | "-Wno-unused", |
| 210 | "-Wno-unused-parameter", |
| 211 | ], |
| 212 | stl: "none", |
| 213 | export_include_dirs: ["."], |
| 214 | srcs: libz_srcs, |
| 215 | |
| 216 | host_supported: true, |
| 217 | vendor_available: true, |
| 218 | recovery_available: true, |
| 219 | } |
| 220 | |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 221 | cc_binary_host { |
| 222 | name: "minigzip", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 223 | srcs: ["contrib/minigzip/minigzip.c"], |
| 224 | cflags: ["-Wall", "-Werror", "-DUSE_MMAP"], |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 225 | static_libs: ["libz"], |
| 226 | stl: "none", |
| 227 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 228 | |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 229 | cc_binary { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 230 | name: "zlib_bench", |
| 231 | srcs: ["contrib/bench/zlib_bench.cc"], |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 232 | cflags: ["-Wall", "-Werror"], |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 233 | host_supported: true, |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 234 | shared_libs: ["libz"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 235 | // We build zlib_bench32 and zlib_bench64 so it's easy to test LP32. |
| 236 | compile_multilib: "both", |
| 237 | multilib: { |
| 238 | lib32: { suffix: "32", }, |
| 239 | lib64: { suffix: "64", }, |
| 240 | }, |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 241 | } |
| 242 | |
Elliott Hughes | 822a4b8 | 2020-06-17 09:01:27 -0700 | [diff] [blame] | 243 | cc_test { |
| 244 | name: "zlib_tests", |
| 245 | srcs: [ |
| 246 | "contrib/tests/infcover.cc", |
| 247 | "contrib/tests/utils_unittest.cc", |
| 248 | "google/compression_utils_portable.cc", |
| 249 | ], |
| 250 | include_dirs: [ |
| 251 | "external/zlib/google", |
| 252 | // These tests include "gtest.h" rather than the usual "gtest/gtest.h". |
| 253 | "external/googletest/googletest/include/gtest/", |
| 254 | ], |
| 255 | shared_libs: ["libz"], |
| 256 | host_supported: true, |
| 257 | test_suites: ["device-tests"], |
| 258 | } |
| 259 | |
Elliott Hughes | 58b328a | 2020-05-01 15:46:14 -0700 | [diff] [blame] | 260 | ndk_headers { |
| 261 | name: "libz_headers", |
| 262 | from: "", |
| 263 | to: "", |
| 264 | srcs: [ |
| 265 | "zconf.h", |
| 266 | "zlib.h", |
| 267 | ], |
| 268 | license: "LICENSE", |
| 269 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 270 | |
| 271 | ndk_library { |
Dan Willemsen | 67ce327 | 2017-04-07 15:34:26 -0700 | [diff] [blame] | 272 | name: "libz", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 273 | symbol_file: "libz.map.txt", |
| 274 | first_version: "9", |
Dan Albert | 40f22ad | 2017-01-05 15:55:02 -0800 | [diff] [blame] | 275 | unversioned_until: "current", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 276 | } |