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-08-26 15:13:04 +00:00
|
|
|
ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
|
2016-08-25 21:50:44 +00:00
|
|
|
cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
|
|
|
|
cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
extra_cflags = ""
|
|
|
|
extra_cflags_c = ""
|
|
|
|
extra_cflags_cc = ""
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
2016-08-03 22:08:04 +00:00
|
|
|
config("no_rtti") {
|
|
|
|
cflags_cc = [ "-fno-rtti" ]
|
|
|
|
}
|
|
|
|
|
2016-07-21 19:25:45 +00:00
|
|
|
config("default") {
|
|
|
|
cflags = [
|
|
|
|
"-g",
|
|
|
|
"-fstrict-aliasing",
|
|
|
|
"-fPIC",
|
2016-07-27 21:59:08 +00:00
|
|
|
"-fvisibility=hidden",
|
2016-07-21 19:25:45 +00:00
|
|
|
|
|
|
|
"-Werror",
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Winit-self",
|
|
|
|
"-Wpointer-arith",
|
|
|
|
"-Wsign-compare",
|
|
|
|
"-Wvla",
|
|
|
|
|
|
|
|
"-Wno-deprecated-declarations",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
]
|
|
|
|
cflags_cc = [
|
|
|
|
"-std=c++11",
|
|
|
|
"-fno-exceptions",
|
|
|
|
"-fno-threadsafe-statics",
|
2016-07-27 21:59:08 +00:00
|
|
|
"-fvisibility-inlines-hidden",
|
2016-07-21 19:25:45 +00:00
|
|
|
|
|
|
|
"-Wnon-virtual-dtor",
|
|
|
|
]
|
2016-08-25 21:50:44 +00:00
|
|
|
if (current_cpu == "arm") {
|
2016-08-26 15:13:04 +00:00
|
|
|
cflags += [
|
|
|
|
"-march=armv7-a",
|
|
|
|
"-mfpu=neon",
|
|
|
|
"-mthumb",
|
|
|
|
]
|
|
|
|
} else if (current_cpu == "mipsel") {
|
|
|
|
cflags += [
|
|
|
|
"-march=mips32r2",
|
|
|
|
"-mdspr2",
|
|
|
|
]
|
2016-08-25 21:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_android) {
|
2016-08-26 15:13:04 +00:00
|
|
|
asmflags = [
|
|
|
|
"--target=$ndk_target",
|
|
|
|
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
|
|
|
|
]
|
2016-08-25 21:50:44 +00:00
|
|
|
cflags += [
|
|
|
|
"--sysroot=$ndk/platforms/$ndk_platform",
|
|
|
|
"--target=$ndk_target",
|
2016-08-26 15:13:04 +00:00
|
|
|
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
|
2016-08-25 21:50:44 +00:00
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
"-isystem$ndk/sources/android/support/include",
|
|
|
|
"-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include",
|
|
|
|
]
|
|
|
|
ldflags = [
|
|
|
|
"--sysroot=$ndk/platforms/$ndk_platform",
|
|
|
|
"--target=$ndk_target",
|
2016-08-26 15:13:04 +00:00
|
|
|
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
|
2016-08-25 21:50:44 +00:00
|
|
|
"-pie",
|
|
|
|
]
|
|
|
|
lib_dirs = [
|
|
|
|
"$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
|
2016-08-26 15:13:04 +00:00
|
|
|
"$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
|
2016-08-25 21:50:44 +00:00
|
|
|
]
|
|
|
|
libs = [
|
|
|
|
# Order matters here! Keep these three in exactly this order.
|
|
|
|
"c++_static",
|
|
|
|
"c++abi",
|
|
|
|
"android_support",
|
|
|
|
]
|
2016-08-26 15:13:04 +00:00
|
|
|
if (target_cpu == "arm") {
|
|
|
|
libs += [ "unwind" ]
|
|
|
|
}
|
2016-08-25 21:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_linux) {
|
|
|
|
libs = [ "pthread" ]
|
|
|
|
}
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config("release") {
|
|
|
|
cflags = [ "-Os" ]
|
|
|
|
defines = [ "NDEBUG" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
config("executable") {
|
|
|
|
if (is_mac) {
|
|
|
|
ldflags = [ "-Wl,-rpath,@loader_path/." ]
|
|
|
|
} else if (is_linux) {
|
|
|
|
ldflags = [ "-Wl,-rpath,\$ORIGIN" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 14:30:58 +00:00
|
|
|
pool("link_pool") {
|
|
|
|
depth = 0 #unlimited
|
|
|
|
}
|
|
|
|
|
2016-07-21 19:25:45 +00:00
|
|
|
toolchain("gcc_like") {
|
|
|
|
lib_switch = "-l"
|
|
|
|
lib_dir_switch = "-L"
|
|
|
|
|
|
|
|
tool("cc") {
|
|
|
|
depfile = "{{output}}.d"
|
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
|
|
|
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $extra_cflags $extra_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-08-19 11:27:34 +00:00
|
|
|
description = "$cc ... $extra_cflags $extra_cflags_c -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("cxx") {
|
|
|
|
depfile = "{{output}}.d"
|
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
|
|
|
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $extra_cflags $extra_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-08-19 11:27:34 +00:00
|
|
|
description = "$cxx ... $extra_cflags $extra_cflags_cc -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("asm") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
2016-07-28 18:42:34 +00:00
|
|
|
description = "$cc ... -o {{output}}"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("alink") {
|
2016-08-26 15:13:04 +00:00
|
|
|
command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}"
|
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-08-26 15:13:04 +00:00
|
|
|
description = "$ar {{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"
|
|
|
|
}
|
|
|
|
|
|
|
|
command = "$cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}"
|
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/$soname",
|
|
|
|
]
|
|
|
|
output_prefix = "lib"
|
|
|
|
default_output_extension = ".so"
|
2016-07-28 18:42:34 +00:00
|
|
|
description = "$cxx -shared ... -o {{output}}"
|
2016-08-10 14:30:58 +00:00
|
|
|
pool = ":link_pool"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("link") {
|
|
|
|
command = "$cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}"
|
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
|
|
|
]
|
2016-07-28 18:42:34 +00:00
|
|
|
description = "$cxx ... -o {{output}}"
|
2016-08-10 14:30:58 +00:00
|
|
|
pool = ":link_pool"
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tool("stamp") {
|
|
|
|
command = "touch {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("copy") {
|
|
|
|
command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
|
|
|
|
}
|
|
|
|
}
|