2016-07-21 19:25:45 +00:00
|
|
|
# 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() {
|
2016-08-26 15:13:04 +00:00
|
|
|
ar = "ar"
|
2016-07-21 19:25:45 +00:00
|
|
|
cc = "cc"
|
|
|
|
cxx = "c++"
|
GN: add extra_cflags et al.
Adding flags to the end of cc or cxx is pretty useful, but these always end up
on the command line before the GN generated flags, thus setting defaults that
GN will override.
For full flexibility we want to be able to add flags after the flags GN has
added, so that custom flags can override _it_.
I've updated the Fast bots with an example here: if we said cc="clang -O3 ...",
that '-O3' would be overriden later by the default Release-mode '-Os'. By
putting it in extra_cflags, we get the last word: our '-O3' overrides the
default '-Os'.
Another good use case is a hypothetical Actually-Shippable-Release mode. Our
Release mode bundles in tons of debug symbols via '-g'. libskia.a is about 10x
larger than it needs to be when built that way, but it helps us debug the bot
failures immensely. To build a libskia.{a,so} that you'd really ship, you can
now set extra_cflags="-g0" to override '-g'. You could set '-march' flags there
too, '-fomit-frame-pointer', etc.
There are lots of flags that won't matter where they end up in the command line.
To keep everything simple I've put them in extra_cflags with the rest. This means
the only time we change 'cc' or 'cxx' in our recipes is to prefix 'ccache'.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2241263003
Review-Url: https://codereview.chromium.org/2241263003
2016-08-16 16:31:16 +00:00
|
|
|
|
2016-08-25 21:50:44 +00:00
|
|
|
if (is_android) {
|
2016-10-24 20:49:15 +00:00
|
|
|
if (host_os == "win") {
|
2016-12-09 15:32:28 +00:00
|
|
|
ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar.exe"
|
|
|
|
cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang.exe"
|
|
|
|
cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++.exe"
|
|
|
|
} else {
|
|
|
|
ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
|
|
|
|
cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
|
|
|
|
cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
|
2016-10-24 20:49:15 +00:00
|
|
|
}
|
2016-08-25 21:50:44 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 20:26:57 +00:00
|
|
|
windk = "C:/Program Files (x86)/Microsoft Visual Studio 14.0"
|
2016-09-16 20:29:57 +00:00
|
|
|
|
2016-10-04 21:09:13 +00:00
|
|
|
extra_cflags = []
|
|
|
|
extra_cflags_c = []
|
|
|
|
extra_cflags_cc = []
|
|
|
|
extra_ldflags = []
|
2016-08-26 20:43:19 +00:00
|
|
|
|
2016-09-20 19:09:12 +00:00
|
|
|
cc_wrapper = ""
|
2016-12-09 00:00:40 +00:00
|
|
|
malloc = ""
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
2016-10-24 20:49:15 +00:00
|
|
|
if (host_os == "win") {
|
|
|
|
python = "python.bat"
|
|
|
|
stamp = "cmd.exe /c echo >"
|
|
|
|
} else {
|
|
|
|
python = "python"
|
|
|
|
stamp = "touch"
|
|
|
|
}
|
|
|
|
|
2016-11-13 15:29:25 +00:00
|
|
|
is_clang = is_android || is_ios || is_mac || (cc == "clang" && cxx == "clang++")
|
|
|
|
if (!is_clang && !is_win) {
|
2016-10-11 17:51:55 +00:00
|
|
|
is_clang = exec_script("is_clang.py",
|
|
|
|
[
|
|
|
|
cc,
|
|
|
|
cxx,
|
|
|
|
],
|
|
|
|
"value")
|
|
|
|
}
|
2016-09-26 15:40:12 +00:00
|
|
|
|
2016-11-03 18:06:31 +00:00
|
|
|
if (is_ios) {
|
|
|
|
ios_sysroot = exec_script("find_ios_sysroot.py", [], "trim string")
|
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("default") {
|
|
|
|
asmflags = []
|
|
|
|
cflags = []
|
|
|
|
cflags_c = []
|
|
|
|
cflags_cc = []
|
|
|
|
defines = []
|
|
|
|
ldflags = []
|
2016-12-09 00:00:40 +00:00
|
|
|
libs = []
|
2016-09-16 21:44:18 +00:00
|
|
|
|
|
|
|
if (is_win) {
|
|
|
|
cflags += [
|
|
|
|
"/FS", # Preserve previous PDB behavior.
|
2016-09-16 20:29:57 +00:00
|
|
|
"/bigobj", # Some of our files are bigger than the regular limits.
|
2016-10-13 03:58:06 +00:00
|
|
|
"/WX", # Treat warnings as errors.
|
2017-01-03 22:09:59 +00:00
|
|
|
"/utf-8", # Set Source and Executable character sets to UTF-8.
|
2016-09-16 20:29:57 +00:00
|
|
|
]
|
2016-09-16 21:44:18 +00:00
|
|
|
defines += [
|
2016-10-13 03:58:06 +00:00
|
|
|
"_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf().
|
|
|
|
"_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL.
|
2016-09-16 21:44:18 +00:00
|
|
|
"WIN32_LEAN_AND_MEAN",
|
|
|
|
"NOMINMAX",
|
2016-09-16 20:29:57 +00:00
|
|
|
]
|
2016-10-11 20:26:57 +00:00
|
|
|
include_dirs = [
|
2016-10-12 19:52:44 +00:00
|
|
|
"$windk/VC/include",
|
2016-10-12 20:25:27 +00:00
|
|
|
|
2016-10-12 19:52:44 +00:00
|
|
|
# For local builds.
|
2016-10-11 20:26:57 +00:00
|
|
|
"$windk/../Windows Kits/10/Include/10.0.10150.0/ucrt",
|
|
|
|
"$windk/../Windows Kits/8.1/Include/shared",
|
2016-10-11 21:08:53 +00:00
|
|
|
"$windk/../Windows Kits/8.1/Include/um",
|
2017-01-10 18:31:33 +00:00
|
|
|
"$windk/../Windows Kits/8.1/Include/winrt",
|
2016-10-12 20:25:27 +00:00
|
|
|
|
2016-10-12 19:52:44 +00:00
|
|
|
# For builds using win_toolchain asset.
|
2017-01-10 15:38:23 +00:00
|
|
|
"$windk/win_sdk/Include/10.0.14393.0/shared",
|
|
|
|
"$windk/win_sdk/Include/10.0.14393.0/ucrt",
|
|
|
|
"$windk/win_sdk/Include/10.0.14393.0/um",
|
2017-01-10 18:31:33 +00:00
|
|
|
"$windk/win_sdk/Include/10.0.14393.0/winrt",
|
2016-10-11 20:26:57 +00:00
|
|
|
]
|
2016-10-11 21:08:53 +00:00
|
|
|
lib_dirs = [
|
2016-10-12 19:52:44 +00:00
|
|
|
# For local builds.
|
2016-10-13 02:42:55 +00:00
|
|
|
"$windk/../Windows Kits/10/Lib/10.0.10150.0/ucrt/$target_cpu",
|
|
|
|
"$windk/../Windows Kits/8.1/Lib/winv6.3/um/$target_cpu",
|
2016-10-12 20:25:27 +00:00
|
|
|
|
2016-10-12 19:52:44 +00:00
|
|
|
# For builds using win_toolchain asset.
|
2017-01-10 15:38:23 +00:00
|
|
|
"$windk/win_sdk/Lib/10.0.14393.0/ucrt/$target_cpu",
|
|
|
|
"$windk/win_sdk/Lib/10.0.14393.0/um/$target_cpu",
|
2016-10-11 21:08:53 +00:00
|
|
|
]
|
2016-10-13 02:42:55 +00:00
|
|
|
if (target_cpu == "x86") {
|
|
|
|
lib_dirs += [ "$windk/VC/lib" ]
|
|
|
|
} else {
|
|
|
|
lib_dirs += [ "$windk/VC/lib/amd64" ]
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
} else {
|
|
|
|
cflags += [
|
2016-09-16 20:29:57 +00:00
|
|
|
"-fstrict-aliasing",
|
|
|
|
"-fPIC",
|
|
|
|
"-fvisibility=hidden",
|
|
|
|
"-Werror",
|
2016-08-25 21:50:44 +00:00
|
|
|
]
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags_cc += [
|
2016-09-16 20:29:57 +00:00
|
|
|
"-std=c++11",
|
|
|
|
"-fno-threadsafe-statics",
|
|
|
|
"-fvisibility-inlines-hidden",
|
2016-08-25 21:50:44 +00:00
|
|
|
]
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_cpu == "arm") {
|
|
|
|
cflags += [
|
|
|
|
"-march=armv7-a",
|
|
|
|
"-mfpu=neon",
|
|
|
|
"-mthumb",
|
|
|
|
]
|
|
|
|
} else if (current_cpu == "mipsel") {
|
|
|
|
cflags += [
|
|
|
|
"-march=mips32r2",
|
|
|
|
"-mdspr2",
|
|
|
|
]
|
2016-10-12 23:36:09 +00:00
|
|
|
} else if (current_cpu == "x86" && !is_win) {
|
2016-09-16 21:44:18 +00:00
|
|
|
asmflags += [ "-m32" ]
|
|
|
|
cflags += [
|
|
|
|
"-m32",
|
|
|
|
"-msse2",
|
|
|
|
"-mfpmath=sse",
|
|
|
|
]
|
|
|
|
ldflags += [ "-m32" ]
|
|
|
|
}
|
|
|
|
|
2016-12-09 00:00:40 +00:00
|
|
|
if (malloc != "" && !is_win) {
|
|
|
|
cflags += [
|
|
|
|
"-fno-builtin-malloc",
|
|
|
|
"-fno-builtin-calloc",
|
|
|
|
"-fno-builtin-realloc",
|
|
|
|
"-fno-builtin-free",
|
|
|
|
]
|
|
|
|
libs += [ malloc ]
|
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
if (is_android) {
|
|
|
|
asmflags += [
|
|
|
|
"--target=$ndk_target",
|
|
|
|
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
|
|
|
|
]
|
|
|
|
cflags += [
|
|
|
|
"--sysroot=$ndk/platforms/$ndk_platform",
|
|
|
|
"--target=$ndk_target",
|
|
|
|
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
|
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
"-isystem$ndk/sources/android/support/include",
|
2016-12-14 18:17:53 +00:00
|
|
|
"-isystem$ndk/sources/cxx-stl/gnu-libstdc++/4.9/include",
|
|
|
|
"-isystem$ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ndk_stdlib/include",
|
2016-09-16 21:44:18 +00:00
|
|
|
]
|
|
|
|
ldflags += [
|
|
|
|
"--sysroot=$ndk/platforms/$ndk_platform",
|
|
|
|
"--target=$ndk_target",
|
|
|
|
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
|
|
|
|
]
|
|
|
|
lib_dirs = [
|
2016-12-14 18:17:53 +00:00
|
|
|
"$ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ndk_stdlib",
|
2016-09-16 21:44:18 +00:00
|
|
|
"$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
|
|
|
|
]
|
|
|
|
|
Update to Android NDK r13.
The libc++ include paths have changed very slightly. I've left GN compatible with both older r12 NDKs and the new r13 to smooth the transition.
The libc++ in r13 depends on long-double math.h functions (cosl, atanl, etc.) only available in Android API v21 (Lollipop) and up. That's what the 64-bit bots were already on, so we just pull the 32-bit bots up to the same target. Conveniently, the oldest bots we have (N7 and N10) are on Lollipop.
The r13 MIPS64 sysroots are a little weird... /usr/include and /usr/lib64 but no /usr/lib. That'd be fine---we only want 64-bit builds---but Clang searches for /usr/lib64 via its path to /usr/lib, and without at least an empty /usr/lib, it can't find /usr/lib64. So you'll see a special mips64el section in the GN config where we do this all manually (other platforms pick this all up correctly from --sysroot). I've chosen to do this rather than fix it up in the asset create.py scripts so that we stay compatible with vanilla NDKs, which is convenient for developers.
CQ_INCLUDE_TRYBOTS=master.client.skia.compile:Build-Mac-Clang-arm64-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-arm-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-arm-Release-GN_Android-Trybot,Build-Ubuntu-Clang-arm64-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-arm64-Debug-GN_Android_FrameworkDefs-Trybot,Build-Ubuntu-Clang-arm64-Debug-GN_Android_Vulkan-Trybot,Build-Ubuntu-Clang-arm64-Release-GN_Android-Trybot,Build-Ubuntu-Clang-mips64el-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-mips64el-Release-GN_Android-Trybot,Build-Ubuntu-Clang-mips64el-Release-GN_Android-Trybot,Build-Ubuntu-Clang-mipsel-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-mipsel-Release-GN_Android-Trybot,Build-Ubuntu-Clang-x64-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-x64-Release-GN_Android-Trybot,Build-Ubuntu-Clang-x86-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-x86-Release-GN_Android-Trybot
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3180
Change-Id: I6f3b5d9411ded0ee49c1099490f41fa86a8736f8
Reviewed-on: https://skia-review.googlesource.com/3180
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-10-11 15:21:36 +00:00
|
|
|
if (current_cpu == "mips64el") {
|
|
|
|
# The r13 NDK omits /usr/lib from the MIPS64 sysroots, but Clang searches
|
|
|
|
# for /usr/lib64 as $PATH_TO_USR_LIB/../lib64. If there's no /usr/lib,
|
|
|
|
# it can't find /usr/lib64. We must point Clang at /usr/lib64 manually.
|
|
|
|
lib_dirs += [ "$ndk/platforms/$ndk_platform/usr/lib64" ]
|
2016-12-08 15:29:27 +00:00
|
|
|
ldflags += [ "-B$ndk/platforms/$ndk_platform/usr/lib64" ]
|
Update to Android NDK r13.
The libc++ include paths have changed very slightly. I've left GN compatible with both older r12 NDKs and the new r13 to smooth the transition.
The libc++ in r13 depends on long-double math.h functions (cosl, atanl, etc.) only available in Android API v21 (Lollipop) and up. That's what the 64-bit bots were already on, so we just pull the 32-bit bots up to the same target. Conveniently, the oldest bots we have (N7 and N10) are on Lollipop.
The r13 MIPS64 sysroots are a little weird... /usr/include and /usr/lib64 but no /usr/lib. That'd be fine---we only want 64-bit builds---but Clang searches for /usr/lib64 via its path to /usr/lib, and without at least an empty /usr/lib, it can't find /usr/lib64. So you'll see a special mips64el section in the GN config where we do this all manually (other platforms pick this all up correctly from --sysroot). I've chosen to do this rather than fix it up in the asset create.py scripts so that we stay compatible with vanilla NDKs, which is convenient for developers.
CQ_INCLUDE_TRYBOTS=master.client.skia.compile:Build-Mac-Clang-arm64-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-arm-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-arm-Release-GN_Android-Trybot,Build-Ubuntu-Clang-arm64-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-arm64-Debug-GN_Android_FrameworkDefs-Trybot,Build-Ubuntu-Clang-arm64-Debug-GN_Android_Vulkan-Trybot,Build-Ubuntu-Clang-arm64-Release-GN_Android-Trybot,Build-Ubuntu-Clang-mips64el-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-mips64el-Release-GN_Android-Trybot,Build-Ubuntu-Clang-mips64el-Release-GN_Android-Trybot,Build-Ubuntu-Clang-mipsel-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-mipsel-Release-GN_Android-Trybot,Build-Ubuntu-Clang-x64-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-x64-Release-GN_Android-Trybot,Build-Ubuntu-Clang-x86-Debug-GN_Android-Trybot,Build-Ubuntu-Clang-x86-Release-GN_Android-Trybot
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3180
Change-Id: I6f3b5d9411ded0ee49c1099490f41fa86a8736f8
Reviewed-on: https://skia-review.googlesource.com/3180
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-10-11 15:21:36 +00:00
|
|
|
}
|
|
|
|
|
2016-12-14 18:17:53 +00:00
|
|
|
libs += [ "gnustl_static" ]
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
2016-11-03 18:06:31 +00:00
|
|
|
if (is_ios) {
|
|
|
|
cflags += [
|
2016-11-07 20:38:48 +00:00
|
|
|
"-isysroot",
|
|
|
|
ios_sysroot,
|
|
|
|
"-arch",
|
|
|
|
target_cpu,
|
2016-11-03 18:06:31 +00:00
|
|
|
]
|
|
|
|
cflags_cc += [ "-stdlib=libc++" ]
|
|
|
|
ldflags += [
|
2016-11-07 20:38:48 +00:00
|
|
|
"-isysroot",
|
|
|
|
ios_sysroot,
|
|
|
|
"-arch",
|
|
|
|
target_cpu,
|
2016-11-03 18:06:31 +00:00
|
|
|
"-stdlib=libc++",
|
|
|
|
]
|
2016-12-09 00:00:40 +00:00
|
|
|
libs += [ "objc" ]
|
2016-11-03 18:06:31 +00:00
|
|
|
|
|
|
|
# We used to link all our iOS tools together, so none actually defines main().
|
|
|
|
# Instead they each define their own entry point, which our iOS mega-app called.
|
|
|
|
# If we can we'd like to not do that anymore. While we're building both ways, here's
|
|
|
|
# our clever hack to give each tool back its own main().
|
|
|
|
cflags += [
|
|
|
|
"-Ddm_main=main",
|
|
|
|
"-Dnanobench_main=main",
|
|
|
|
"-Dtool_main=main",
|
|
|
|
"-Dtest_main=main",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
if (is_linux) {
|
2016-12-09 00:00:40 +00:00
|
|
|
libs += [ "pthread" ]
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
2016-08-25 21:50:44 +00:00
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
if (sanitize != "") {
|
|
|
|
# You can either pass the sanitizers directly, e.g. "address,undefined",
|
|
|
|
# or pass one of the couple common aliases used by the bots.
|
|
|
|
sanitizers = sanitize
|
|
|
|
if (sanitize == "ASAN") {
|
|
|
|
sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
|
|
|
|
} else if (sanitize == "TSAN") {
|
|
|
|
sanitizers = "thread"
|
|
|
|
} else if (sanitize == "MSAN") {
|
|
|
|
sanitizers = "memory"
|
2016-09-08 15:39:34 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags += [
|
|
|
|
"-fsanitize=$sanitizers",
|
|
|
|
"-fno-sanitize-recover=$sanitizers",
|
|
|
|
"-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
|
|
|
|
]
|
|
|
|
ldflags += [ "-fsanitize=$sanitizers" ]
|
|
|
|
if (sanitizers == "memory") {
|
|
|
|
cflags += [ "-fsanitize-memory-track-origins" ]
|
|
|
|
cflags_cc += [ "-stdlib=libc++" ]
|
|
|
|
ldflags += [ "-stdlib=libc++" ]
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-26 15:41:47 +00:00
|
|
|
config("no_exceptions") {
|
|
|
|
# Exceptions are disabled by default on Windows. (Use /EHsc to enable them.)
|
|
|
|
if (!is_win) {
|
|
|
|
cflags_cc = [ "-fno-exceptions" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-13 03:58:06 +00:00
|
|
|
config("warnings") {
|
|
|
|
cflags = []
|
|
|
|
cflags_cc = []
|
2016-10-20 14:17:47 +00:00
|
|
|
cflags_objc = []
|
2016-10-13 03:58:06 +00:00
|
|
|
if (is_win) {
|
|
|
|
cflags += [
|
|
|
|
"/W3", # Turn on lots of warnings.
|
|
|
|
|
|
|
|
# Disable a bunch of warnings:
|
|
|
|
"/wd4244", # conversion from 'float' to 'int', possible loss of data
|
|
|
|
"/wd4267", # conversion from 'size_t' to 'int', possible loss of data
|
|
|
|
"/wd4800", # forcing value to bool 'true' or 'false' (performance warning)
|
|
|
|
|
|
|
|
# Probably only triggers when /EHsc is enabled.
|
|
|
|
"/wd4291", # no matching operator delete found;
|
|
|
|
# memory will not be freed if initialization throws an exception
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
cflags += [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Winit-self",
|
|
|
|
"-Wpointer-arith",
|
|
|
|
"-Wsign-compare",
|
|
|
|
"-Wvla",
|
|
|
|
|
|
|
|
"-Wno-deprecated-declarations",
|
2016-12-13 17:46:05 +00:00
|
|
|
"-Wno-maybe-uninitialized",
|
2016-10-13 03:58:06 +00:00
|
|
|
]
|
|
|
|
cflags_cc += [ "-Wnon-virtual-dtor" ]
|
|
|
|
|
|
|
|
if (is_clang) {
|
|
|
|
cflags += [
|
|
|
|
"-Weverything",
|
|
|
|
"-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings.
|
|
|
|
]
|
|
|
|
|
|
|
|
if (is_android && target_cpu == "x86") {
|
|
|
|
# Clang seems to think new/malloc will only be 4-byte aligned on x86 Android.
|
|
|
|
# We're pretty sure it's actually 8-byte alignment.
|
|
|
|
cflags += [ "-Wno-over-aligned" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
cflags += [
|
|
|
|
"-Wno-cast-align",
|
|
|
|
"-Wno-conditional-uninitialized",
|
|
|
|
"-Wno-conversion",
|
|
|
|
"-Wno-disabled-macro-expansion",
|
|
|
|
"-Wno-documentation",
|
|
|
|
"-Wno-documentation-unknown-command",
|
|
|
|
"-Wno-double-promotion",
|
|
|
|
"-Wno-exit-time-destructors", # TODO: OK outside libskia
|
|
|
|
"-Wno-float-conversion",
|
|
|
|
"-Wno-float-equal",
|
|
|
|
"-Wno-format-nonliteral",
|
|
|
|
"-Wno-global-constructors", # TODO: OK outside libskia
|
|
|
|
"-Wno-gnu-zero-variadic-macro-arguments",
|
|
|
|
"-Wno-missing-prototypes",
|
|
|
|
"-Wno-missing-variable-declarations",
|
|
|
|
"-Wno-pedantic",
|
|
|
|
"-Wno-reserved-id-macro",
|
|
|
|
"-Wno-shadow",
|
|
|
|
"-Wno-shift-sign-overflow",
|
|
|
|
"-Wno-sign-conversion",
|
2017-01-04 22:13:44 +00:00
|
|
|
"-Wno-signed-enum-bitfield",
|
2016-10-13 03:58:06 +00:00
|
|
|
"-Wno-switch-enum",
|
|
|
|
"-Wno-undef",
|
|
|
|
"-Wno-unreachable-code",
|
|
|
|
"-Wno-unreachable-code-break",
|
|
|
|
"-Wno-unreachable-code-return",
|
|
|
|
"-Wno-unused-macros",
|
|
|
|
"-Wno-unused-member-function",
|
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
"-Wno-abstract-vbase-init",
|
|
|
|
"-Wno-weak-vtables",
|
|
|
|
]
|
|
|
|
|
|
|
|
# We are unlikely to want to fix these.
|
|
|
|
cflags += [
|
|
|
|
"-Wno-covered-switch-default",
|
|
|
|
"-Wno-deprecated",
|
|
|
|
"-Wno-implicit-fallthrough",
|
|
|
|
"-Wno-missing-noreturn",
|
|
|
|
"-Wno-old-style-cast",
|
|
|
|
"-Wno-padded",
|
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
"-Wno-c++98-compat",
|
|
|
|
"-Wno-c++98-compat-pedantic",
|
|
|
|
"-Wno-undefined-func-template",
|
|
|
|
]
|
2016-10-20 14:17:47 +00:00
|
|
|
cflags_objc += [
|
|
|
|
"-Wno-direct-ivar-access",
|
|
|
|
"-Wno-objc-interface-ivars",
|
|
|
|
]
|
2016-10-13 03:58:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-16 17:13:44 +00:00
|
|
|
config("warnings_except_public_headers") {
|
|
|
|
if (!is_win) {
|
|
|
|
cflags = [ "-Wno-unused-parameter" ]
|
|
|
|
}
|
|
|
|
}
|
2016-10-13 03:58:06 +00:00
|
|
|
|
2016-10-04 21:09:13 +00:00
|
|
|
config("extra_flags") {
|
|
|
|
cflags = extra_cflags
|
|
|
|
cflags_c = extra_cflags_c
|
|
|
|
cflags_cc = extra_cflags_cc
|
|
|
|
ldflags = extra_ldflags
|
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("debug_symbols") {
|
|
|
|
# It's annoying to wait for full debug symbols to push over
|
|
|
|
# to Android devices. -gline-tables-only is a lot slimmer.
|
|
|
|
if (is_android) {
|
|
|
|
cflags = [ "-gline-tables-only" ]
|
2016-10-12 20:25:27 +00:00
|
|
|
} else if (is_win) {
|
|
|
|
cflags = [ "/Zi" ]
|
2016-10-13 17:19:25 +00:00
|
|
|
ldflags = [ "/DEBUG" ]
|
2016-10-12 20:25:27 +00:00
|
|
|
} else {
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags = [ "-g" ]
|
|
|
|
}
|
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("no_rtti") {
|
|
|
|
if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
|
2016-10-12 20:25:27 +00:00
|
|
|
if (is_win) {
|
|
|
|
cflags_cc = [ "/GR-" ]
|
|
|
|
} else {
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags_cc = [ "-fno-rtti" ]
|
2016-09-08 15:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
2016-07-21 19:25:45 +00:00
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("release") {
|
2016-10-12 20:25:27 +00:00
|
|
|
if (is_win) {
|
2016-10-20 17:34:18 +00:00
|
|
|
cflags = [
|
|
|
|
"/O2",
|
|
|
|
"/Zc:inline",
|
2016-10-20 19:45:02 +00:00
|
|
|
"/GS-",
|
2016-10-20 17:34:18 +00:00
|
|
|
]
|
2016-10-20 17:52:38 +00:00
|
|
|
ldflags = [
|
|
|
|
"/OPT:ICF",
|
|
|
|
"/OPT:REF",
|
|
|
|
]
|
2016-10-12 20:25:27 +00:00
|
|
|
} else {
|
2016-10-20 02:24:10 +00:00
|
|
|
cflags = [
|
|
|
|
"-O3",
|
|
|
|
"-momit-leaf-frame-pointer",
|
|
|
|
]
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
defines = [ "NDEBUG" ]
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config("executable") {
|
2016-12-06 15:46:02 +00:00
|
|
|
if (is_android) {
|
|
|
|
ldflags = [ "-pie" ]
|
|
|
|
} else if (is_mac) {
|
2016-07-21 19:25:45 +00:00
|
|
|
ldflags = [ "-Wl,-rpath,@loader_path/." ]
|
|
|
|
} else if (is_linux) {
|
2016-09-15 17:44:15 +00:00
|
|
|
ldflags = [
|
|
|
|
"-rdynamic",
|
|
|
|
"-Wl,-rpath,\$ORIGIN",
|
|
|
|
]
|
2016-11-06 16:54:19 +00:00
|
|
|
} else if (is_win) {
|
|
|
|
ldflags = [
|
|
|
|
"/SUBSYSTEM:CONSOLE", # Quiet "no subsystem specified; CONSOLE assumed".
|
|
|
|
"/INCREMENTAL:NO", # Quiet warnings about failing to incrementally link by never trying to.
|
|
|
|
]
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-16 20:29:57 +00:00
|
|
|
toolchain("msvc") {
|
2016-10-11 21:08:53 +00:00
|
|
|
lib_dir_switch = "/LIBPATH:"
|
|
|
|
|
2016-10-13 02:42:55 +00:00
|
|
|
bin = "$windk/VC/bin/amd64"
|
|
|
|
env_setup = ""
|
|
|
|
if (target_cpu == "x86") {
|
|
|
|
bin += "_x86"
|
|
|
|
env_setup = "cmd /c $windk/win_sdk/bin/SetEnv.cmd /x86 && "
|
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
|
|
|
|
tool("cc") {
|
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
precompiled_header_type = "msvc"
|
|
|
|
pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
|
|
|
|
|
2016-10-11 20:26:57 +00:00
|
|
|
# Label names may have spaces so pdbname must be quoted.
|
2016-10-13 02:42:55 +00:00
|
|
|
command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
|
2016-09-16 20:29:57 +00:00
|
|
|
depsformat = "msvc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
|
|
|
|
]
|
2016-10-11 20:26:57 +00:00
|
|
|
rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
|
2016-10-13 18:31:01 +00:00
|
|
|
description = "compile {{source}}"
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("cxx") {
|
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
precompiled_header_type = "msvc"
|
|
|
|
pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
|
|
|
|
|
2016-10-11 20:26:57 +00:00
|
|
|
# Label names may have spaces so pdbname must be quoted.
|
2016-10-13 02:42:55 +00:00
|
|
|
command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
|
2016-09-16 20:29:57 +00:00
|
|
|
depsformat = "msvc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
|
|
|
|
]
|
2016-10-11 20:26:57 +00:00
|
|
|
rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}"
|
2016-10-13 18:31:01 +00:00
|
|
|
description = "compile {{source}}"
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
|
|
|
|
tool("alink") {
|
|
|
|
rspfile = "{{output}}.rsp"
|
2016-09-16 21:44:18 +00:00
|
|
|
|
2016-10-13 18:31:01 +00:00
|
|
|
command = "$env_setup$bin/lib.exe /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile"
|
2016-09-16 20:29:57 +00:00
|
|
|
outputs = [
|
|
|
|
# Ignore {{output_extension}} and always use .lib, there's no reason to
|
|
|
|
# allow targets to override this extension on Windows.
|
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
|
|
|
]
|
|
|
|
default_output_extension = ".lib"
|
|
|
|
default_output_dir = "{{target_out_dir}}"
|
|
|
|
|
2016-10-11 20:26:57 +00:00
|
|
|
# inputs_newline works around a fixed per-line buffer size in the linker.
|
2016-09-16 20:29:57 +00:00
|
|
|
rspfile_content = "{{inputs_newline}}"
|
2016-10-13 18:31:01 +00:00
|
|
|
description = "link {{output}}"
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
|
|
|
|
2016-10-17 15:51:11 +00:00
|
|
|
tool("solink") {
|
|
|
|
dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
|
|
|
libname = "${dllname}.lib"
|
|
|
|
pdbname = "${dllname}.pdb"
|
|
|
|
rspfile = "${dllname}.rsp"
|
|
|
|
|
|
|
|
command = "$env_setup$bin/link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
|
|
|
|
outputs = [
|
|
|
|
dllname,
|
|
|
|
libname,
|
|
|
|
pdbname,
|
|
|
|
]
|
|
|
|
default_output_extension = ".dll"
|
|
|
|
default_output_dir = "{{root_out_dir}}"
|
|
|
|
|
|
|
|
link_output = libname
|
|
|
|
depend_output = libname
|
|
|
|
runtime_outputs = [
|
|
|
|
dllname,
|
|
|
|
pdbname,
|
|
|
|
]
|
|
|
|
|
|
|
|
# I don't quite understand this. Aping Chrome's toolchain/win/BUILD.gn.
|
|
|
|
restat = true
|
|
|
|
|
|
|
|
# inputs_newline works around a fixed per-line buffer size in the linker.
|
|
|
|
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
2016-09-16 20:29:57 +00:00
|
|
|
tool("link") {
|
|
|
|
exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
|
|
|
|
pdbname = "$exename.pdb"
|
|
|
|
rspfile = "$exename.rsp"
|
|
|
|
|
2016-10-13 02:42:55 +00:00
|
|
|
command =
|
|
|
|
"$env_setup$bin/link.exe /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
|
2016-09-16 20:29:57 +00:00
|
|
|
|
|
|
|
default_output_extension = ".exe"
|
|
|
|
default_output_dir = "{{root_out_dir}}"
|
|
|
|
outputs = [
|
|
|
|
exename,
|
|
|
|
]
|
2016-09-16 21:44:18 +00:00
|
|
|
|
2016-10-11 20:26:57 +00:00
|
|
|
# inputs_newline works around a fixed per-line buffer size in the linker.
|
2016-09-16 20:29:57 +00:00
|
|
|
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
|
2016-10-13 18:31:01 +00:00
|
|
|
description = "link {{output}}"
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("stamp") {
|
2016-10-24 20:49:15 +00:00
|
|
|
command = "$stamp {{output}}"
|
2016-10-13 18:31:01 +00:00
|
|
|
description = "stamp {{output}}"
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
2016-10-17 15:51:11 +00:00
|
|
|
|
|
|
|
tool("copy") {
|
|
|
|
cp_py = rebase_path("cp.py")
|
2016-10-24 20:49:15 +00:00
|
|
|
command = "$python $cp_py {{source}} {{output}}"
|
2016-10-17 15:51:11 +00:00
|
|
|
description = "copy {{source}} {{output}}"
|
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 19:25:45 +00:00
|
|
|
toolchain("gcc_like") {
|
|
|
|
lib_switch = "-l"
|
|
|
|
lib_dir_switch = "-L"
|
|
|
|
|
|
|
|
tool("cc") {
|
|
|
|
depfile = "{{output}}.d"
|
2016-10-04 21:09:13 +00:00
|
|
|
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "compile {{source}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("cxx") {
|
|
|
|
depfile = "{{output}}.d"
|
2016-10-04 21:09:13 +00:00
|
|
|
command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "compile {{source}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 14:17:47 +00:00
|
|
|
tool("objc") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("objcxx") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objc}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
2016-07-21 19:25:45 +00:00
|
|
|
tool("asm") {
|
|
|
|
depfile = "{{output}}.d"
|
2016-09-20 19:09:12 +00:00
|
|
|
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "compile {{source}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("alink") {
|
2016-11-06 16:20:09 +00:00
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
rspfile_content = "{{inputs}}"
|
|
|
|
ar_py = rebase_path("ar.py")
|
|
|
|
command = "$python $ar_py $ar {{output}} $rspfile"
|
2016-07-21 19:25:45 +00:00
|
|
|
outputs = [
|
2016-07-29 16:10:31 +00:00
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
2016-07-21 19:25:45 +00:00
|
|
|
]
|
|
|
|
default_output_extension = ".a"
|
|
|
|
output_prefix = "lib"
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "link {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("solink") {
|
|
|
|
soname = "{{target_output_name}}{{output_extension}}"
|
|
|
|
|
|
|
|
rpath = "-Wl,-soname,$soname"
|
|
|
|
if (is_mac) {
|
|
|
|
rpath = "-Wl,-install_name,@rpath/$soname"
|
|
|
|
}
|
|
|
|
|
2016-10-04 21:09:13 +00:00
|
|
|
command = "$cc_wrapper $cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/$soname",
|
|
|
|
]
|
|
|
|
output_prefix = "lib"
|
|
|
|
default_output_extension = ".so"
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "link {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("link") {
|
2016-10-04 21:09:13 +00:00
|
|
|
command = "$cc_wrapper $cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
|
|
|
]
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "link {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("stamp") {
|
2016-10-24 20:49:15 +00:00
|
|
|
command = "$stamp {{output}}"
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "stamp {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("copy") {
|
2016-10-17 15:51:11 +00:00
|
|
|
cp_py = rebase_path("cp.py")
|
2016-10-24 20:49:15 +00:00
|
|
|
command = "$python $cp_py {{source}} {{output}}"
|
2016-10-17 14:41:41 +00:00
|
|
|
description = "copy {{source}} {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
}
|