GN: support compiler_prefix, use it for ccache on bots.
This makes it considerably easier to use ccache with the Android NDK. You can now just set compiler_prefix = "ccache" ndk = "/path/to/ndk" and we'll use the NDK clang, wrapped with ccache. The name compiler_prefix is stolen from / compatible with Chrome. If you have ccache, you can just always leave compiler_prefix="ccache" enabled. This should make it an unusual thing for humans to have to change cc or cxx. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2281163002 Review-Url: https://codereview.chromium.org/2281163002
This commit is contained in:
parent
4871f22777
commit
cab0bb7fc6
24
gn/BUILD.gn
24
gn/BUILD.gn
@ -17,6 +17,8 @@ declare_args() {
|
||||
extra_cflags = ""
|
||||
extra_cflags_c = ""
|
||||
extra_cflags_cc = ""
|
||||
|
||||
compiler_prefix = ""
|
||||
}
|
||||
|
||||
config("no_rtti") {
|
||||
@ -125,32 +127,34 @@ toolchain("gcc_like") {
|
||||
|
||||
tool("cc") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $extra_cflags $extra_cflags_c -c {{source}} -o {{output}}"
|
||||
command = "$compiler_prefix $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $extra_cflags $extra_cflags_c -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
outputs = [
|
||||
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
||||
]
|
||||
description = "$cc ... $extra_cflags $extra_cflags_c -o {{output}}"
|
||||
description =
|
||||
"$compiler_prefix $cc ... $extra_cflags $extra_cflags_c -o {{output}}"
|
||||
}
|
||||
|
||||
tool("cxx") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $extra_cflags $extra_cflags_cc -c {{source}} -o {{output}}"
|
||||
command = "$compiler_prefix $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $extra_cflags $extra_cflags_cc -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
outputs = [
|
||||
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
||||
]
|
||||
description = "$cxx ... $extra_cflags $extra_cflags_cc -o {{output}}"
|
||||
description =
|
||||
"$compiler_prefix $cxx ... $extra_cflags $extra_cflags_cc -o {{output}}"
|
||||
}
|
||||
|
||||
tool("asm") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
|
||||
command = "$compiler_prefix $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",
|
||||
]
|
||||
description = "$cc ... -o {{output}}"
|
||||
description = "$compiler_prefix $cc ... -o {{output}}"
|
||||
}
|
||||
|
||||
tool("alink") {
|
||||
@ -171,22 +175,22 @@ toolchain("gcc_like") {
|
||||
rpath = "-Wl,-install_name,@rpath/$soname"
|
||||
}
|
||||
|
||||
command = "$cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}"
|
||||
command = "$compiler_prefix $cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}"
|
||||
outputs = [
|
||||
"{{root_out_dir}}/$soname",
|
||||
]
|
||||
output_prefix = "lib"
|
||||
default_output_extension = ".so"
|
||||
description = "$cxx -shared ... -o {{output}}"
|
||||
description = "$compiler_prefix $cxx -shared ... -o {{output}}"
|
||||
pool = ":link_pool"
|
||||
}
|
||||
|
||||
tool("link") {
|
||||
command = "$cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}"
|
||||
command = "$compiler_prefix $cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}"
|
||||
outputs = [
|
||||
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
||||
]
|
||||
description = "$cxx ... -o {{output}}"
|
||||
description = "$compiler_prefix $cxx ... -o {{output}}"
|
||||
pool = ":link_pool"
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,10 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
|
||||
elif compiler == 'GCC':
|
||||
cc, cxx = 'gcc', 'g++'
|
||||
|
||||
compiler_prefix = ""
|
||||
ccache = self.m.run.ccache()
|
||||
if ccache:
|
||||
cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx)
|
||||
compiler_prefix = ccache
|
||||
if compiler == 'Clang':
|
||||
# Stifle "argument unused during compilation: ..." warnings.
|
||||
extra_cflags.append('-Qunused-arguments')
|
||||
@ -45,6 +46,7 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
|
||||
gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in {
|
||||
'cc': quote(cc),
|
||||
'cxx': quote(cxx),
|
||||
'compiler_prefix': quote(compiler_prefix),
|
||||
'extra_cflags': quote(' '.join(extra_cflags)),
|
||||
'is_debug': 'true' if configuration == 'Debug' else 'false',
|
||||
}.iteritems())
|
||||
|
@ -127,7 +127,7 @@
|
||||
"gn",
|
||||
"gen",
|
||||
"[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-x86_64-Debug-GN/Debug",
|
||||
"--args=cc=\"/usr/bin/ccache clang\" cxx=\"/usr/bin/ccache clang++\" is_debug=true extra_cflags=\"-Qunused-arguments\""
|
||||
"--args=cc=\"clang\" cxx=\"clang++\" is_debug=true extra_cflags=\"-Qunused-arguments\" compiler_prefix=\"/usr/bin/ccache\""
|
||||
],
|
||||
"cwd": "[CUSTOM_/_B_WORK]/skia",
|
||||
"env": {
|
||||
|
@ -125,7 +125,7 @@
|
||||
"gn",
|
||||
"gen",
|
||||
"[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-GCC-x86_64-Debug-GN/Debug",
|
||||
"--args=cc=\"/usr/bin/ccache gcc\" cxx=\"/usr/bin/ccache g++\" is_debug=true extra_cflags=\"\""
|
||||
"--args=cc=\"gcc\" cxx=\"g++\" is_debug=true extra_cflags=\"\" compiler_prefix=\"/usr/bin/ccache\""
|
||||
],
|
||||
"cwd": "[CUSTOM_/_B_WORK]/skia",
|
||||
"env": {
|
||||
|
@ -124,7 +124,7 @@
|
||||
"gn",
|
||||
"gen",
|
||||
"[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE/Debug",
|
||||
"--args=cc=\"gcc\" cxx=\"g++\" is_debug=true extra_cflags=\"-DSK_USE_DISCARDABLE_SCALEDIMAGECACHE\""
|
||||
"--args=cc=\"gcc\" cxx=\"g++\" is_debug=true extra_cflags=\"-DSK_USE_DISCARDABLE_SCALEDIMAGECACHE\" compiler_prefix=\"\""
|
||||
],
|
||||
"cwd": "[CUSTOM_/_B_WORK]/skia",
|
||||
"env": {
|
||||
|
@ -123,7 +123,7 @@
|
||||
"gn",
|
||||
"gen",
|
||||
"[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-GCC-x86_64-Release-Fast/Release",
|
||||
"--args=cc=\"gcc\" cxx=\"g++\" is_debug=false extra_cflags=\"-march=native -fomit-frame-pointer -O3\""
|
||||
"--args=cc=\"gcc\" cxx=\"g++\" is_debug=false extra_cflags=\"-march=native -fomit-frame-pointer -O3\" compiler_prefix=\"\""
|
||||
],
|
||||
"cwd": "[CUSTOM_/_B_WORK]/skia",
|
||||
"env": {
|
||||
|
@ -93,7 +93,7 @@
|
||||
"gn",
|
||||
"gen",
|
||||
"[CUSTOM_C:\\_B_WORK]\\skia\\out\\Build-Win-MSVC-x86-Release-GN\\Release",
|
||||
"--args=cc=\"cc\" cxx=\"c++\" is_debug=false extra_cflags=\"\""
|
||||
"--args=cc=\"cc\" cxx=\"c++\" is_debug=false extra_cflags=\"\" compiler_prefix=\"\""
|
||||
],
|
||||
"cwd": "[CUSTOM_C:\\_B_WORK]\\skia",
|
||||
"env": {
|
||||
|
Loading…
Reference in New Issue
Block a user