401 lines
9.9 KiB
Plaintext
401 lines
9.9 KiB
Plaintext
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",
|
|
],
|
|
}
|
|
|
|
cflags_arm = [
|
|
// Testing with zlib_bench shows -O3 is a win for ARM but a bit of a wash
|
|
// for x86, so match the BUILD file in only enabling this for ARM.
|
|
"-O3",
|
|
// We no longer support non-Neon platform builds, but the NDK just has one libz.
|
|
"-DADLER32_SIMD_NEON",
|
|
// TODO: causes `atest org.apache.harmony.tests.java.util.zip.DeflaterTest` failures.
|
|
// "-DINFLATE_CHUNK_SIMD_NEON",
|
|
// HWCAP_CRC32 is checked at runtime, so it's okay to turn crc32
|
|
// acceleration on for both 32- and 64-bit.
|
|
"-DCRC32_ARMV8_CRC32",
|
|
]
|
|
cflags_arm64 = cflags_arm
|
|
|
|
// The *host* x86 configuration (with *lower* CPU feature requirements).
|
|
cflags_x86 = [
|
|
// See ARMV8_OS_LINUX above.
|
|
"-DX86_NOT_WINDOWS",
|
|
// TODO: see arm above.
|
|
// "-DINFLATE_CHUNK_SIMD_SSE2",
|
|
// Android's host CPU feature requirements are *lower* than the
|
|
// corresponding device CPU feature requirements, so it's easier to just
|
|
// say "no SIMD for you" rather than specificially disable SSSE3.
|
|
// We should have a conversation about that, but not until we at least have
|
|
// data on how many Studio users have CPUs that don't make the grade...
|
|
// https://issuetracker.google.com/171235570
|
|
"-DCPU_NO_SIMD",
|
|
]
|
|
// The *device* x86 configuration (with *higher* CPU feature requirements).
|
|
cflags_android_x86 = [
|
|
// Android's x86/x86-64 ABI includes SSE2 and SSSE3.
|
|
"-UCPU_NO_SIMD",
|
|
"-DADLER32_SIMD_SSSE3",
|
|
]
|
|
|
|
// This optimization is applicable to arm64 and x86-64.
|
|
cflags_64 = ["-DINFLATE_CHUNK_READ_64LE"]
|
|
|
|
libz_srcs = [
|
|
"adler32.c",
|
|
"adler32_simd.c",
|
|
"compress.c",
|
|
"cpu_features.c",
|
|
"crc32.c",
|
|
"crc32_simd.c",
|
|
"crc_folding.c",
|
|
"deflate.c",
|
|
"gzclose.c",
|
|
"gzlib.c",
|
|
"gzread.c",
|
|
"gzwrite.c",
|
|
"infback.c",
|
|
"inffast.c",
|
|
"inflate.c",
|
|
"inftrees.c",
|
|
"trees.c",
|
|
"uncompr.c",
|
|
"zutil.c",
|
|
|
|
// Not-yet-enabled optimizations.
|
|
// See https://chromium-review.googlesource.com/749732.
|
|
// TODO: causes `atest org.apache.harmony.tests.java.util.zip.DeflaterTest` failures.
|
|
// "contrib/optimizations/inffast_chunk.c",
|
|
// "contrib/optimizations/inflate.c",
|
|
]
|
|
|
|
cc_defaults {
|
|
name: "libz_defaults",
|
|
|
|
cflags: [
|
|
// We do support hidden visibility, so turn that on.
|
|
"-DHAVE_HIDDEN",
|
|
// We do support const, so turn that on.
|
|
"-DZLIB_CONST",
|
|
// Enable -O3 as per chromium.
|
|
"-O3",
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-deprecated-non-prototype",
|
|
"-Wno-unused",
|
|
"-Wno-unused-parameter",
|
|
],
|
|
stl: "none",
|
|
export_include_dirs: ["."],
|
|
|
|
host_supported: true,
|
|
native_bridge_supported: true,
|
|
|
|
vendor_available: true,
|
|
product_available: true,
|
|
ramdisk_available: true,
|
|
vendor_ramdisk_available: true,
|
|
recovery_available: true,
|
|
|
|
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,
|
|
},
|
|
arm64: {
|
|
cflags: cflags_arm64 + cflags_64,
|
|
},
|
|
x86: {
|
|
cflags: cflags_x86,
|
|
},
|
|
x86_64: {
|
|
cflags: cflags_x86 + cflags_64,
|
|
},
|
|
},
|
|
target: {
|
|
android_arm: {
|
|
cflags: [
|
|
// Since we're building for the platform, we claim to be Linux rather than
|
|
// Android so we use getauxval() directly instead of the NDK
|
|
// android_getCpuFeatures which isn't available to us anyway.
|
|
"-DARMV8_OS_LINUX",
|
|
],
|
|
},
|
|
android_x86: {
|
|
cflags: cflags_android_x86,
|
|
},
|
|
android_x86_64: {
|
|
cflags: cflags_android_x86,
|
|
},
|
|
darwin_arm64: {
|
|
cflags: [
|
|
"-DARMV8_OS_MACOS",
|
|
],
|
|
},
|
|
linux_bionic: {
|
|
enabled: true,
|
|
},
|
|
linux_arm64: {
|
|
cflags: [
|
|
// Since we're building for the platform, we claim to be Linux rather than
|
|
// Android so we use getauxval() directly instead of the NDK
|
|
// android_getCpuFeatures which isn't available to us anyway.
|
|
"-DARMV8_OS_LINUX",
|
|
],
|
|
},
|
|
windows: {
|
|
enabled: true,
|
|
},
|
|
},
|
|
}
|
|
|
|
cc_library {
|
|
name: "libz",
|
|
defaults: ["libz_defaults"],
|
|
|
|
whole_static_libs: ["libz_static"],
|
|
|
|
unique_host_soname: true,
|
|
static_ndk_lib: true,
|
|
|
|
vndk: {
|
|
enabled: true,
|
|
support_system_process: true,
|
|
},
|
|
|
|
stubs: {
|
|
versions: [
|
|
"29",
|
|
"30",
|
|
],
|
|
symbol_file: "libz.map.txt",
|
|
},
|
|
}
|
|
|
|
cc_library {
|
|
name: "libz_static",
|
|
defaults: ["libz_defaults"],
|
|
visibility: ["//external/angle"],
|
|
|
|
srcs: libz_srcs,
|
|
|
|
sdk_version: "minimum",
|
|
|
|
apex_available: [
|
|
"com.android.runtime",
|
|
"//apex_available:platform",
|
|
],
|
|
}
|
|
|
|
// 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: [
|
|
// We do support hidden visibility, so turn that on.
|
|
"-DHAVE_HIDDEN",
|
|
// We do support const, so turn that on.
|
|
"-DZLIB_CONST",
|
|
// Enable -O3 as per chromium
|
|
"-O3",
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-deprecated-non-prototype",
|
|
"-Wno-unused",
|
|
"-Wno-unused-parameter",
|
|
],
|
|
stl: "none",
|
|
export_include_dirs: ["."],
|
|
srcs: libz_srcs,
|
|
|
|
host_supported: true,
|
|
vendor_available: true,
|
|
recovery_available: true,
|
|
}
|
|
|
|
cc_binary_host {
|
|
name: "minigzip",
|
|
srcs: ["contrib/minigzip/minigzip.c"],
|
|
cflags: [
|
|
"-Wall",
|
|
"-Werror",
|
|
"-DUSE_MMAP",
|
|
"-Wno-deprecated-non-prototype",
|
|
],
|
|
static_libs: ["libz"],
|
|
stl: "none",
|
|
}
|
|
|
|
cc_binary {
|
|
name: "zlib_bench",
|
|
srcs: ["contrib/bench/zlib_bench.cc"],
|
|
cflags: [
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-deprecated-non-prototype",
|
|
"-Wno-unused-parameter",
|
|
],
|
|
host_supported: true,
|
|
shared_libs: ["libz"],
|
|
// We build zlib_bench32 and zlib_bench64 so it's easy to test LP32.
|
|
compile_multilib: "both",
|
|
multilib: {
|
|
lib32: {
|
|
suffix: "32",
|
|
},
|
|
lib64: {
|
|
suffix: "64",
|
|
},
|
|
},
|
|
}
|
|
|
|
cc_library {
|
|
name: "zlib_google_compression_utils_portable",
|
|
defaults: ["libz_defaults"],
|
|
srcs: [
|
|
"google/compression_utils_portable.cc",
|
|
],
|
|
export_include_dirs: ["google"],
|
|
host_supported: true,
|
|
shared_libs: ["libz"],
|
|
sdk_version: "minimum",
|
|
visibility: ["//external/angle"],
|
|
apex_available: [
|
|
"com.android.runtime",
|
|
"//apex_available:platform",
|
|
],
|
|
}
|
|
|
|
cc_test {
|
|
name: "zlib_tests",
|
|
srcs: [
|
|
"contrib/tests/infcover.cc",
|
|
"contrib/tests/utils_unittest.cc",
|
|
],
|
|
cflags: [
|
|
"-Wno-unused-parameter",
|
|
],
|
|
include_dirs: [
|
|
// These tests include "gtest.h" rather than the usual "gtest/gtest.h".
|
|
"external/googletest/googletest/include/gtest/",
|
|
],
|
|
shared_libs: ["libz"],
|
|
static_libs: ["zlib_google_compression_utils_portable"],
|
|
host_supported: true,
|
|
test_suites: ["device-tests"],
|
|
}
|
|
|
|
ndk_headers {
|
|
name: "libz_headers",
|
|
from: "",
|
|
to: "",
|
|
srcs: [
|
|
"zconf.h",
|
|
"zlib.h",
|
|
],
|
|
license: "LICENSE",
|
|
}
|
|
|
|
ndk_library {
|
|
name: "libz",
|
|
symbol_file: "libz.map.txt",
|
|
first_version: "9",
|
|
unversioned_until: "current",
|
|
export_header_libs: [
|
|
"libz_headers",
|
|
],
|
|
}
|
|
|
|
// Export zlib headers for inclusion in the musl sysroot.
|
|
genrule {
|
|
name: "libc_musl_sysroot_zlib_headers",
|
|
visibility: ["//external/musl"],
|
|
srcs: [
|
|
"LICENSE",
|
|
"zconf.h",
|
|
"zlib.h",
|
|
],
|
|
out: ["libc_musl_sysroot_zlib_headers.zip"],
|
|
tools: [
|
|
"soong_zip",
|
|
"zip2zip",
|
|
],
|
|
cmd: "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
|
|
// NOTICE
|
|
" -j -f $(location LICENSE) " +
|
|
// headers
|
|
" -j -P include " +
|
|
" -f $(location zconf.h) " +
|
|
" -f $(location zlib.h) " +
|
|
" && " +
|
|
"$(location zip2zip) -i $(genDir)/sysroot.zip -o $(out) " +
|
|
" include/**/*:include " +
|
|
" LICENSE:NOTICE.zlib",
|
|
}
|
|
|
|
cc_defaults {
|
|
name: "zlib_fuzz_defaults",
|
|
static_libs: ["libz"],
|
|
host_supported: true,
|
|
}
|
|
|
|
cc_fuzz {
|
|
name: "zlib_deflate_fuzzer",
|
|
defaults: ["zlib_fuzz_defaults"],
|
|
srcs: ["contrib/tests/fuzzers/deflate_fuzzer.cc"],
|
|
}
|
|
|
|
cc_fuzz {
|
|
name: "zlib_deflate_set_dictionary_fuzzer",
|
|
defaults: ["zlib_fuzz_defaults"],
|
|
srcs: ["contrib/tests/fuzzers/deflate_set_dictionary_fuzzer.cc"],
|
|
}
|
|
|
|
cc_fuzz {
|
|
name: "zlib_inflate_fuzzer",
|
|
defaults: ["zlib_fuzz_defaults"],
|
|
srcs: ["contrib/tests/fuzzers/inflate_fuzzer.cc"],
|
|
}
|
|
|
|
cc_fuzz {
|
|
name: "zlib_inflate_with_header_fuzzer",
|
|
defaults: ["zlib_fuzz_defaults"],
|
|
srcs: ["contrib/tests/fuzzers/inflate_with_header_fuzzer.cc"],
|
|
enabled: false, // TODO: fix the third_party/zlib #include
|
|
}
|
|
|
|
cc_fuzz {
|
|
name: "zlib_streaming_inflate_fuzzer",
|
|
defaults: ["zlib_fuzz_defaults"],
|
|
srcs: ["contrib/tests/fuzzers/streaming_inflate_fuzzer.cc"],
|
|
fuzz_config: {
|
|
libfuzzer_options: ["max_len=256000"],
|
|
}
|
|
}
|
|
|
|
cc_fuzz {
|
|
name: "zlib_uncompress_fuzzer",
|
|
defaults: ["zlib_fuzz_defaults"],
|
|
srcs: ["contrib/tests/fuzzers/uncompress_fuzzer.cc"],
|
|
}
|