summaryrefslogtreecommitdiff
path: root/Android.bp
diff options
context:
space:
mode:
authorDanny Lin <danny@kdrag0n.dev>2021-04-06 21:39:07 -0700
committeralk3pInjection <webmaster@raspii.tech>2022-05-13 14:58:00 +0800
commit2ca0d0b38b60e8d6d49a8959bf674a79e7d16f41 (patch)
tree0b9a6cb57102589741eaec759a95438f8acd0f5c /Android.bp
parentb56a2fd0b126cfe5f13e68ab9090cd4f6a773286 (diff)
Port zlib-ng to the Android platformHEADsugisawa-mr1
- Add Soong blueprint - Add CRC32 fixes - Add NDK mappings All changes were based on the Android fork of Chromium zlib. Change-Id: Icf0f00d95e1534a0f5683cce40679916a464cc12
Diffstat (limited to 'Android.bp')
-rw-r--r--Android.bp244
1 files changed, 244 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..a8444fb
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,244 @@
+package {
+ default_applicable_licenses: ["external_zlib_license"],
+}
+
+license {
+ name: "external_zlib_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-BSD",
+ "SPDX-license-identifier-Zlib",
+ ],
+ license_text: [
+ "LICENSE.md",
+ ],
+}
+
+srcs_arm = [
+ "arch/arm/adler32_neon.c",
+ "arch/arm/armfeature.c",
+ "arch/arm/chunkset_neon.c",
+ "arch/arm/crc32_acle.c",
+ "arch/arm/insert_string_acle.c",
+ "arch/arm/slide_neon.c",
+]
+
+// Not all CPUs will support these features, but compatibility is checked at runtime.
+cflags_arm = [
+ "-DARM_FEATURES",
+
+ // Runtime compatibility checks
+ "-DARM_AUXV_HAS_CRC32",
+ "-DARM_AUXV_HAS_NEON",
+
+ // Optional fatures
+ "-DARM_ACLE_CRC_HASH",
+ "-DARM_NEON_ADLER32",
+ "-DARM_NEON_CHUNKSET",
+ "-DARM_NEON_SLIDEHASH",
+]
+
+// The *device* x86 configuration (with *higher* CPU feature requirements).
+srcs_android_x86 = [
+ "arch/x86/adler32_avx.c",
+ "arch/x86/adler32_ssse3.c",
+ "arch/x86/chunkset_avx.c",
+ "arch/x86/chunkset_sse.c",
+ "arch/x86/compare258_avx.c",
+ "arch/x86/compare258_sse.c",
+ "arch/x86/crc_folding.c",
+ "arch/x86/insert_string_sse.c",
+ "arch/x86/slide_avx.c",
+ "arch/x86/slide_sse.c",
+ "arch/x86/x86.c",
+]
+cflags_android_x86 = [
+ "-DX86_AVX2",
+ "-DX86_AVX2_ADLER32",
+ "-DX86_AVX_CHUNKSET",
+ "-DX86_FEATURES",
+ "-DX86_PCLMULQDQ_CRC",
+ "-DX86_SSE2",
+ "-DX86_SSE2_CHUNKSET",
+ "-DX86_SSE2_SLIDEHASH",
+ "-DX86_SSE42_CMP_STR",
+ "-DX86_SSE42_CRC_HASH",
+ "-DX86_SSE42_CRC_INTRIN",
+ "-DX86_SSSE3",
+ "-DX86_SSSE3_ADLER32",
+ "-mavx2",
+ "-msse4",
+ "-mssse3",
+ "-mpclmul",
+]
+
+// This optimization is applicable to arm64 and x86-64.
+cflags_64 = ["-DUNALIGNED64_OK"]
+
+libz_srcs = [
+ "adler32.c",
+ "chunkset.c",
+ "compare258.c",
+ "compress.c",
+ "crc32_comb.c",
+ "crc32.c",
+ "deflate_fast.c",
+ "deflate_medium.c",
+ "deflate_quick.c",
+ "deflate_slow.c",
+ "deflate.c",
+ "functable.c",
+ "gzlib.c",
+ "gzread.c",
+ "gzwrite.c",
+ "infback.c",
+ "inffast.c",
+ "inflate.c",
+ "inftrees.c",
+ "insert_string.c",
+ "trees.c",
+ "uncompr.c",
+ "zutil.c",
+]
+
+cflags_common = [
+ "-DHAVE_BUILTIN_CTZ",
+ "-DHAVE_BUILTIN_CTZLL",
+ "-DHAVE_VISIBILITY_HIDDEN",
+ "-DHAVE_VISIBILITY_INTERNAL",
+ "-DZLIB_CONST",
+
+ "-DWITH_GZFILEOP",
+ "-DZLIB_COMPAT",
+ "-DZLIB_DLL",
+ "-D_LARGEFILE64_SOURCE=1",
+ "-D__USE_LARGEFILE64",
+ "-Wall",
+ "-Werror",
+ "-Wno-implicit-fallthrough",
+ "-O3",
+ "-DNDEBUG",
+ "-fno-semantic-interposition",
+ "-std=c99",
+ "-DUNALIGNED_OK",
+]
+
+cc_defaults {
+ name: "libz_defaults",
+
+ cflags: cflags_common,
+ stl: "none",
+ export_include_dirs: ["."],
+ srcs: libz_srcs,
+
+ arch: {
+ arm: {
+ // TODO: This is to work around b/24465209. Remove after root cause
+ // is fixed.
+ pack_relocations: false,
+ ldflags: ["-Wl,--hash-style=both"],
+
+ cflags: cflags_arm,
+ srcs: srcs_arm,
+ },
+ arm64: {
+ cflags: cflags_arm + cflags_64,
+ srcs: srcs_arm,
+ },
+ x86_64: {
+ cflags: cflags_64,
+ },
+ },
+ target: {
+ android_x86: {
+ srcs: srcs_android_x86,
+ cflags: cflags_android_x86,
+ },
+ android_x86_64: {
+ srcs: srcs_android_x86,
+ cflags: cflags_android_x86 + cflags_64,
+ },
+ },
+}
+
+cc_library {
+ name: "libz",
+ defaults: ["libz_defaults"],
+
+ host_supported: true,
+ unique_host_soname: true,
+ static_ndk_lib: true,
+
+ vendor_available: true,
+ product_available: true,
+ vndk: {
+ enabled: true,
+ support_system_process: true,
+ },
+ ramdisk_available: true,
+ vendor_ramdisk_available: true,
+ recovery_available: true,
+ native_bridge_supported: true,
+
+ target: {
+ linux_bionic: {
+ enabled: true,
+ },
+ windows: {
+ enabled: true,
+ },
+ },
+
+ stubs: {
+ versions: [
+ "29",
+ "30",
+ ],
+ symbol_file: "libz.map.txt",
+ },
+}
+
+// A more stable build of libz. Build configuration of this library should be
+// the same for different targets. This is only used by imgdiff.
+
+cc_library {
+ name: "libz_stable",
+ visibility: [
+ "//bootable/recovery/applypatch",
+ "//bootable/recovery/tests",
+ ],
+ cflags: cflags_common,
+ stl: "none",
+ export_include_dirs: ["."],
+ srcs: libz_srcs,
+
+ host_supported: true,
+ vendor_available: true,
+ recovery_available: true,
+}
+
+cc_binary_host {
+ name: "minigzip",
+ srcs: ["test/minigzip.c"],
+ cflags: cflags_common,
+ static_libs: ["libz"],
+ stl: "none",
+}
+
+ndk_headers {
+ name: "libz_headers",
+ from: "",
+ to: "",
+ srcs: [
+ "zconf.h",
+ "zlib.h",
+ ],
+ license: "LICENSE.md",
+}
+
+ndk_library {
+ name: "libz",
+ symbol_file: "libz.map.txt",
+ first_version: "9",
+ unversioned_until: "current",
+}