summaryrefslogtreecommitdiff
path: root/BUILD.gn
diff options
context:
space:
mode:
Diffstat (limited to 'BUILD.gn')
-rw-r--r--BUILD.gn151
1 files changed, 110 insertions, 41 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 2414c88..d64cb38 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -4,6 +4,10 @@
import("//build/config/compiler/compiler.gni")
+if (build_with_chromium) {
+ import("//testing/test.gni")
+}
+
if (current_cpu == "arm" || current_cpu == "arm64") {
import("//build/config/arm.gni")
}
@@ -14,10 +18,36 @@ config("zlib_config") {
config("zlib_internal_config") {
defines = [ "ZLIB_IMPLEMENTATION" ]
+
+ if (!is_debug) {
+ # Build code using -O3, see: crbug.com/1084371.
+ configs = [ "//build/config/compiler:optimize_speed" ]
+ }
+ if (is_debug || use_libfuzzer) {
+ # Enable zlib's asserts in debug and fuzzer builds.
+ defines += [ "ZLIB_DEBUG" ]
+ }
+}
+
+source_set("zlib_common_headers") {
+ sources = [
+ "chromeconf.h",
+ "deflate.h",
+ "inffast.h",
+ "inffixed.h",
+ "inflate.h",
+ "inftrees.h",
+ "zconf.h",
+ "zlib.h",
+ "zutil.h",
+ ]
}
use_arm_neon_optimizations = false
-if (current_cpu == "arm" || current_cpu == "arm64") {
+if ((current_cpu == "arm" || current_cpu == "arm64") &&
+ !(is_win && !is_clang)) {
+ # TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
+ # Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
if (arm_use_neon) {
use_arm_neon_optimizations = true
}
@@ -34,7 +64,9 @@ config("zlib_adler32_simd_config") {
} else {
defines += [ "X86_NOT_WINDOWS" ]
}
- } else if (use_arm_neon_optimizations) {
+ }
+
+ if (use_arm_neon_optimizations) {
defines = [ "ADLER32_SIMD_NEON" ]
}
}
@@ -58,16 +90,13 @@ source_set("zlib_adler32_simd") {
"adler32_simd.c",
"adler32_simd.h",
]
- if (!is_debug) {
- # Use optimize_speed (-O3) to output the _smallest_ code.
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_speed" ]
- }
}
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_adler32_simd_config" ]
+
+ public_deps = [ ":zlib_common_headers" ]
}
if (use_arm_neon_optimizations) {
@@ -81,6 +110,8 @@ if (use_arm_neon_optimizations) {
defines += [ "ARMV8_OS_ANDROID" ]
} else if (is_linux || is_chromeos) {
defines += [ "ARMV8_OS_LINUX" ]
+ } else if (is_mac) {
+ defines += [ "ARMV8_OS_MACOS" ]
} else if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
} else if (is_win) {
@@ -107,16 +138,13 @@ if (use_arm_neon_optimizations) {
"crc32_simd.c",
"crc32_simd.h",
]
-
- if (!is_debug) {
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_speed" ]
- }
}
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_arm_crc32_config" ]
+
+ public_deps = [ ":zlib_common_headers" ]
}
}
@@ -131,6 +159,7 @@ config("zlib_inflate_chunk_simd_config") {
if (use_arm_neon_optimizations) {
defines = [ "INFLATE_CHUNK_SIMD_NEON" ]
+
if (current_cpu == "arm64") {
defines += [ "INFLATE_CHUNK_READ_64LE" ]
}
@@ -149,22 +178,18 @@ source_set("zlib_inflate_chunk_simd") {
"contrib/optimizations/inffast_chunk.h",
"contrib/optimizations/inflate.c",
]
-
- if (use_arm_neon_optimizations && !is_debug) {
- # Here we trade better performance on newer/bigger ARMv8 cores
- # for less perf on ARMv7, per crbug.com/772870#c40
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_speed" ]
- }
}
+ configs += [ ":zlib_internal_config" ]
+
+ # Needed for MSVC, which is still supported by V8 and PDFium. zlib uses K&R C
+ # style function declarations, which triggers warning C4131.
configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":zlib_internal_config",
- "//build/config/compiler:no_chromium_code",
- ]
+ configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":zlib_inflate_chunk_simd_config" ]
+
+ public_deps = [ ":zlib_common_headers" ]
}
config("zlib_crc32_simd_config") {
@@ -193,6 +218,16 @@ source_set("zlib_crc32_simd") {
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_crc32_simd_config" ]
+ public_deps = [ ":zlib_common_headers" ]
+}
+
+config("zlib_x86_simd_config") {
+ if (use_x86_x64_optimizations) {
+ defines = [
+ "CRC32_SIMD_SSE42_PCLMUL",
+ "DEFLATE_FILL_WINDOW_SSE2",
+ ]
+ }
}
source_set("zlib_x86_simd") {
@@ -212,11 +247,11 @@ source_set("zlib_x86_simd") {
}
}
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":zlib_internal_config",
- "//build/config/compiler:no_chromium_code",
- ]
+ configs += [ ":zlib_internal_config" ]
+
+ public_configs = [ ":zlib_x86_simd_config" ]
+
+ public_deps = [ ":zlib_common_headers" ]
}
config("zlib_warnings") {
@@ -265,6 +300,7 @@ component("zlib") {
defines = []
deps = []
+
if (!use_x86_x64_optimizations && !use_arm_neon_optimizations) {
# Apparently android_cronet bot builds with NEON disabled and
# we also should disable optimizations for iOS@x86 (a.k.a. simulator).
@@ -274,8 +310,8 @@ component("zlib") {
if (is_ios) {
# iOS@ARM is a special case where we always have NEON but don't check
# for crypto extensions.
- # TODO(cavalcantii): verify what is the current state of CPU features shipped
- # on latest iOS devices.
+ # TODO(cavalcantii): verify what is the current state of CPU features
+ # shipped on latest iOS devices.
defines += [ "ARM_OS_IOS" ]
}
@@ -295,6 +331,8 @@ component("zlib") {
sources += [ "inflate.c" ]
}
+ deps += [ ":zlib_x86_simd" ]
+
if (is_android) {
import("//build/config/android/config.gni")
if (defined(android_ndk_root) && android_ndk_root != "") {
@@ -305,17 +343,17 @@ component("zlib") {
}
configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [ "//build/config/compiler:no_chromium_code" ]
+
+ public_configs = [ ":zlib_config" ]
+
configs += [
":zlib_internal_config",
- "//build/config/compiler:no_chromium_code",
# Must be after no_chromium_code for warning flags to be ordered correctly.
":zlib_warnings",
]
- public_configs = [ ":zlib_config" ]
-
- deps += [ ":zlib_x86_simd" ]
allow_circular_includes_from = deps
}
@@ -347,7 +385,7 @@ static_library("minizip") {
]
}
- if (is_mac || is_ios || is_android || is_nacl) {
+ if (is_apple || is_android || is_nacl) {
# Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
# use fopen, ftell, and fseek instead on these systems.
defines = [ "USE_FILE32API" ]
@@ -356,28 +394,59 @@ static_library("minizip") {
deps = [ ":zlib" ]
configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- "//build/config/compiler:no_chromium_code",
+ configs += [ "//build/config/compiler:no_chromium_code" ]
+
+ public_configs = [ ":zlib_config" ]
+ configs += [
# Must be after no_chromium_code for warning flags to be ordered correctly.
":minizip_warnings",
]
-
- public_configs = [ ":zlib_config" ]
}
executable("zlib_bench") {
include_dirs = [ "." ]
sources = [ "contrib/bench/zlib_bench.cc" ]
-
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}
+ deps = [ ":zlib" ]
+
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
+}
- deps = [ ":zlib" ]
+if (build_with_chromium) {
+ test("zlib_unittests") {
+ testonly = true
+
+ sources = [
+ "contrib/tests/infcover.cc",
+ "contrib/tests/infcover.h",
+ "contrib/tests/run_all_unittests.cc",
+ "contrib/tests/utils_unittest.cc",
+ "google/compression_utils_unittest.cc",
+ "google/zip_reader_unittest.cc",
+ "google/zip_unittest.cc",
+ ]
+
+ data = [ "google/test/data/" ]
+
+ deps = [
+ ":zlib",
+ "google:compression_utils",
+ "google:zip",
+ "//base/test:test_support",
+ "//testing/gtest",
+ ]
+
+ include_dirs = [
+ "//third_party/googletest/src/googletest/include/gtest",
+ ".",
+ "google",
+ ]
+ }
}