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", |
Vishalcj17 | 4edd88d | 2021-05-11 13:46:03 +0700 | [diff] [blame^] | 111 | // Enable -O3 as per chromium. |
| 112 | "-O3", |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 113 | "-Wall", |
| 114 | "-Werror", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 115 | "-Wno-unused", |
| 116 | "-Wno-unused-parameter", |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 117 | ], |
| 118 | stl: "none", |
| 119 | export_include_dirs: ["."], |
Kelvin Zhang | e6a6dbd | 2021-01-12 14:54:06 -0500 | [diff] [blame] | 120 | srcs: libz_srcs, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 121 | |
| 122 | arch: { |
| 123 | arm: { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 124 | // TODO: This is to work around b/24465209. Remove after root cause |
| 125 | // is fixed. |
Chih-Hung Hsieh | 19b536b | 2018-05-23 18:52:18 -0700 | [diff] [blame] | 126 | pack_relocations: false, |
Ian Pedowitz | cca7bd4 | 2018-01-18 16:22:54 -0800 | [diff] [blame] | 127 | ldflags: ["-Wl,--hash-style=both"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 128 | |
| 129 | cflags: cflags_arm, |
| 130 | neon: { |
| 131 | cflags: cflags_arm_neon, |
| 132 | srcs: srcs_opt, |
| 133 | } |
| 134 | }, |
| 135 | arm64: { |
| 136 | cflags: cflags_arm64 + cflags_64, |
| 137 | srcs: srcs_opt, |
| 138 | }, |
| 139 | x86: { |
| 140 | cflags: cflags_x86, |
| 141 | srcs: srcs_x86, |
| 142 | }, |
| 143 | x86_64: { |
| 144 | cflags: cflags_x86 + cflags_64, |
| 145 | srcs: srcs_x86, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 146 | }, |
| 147 | }, |
Elliott Hughes | 8472b6c | 2021-01-06 14:52:46 -0800 | [diff] [blame] | 148 | target: { |
| 149 | android_x86: { |
| 150 | cflags: cflags_android_x86, |
| 151 | }, |
| 152 | android_x86_64: { |
| 153 | cflags: cflags_android_x86, |
| 154 | }, |
| 155 | }, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | cc_library { |
| 159 | name: "libz", |
| 160 | defaults: ["libz_defaults"], |
| 161 | |
| 162 | host_supported: true, |
| 163 | unique_host_soname: true, |
| 164 | static_ndk_lib: true, |
| 165 | |
| 166 | vendor_available: true, |
Justin Yun | e66fac5 | 2020-11-11 18:26:47 +0900 | [diff] [blame] | 167 | product_available: true, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 168 | vndk: { |
| 169 | enabled: true, |
| 170 | support_system_process: true, |
| 171 | }, |
Yifan Hong | d4b6e52 | 2020-01-21 19:28:33 -0800 | [diff] [blame] | 172 | ramdisk_available: true, |
Yifan Hong | c777f20 | 2020-10-21 18:44:36 -0700 | [diff] [blame] | 173 | vendor_ramdisk_available: true, |
Dan Albert | ca7b415 | 2019-06-11 16:32:07 -0700 | [diff] [blame] | 174 | recovery_available: true, |
| 175 | native_bridge_supported: true, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 176 | |
| 177 | target: { |
Dan Willemsen | 0bb579c | 2016-11-04 12:27:30 -0700 | [diff] [blame] | 178 | linux_bionic: { |
| 179 | enabled: true, |
| 180 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 181 | windows: { |
| 182 | enabled: true, |
| 183 | }, |
| 184 | }, |
Jiyong Park | d8ff0c7 | 2020-05-18 09:30:14 +0000 | [diff] [blame] | 185 | |
| 186 | stubs: { |
| 187 | versions: [ |
| 188 | "29", |
| 189 | "30", |
| 190 | ], |
| 191 | symbol_file: "libz.map.txt", |
| 192 | }, |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Kelvin Zhang | e6a6dbd | 2021-01-12 14:54:06 -0500 | [diff] [blame] | 195 | // A more stable build of libz. Build configuration of this library should be |
| 196 | // the same for different targets. This is only used by imgdiff. |
| 197 | |
| 198 | cc_library { |
| 199 | name: "libz_stable", |
| 200 | visibility: [ |
| 201 | "//bootable/recovery/applypatch", |
| 202 | "//bootable/recovery/tests", |
| 203 | ], |
| 204 | cflags: [ |
| 205 | // We do support hidden visibility, so turn that on. |
| 206 | "-DHAVE_HIDDEN", |
| 207 | // We do support const, so turn that on. |
| 208 | "-DZLIB_CONST", |
Vishalcj17 | 4edd88d | 2021-05-11 13:46:03 +0700 | [diff] [blame^] | 209 | // Enable -O3 as per chromium |
| 210 | "-O3", |
Kelvin Zhang | e6a6dbd | 2021-01-12 14:54:06 -0500 | [diff] [blame] | 211 | "-Wall", |
| 212 | "-Werror", |
| 213 | "-Wno-unused", |
| 214 | "-Wno-unused-parameter", |
| 215 | ], |
| 216 | stl: "none", |
| 217 | export_include_dirs: ["."], |
| 218 | srcs: libz_srcs, |
| 219 | |
| 220 | host_supported: true, |
| 221 | vendor_available: true, |
| 222 | recovery_available: true, |
| 223 | } |
| 224 | |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 225 | cc_binary_host { |
| 226 | name: "minigzip", |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 227 | srcs: ["contrib/minigzip/minigzip.c"], |
| 228 | cflags: ["-Wall", "-Werror", "-DUSE_MMAP"], |
Dan Willemsen | c1b393b | 2016-07-06 19:05:32 -0700 | [diff] [blame] | 229 | static_libs: ["libz"], |
| 230 | stl: "none", |
| 231 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 232 | |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 233 | cc_binary { |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 234 | name: "zlib_bench", |
| 235 | srcs: ["contrib/bench/zlib_bench.cc"], |
Chih-Hung Hsieh | 3e5deb4 | 2017-09-29 11:41:33 -0700 | [diff] [blame] | 236 | cflags: ["-Wall", "-Werror"], |
Elliott Hughes | e7091dd | 2019-06-06 12:47:16 -0700 | [diff] [blame] | 237 | host_supported: true, |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 238 | shared_libs: ["libz"], |
Elliott Hughes | ce1c037 | 2020-02-14 00:58:28 +0000 | [diff] [blame] | 239 | // We build zlib_bench32 and zlib_bench64 so it's easy to test LP32. |
| 240 | compile_multilib: "both", |
| 241 | multilib: { |
| 242 | lib32: { suffix: "32", }, |
| 243 | lib64: { suffix: "64", }, |
| 244 | }, |
Narayan Kamath | 1a14eb3 | 2017-01-06 12:49:24 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Elliott Hughes | 822a4b8 | 2020-06-17 09:01:27 -0700 | [diff] [blame] | 247 | cc_test { |
| 248 | name: "zlib_tests", |
| 249 | srcs: [ |
| 250 | "contrib/tests/infcover.cc", |
| 251 | "contrib/tests/utils_unittest.cc", |
| 252 | "google/compression_utils_portable.cc", |
| 253 | ], |
| 254 | include_dirs: [ |
| 255 | "external/zlib/google", |
| 256 | // These tests include "gtest.h" rather than the usual "gtest/gtest.h". |
| 257 | "external/googletest/googletest/include/gtest/", |
| 258 | ], |
| 259 | shared_libs: ["libz"], |
| 260 | host_supported: true, |
| 261 | test_suites: ["device-tests"], |
| 262 | } |
| 263 | |
Elliott Hughes | 58b328a | 2020-05-01 15:46:14 -0700 | [diff] [blame] | 264 | ndk_headers { |
| 265 | name: "libz_headers", |
| 266 | from: "", |
| 267 | to: "", |
| 268 | srcs: [ |
| 269 | "zconf.h", |
| 270 | "zlib.h", |
| 271 | ], |
| 272 | license: "LICENSE", |
| 273 | } |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 274 | |
| 275 | ndk_library { |
Dan Willemsen | 67ce327 | 2017-04-07 15:34:26 -0700 | [diff] [blame] | 276 | name: "libz", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 277 | symbol_file: "libz.map.txt", |
| 278 | first_version: "9", |
Dan Albert | 40f22ad | 2017-01-05 15:55:02 -0800 | [diff] [blame] | 279 | unversioned_until: "current", |
Dan Albert | e405a26 | 2016-09-15 16:24:19 -0700 | [diff] [blame] | 280 | } |