skia2/third_party/zlib/BUILD.gn

209 lines
5.8 KiB
Plaintext
Raw Normal View History

# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
declare_args() {
Strengthen is_official_build, update docs. This makes is_official_build turn off all development targets and features in Skia, including building third-party dependencies from source. This will intentionally break some external users, who will find themselves no longer able to find third-party headers or link against third-party libraries. These users have been building with our testing third-party dependencies unknowingly. They'll need to either explicitly turn back on building each dependency from source (skia_use_system_foo=false) or disable that dependency entirely (skia_use_foo=false). is_skia_standalone is now basically !is_official_build, so I've propagated that through, removing is_skia_standalone. In a few places we were using it as a stand-in for defined(ndk), so I've just written defined(ndk) there. Duh. gn_to_bp: is_offical_build's new strength also makes gn_to_bp.py simpler to write. In spirit, Android builds are official Skia builds that also build DM and nanobench. It seems that SkJumper (src/jumper/*) is (unintentionally) enabled on Android. Switching to an is_official_build would have disabled that. But as that accidental launch seems to have gone fine, I've kept it explicitly enabled. In the end, no changes to Android.bp or its SkUserConfig.h. The -Mini builder no longer needs to explicitly disable tools. CQ_INCLUDE_TRYBOTS=skia.primary:Build-Ubuntu-Clang-x86_64-Release-Mini Change-Id: Id06e53268a5caf55c6046ada354a0863c3031c73 Reviewed-on: https://skia-review.googlesource.com/9190 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-03-03 14:21:30 +00:00
skia_use_system_zlib = is_official_build
}
import("../third_party.gni")
if (skia_use_system_zlib) {
system("zlib") {
libs = [ "z" ]
}
} else {
# ARM optimizations disabled for Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
use_arm_neon_optimizations =
(current_cpu == "arm" || current_cpu == "arm64") && !(is_win && !is_clang)
use_x86_x64_optimizations =
(current_cpu == "x86" || current_cpu == "x64") && !is_ios
config("zlib_simd_config") {
defines = []
if (use_x86_x64_optimizations) {
if (is_win) {
defines += [ "X86_WINDOWS" ]
} else {
defines += [ "X86_NOT_WINDOWS" ]
}
defines += [ "ADLER32_SIMD_SSSE3" ] # Strangely this is needed for
# cpu_features.c
}
if (use_arm_neon_optimizations) {
if (is_android) {
defines += [ "ARMV8_OS_ANDROID" ] # also compatible with v7
} else if (is_linux || is_chromeos) {
defines += [ "ARMV8_OS_LINUX" ]
} else if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
} else if (is_win) {
defines += [ "ARMV8_OS_WINDOWS" ]
} else if (is_ios || is_mac) {
# iOS@ARM is a special case where we always have NEON but don't check
# for crypto extensions.
defines += [ "ARM_OS_IOS" ]
} else {
assert(false, "Unsupported ARM OS")
}
}
# Warnings are just noise if we're not maintaining the code.
if (is_win) {
cflags = [ "/w" ]
} else {
cflags = [ "-w" ]
}
}
source_set("zlib_adler32_simd") {
visibility = [ ":*" ]
configs += [ ":zlib_simd_config" ]
if (use_x86_x64_optimizations) {
defines = [ "ADLER32_SIMD_SSSE3" ]
if (!is_win || is_clang) {
cflags = [ "-mssse3" ]
}
}
if (use_arm_neon_optimizations) {
defines = [ "ADLER32_SIMD_NEON" ]
}
sources = [ "../externals/zlib/adler32_simd.c" ]
}
source_set("zlib_crc32_simd") {
visibility = [ ":*" ]
configs += [ ":zlib_simd_config" ]
# Disabled for iPhone, as described in DDI0487C_a_armv8_arm:
# "All implementations of the ARMv8.1 architecture are required to
# implement the CRC32* instructions. These are optional in ARMv8.0."
if (!is_ios && use_arm_neon_optimizations) {
defines = [ "CRC32_ARMV8_CRC32" ]
# An ARMv7 GCC build will fail to compile without building this target
# for ARMv8-a+crc and letting runtime cpu detection select the correct
# function.
if (!is_win && !is_clang) {
cflags_c = [ "-march=armv8-a+crc" ]
}
}
if (use_x86_x64_optimizations) {
defines = [ "CRC32_SIMD_SSE42_PCLMUL" ]
if (!is_win || is_clang) {
cflags = [
"-msse4.2",
"-mpclmul",
]
}
}
sources = [ "../externals/zlib/crc32_simd.c" ]
}
source_set("zlib_inflate_chunk_simd") {
visibility = [ ":*" ]
configs += [ ":zlib_simd_config" ]
if (use_x86_x64_optimizations) {
defines = [ "INFLATE_CHUNK_SIMD_SSE2" ]
if (current_cpu == "x64") {
defines += [ "INFLATE_CHUNK_READ_64LE" ]
}
}
if (use_arm_neon_optimizations) {
defines = [ "INFLATE_CHUNK_SIMD_NEON" ]
if (current_cpu == "arm64") {
defines += [ "INFLATE_CHUNK_READ_64LE" ]
}
}
if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
include_dirs = [
"../externals/zlib/",
"../externals/zlib/contrib/optimizations/",
]
sources = [
"../externals/zlib/contrib/optimizations/inffast_chunk.c",
"../externals/zlib/contrib/optimizations/inflate.c",
]
}
}
source_set("zlib_x86_x64_simd") {
visibility = [ ":*" ]
configs += [ ":zlib_simd_config" ]
if (use_x86_x64_optimizations) {
defines = [
"CRC32_SIMD_SSE42_PCLMUL",
"DEFLATE_FILL_WINDOW_SSE2",
]
if (!is_win || is_clang) {
cflags = [
"-msse4.2",
"-mpclmul",
]
}
sources = [
"../externals/zlib/crc_folding.c",
"../externals/zlib/fill_window_sse.c",
]
}
}
third_party("zlib") {
public_include_dirs = [ "../externals/zlib" ]
defines = [ "ZLIB_IMPLEMENTATION" ]
deps = []
configs = []
sources = [
"../externals/zlib/adler32.c",
"../externals/zlib/compress.c",
"../externals/zlib/cpu_features.c",
"../externals/zlib/crc32.c",
"../externals/zlib/deflate.c",
"../externals/zlib/gzclose.c",
"../externals/zlib/gzlib.c",
"../externals/zlib/gzread.c",
"../externals/zlib/gzwrite.c",
"../externals/zlib/infback.c",
"../externals/zlib/inffast.c",
"../externals/zlib/inftrees.c",
"../externals/zlib/trees.c",
"../externals/zlib/uncompr.c",
"../externals/zlib/zutil.c",
]
if (is_android) {
deps += [ "//third_party/cpu-features" ]
}
if (!use_x86_x64_optimizations && !use_arm_neon_optimizations) {
defines += [ "CPU_NO_SIMD" ]
sources += [ "../externals/zlib/inflate.c" ]
} else {
configs += [ ":zlib_simd_config" ]
deps += [
":zlib_adler32_simd",
":zlib_crc32_simd",
":zlib_inflate_chunk_simd",
":zlib_x86_x64_simd",
]
}
}
}
config("zlib_config") {
}
third_party("compression_utils_portable") {
visibility = [ "//third_party/externals/angle2:*" ]
public_include_dirs = [ "../externals/zlib/google" ]
sources = [
"../externals/zlib/google/compression_utils_portable.cc",
"../externals/zlib/google/compression_utils_portable.h",
]
public_deps = [ ":zlib" ] # either system or from source
}