aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-08-16 09:31:16 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-16 09:31:16 -0700
commit8079ba688c69af14932c200e579090a70e699f41 (patch)
tree9394829b65c1f742fd013c91433eb47960cc7295 /infra
parent168820625c35a8c19f66c661efcbce7a5e334837 (diff)
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
Diffstat (limited to 'infra')
-rw-r--r--infra/bots/recipe_modules/flavor/gn_flavor.py23
-rw-r--r--infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-Clang-x86_64-Debug-GN.json2
-rw-r--r--infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-GN.json2
-rw-r--r--infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json2
-rw-r--r--infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Release-Fast.json2
-rw-r--r--infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GN.json2
6 files changed, 17 insertions, 16 deletions
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index ef25896569..75c318f818 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -21,12 +21,8 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
configuration = self.m.vars.builder_cfg.get('configuration', '')
extra_config = self.m.vars.builder_cfg.get('extra_config', '')
- gn_args = []
- if configuration != 'Debug':
- gn_args.append('is_debug=false')
-
cc, cxx = 'cc', 'c++'
- cflags = []
+ extra_cflags = []
if compiler == 'Clang':
cc, cxx = 'clang', 'clang++'
@@ -38,19 +34,24 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx)
if compiler == 'Clang':
# Stifle "argument unused during compilation: ..." warnings.
- cflags.append('-Qunused-arguments')
+ extra_cflags.append('-Qunused-arguments')
if extra_config == 'Fast':
- cflags.extend(['-march=native', '-fomit-frame-pointer'])
+ extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3'])
if extra_config.startswith('SK'):
- cflags.append('-D' + extra_config)
+ extra_cflags.append('-D' + extra_config)
- cflags = ' '.join(cflags)
- gn_args += [ 'cc="%s %s"' % (cc, cflags), 'cxx="%s %s"' % (cxx, cflags) ]
+ quote = lambda x: '"%s"' % x
+ gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in {
+ 'cc': quote(cc),
+ 'cxx': quote(cxx),
+ 'extra_cflags': quote(' '.join(extra_cflags)),
+ 'is_debug': 'true' if configuration == 'Debug' else 'false',
+ }.iteritems())
run = lambda title, cmd: self.m.run(self.m.step, title, cmd=cmd,
cwd=self.m.vars.skia_dir, **kwargs)
run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')])
- run('gn gen', ['gn', 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)])
+ run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args])
run('ninja', ['ninja', '-C', self.out_dir])
diff --git a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-Clang-x86_64-Debug-GN.json b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-Clang-x86_64-Debug-GN.json
index 40c9a2b21d..3e3ef0e0bd 100644
--- a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-Clang-x86_64-Debug-GN.json
+++ b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-Clang-x86_64-Debug-GN.json
@@ -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 -Qunused-arguments\" cxx=\"/usr/bin/ccache clang++ -Qunused-arguments\""
+ "--args=cc=\"/usr/bin/ccache clang\" cxx=\"/usr/bin/ccache clang++\" is_debug=true extra_cflags=\"-Qunused-arguments\""
],
"cwd": "[CUSTOM_/_B_WORK]/skia",
"env": {
diff --git a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-GN.json b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-GN.json
index 5ad5558822..10ff8c3307 100644
--- a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-GN.json
+++ b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-GN.json
@@ -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++ \""
+ "--args=cc=\"/usr/bin/ccache gcc\" cxx=\"/usr/bin/ccache g++\" is_debug=true extra_cflags=\"\""
],
"cwd": "[CUSTOM_/_B_WORK]/skia",
"env": {
diff --git a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json
index 5d0dd78b6d..12314f87cc 100644
--- a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json
+++ b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json
@@ -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 -DSK_USE_DISCARDABLE_SCALEDIMAGECACHE\" cxx=\"g++ -DSK_USE_DISCARDABLE_SCALEDIMAGECACHE\""
+ "--args=cc=\"gcc\" cxx=\"g++\" is_debug=true extra_cflags=\"-DSK_USE_DISCARDABLE_SCALEDIMAGECACHE\""
],
"cwd": "[CUSTOM_/_B_WORK]/skia",
"env": {
diff --git a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Release-Fast.json b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Release-Fast.json
index 5dd7797b65..091b29ebb1 100644
--- a/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Release-Fast.json
+++ b/infra/bots/recipes/swarm_compile.expected/Build-Ubuntu-GCC-x86_64-Release-Fast.json
@@ -123,7 +123,7 @@
"gn",
"gen",
"[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-GCC-x86_64-Release-Fast/Release",
- "--args=is_debug=false cc=\"gcc -march=native -fomit-frame-pointer\" cxx=\"g++ -march=native -fomit-frame-pointer\""
+ "--args=cc=\"gcc\" cxx=\"g++\" is_debug=false extra_cflags=\"-march=native -fomit-frame-pointer -O3\""
],
"cwd": "[CUSTOM_/_B_WORK]/skia",
"env": {
diff --git a/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GN.json b/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GN.json
index 1cd02d0266..fe8c242369 100644
--- a/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GN.json
+++ b/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GN.json
@@ -93,7 +93,7 @@
"gn",
"gen",
"[CUSTOM_C:\\_B_WORK]\\skia\\out\\Build-Win-MSVC-x86-Release-GN\\Release",
- "--args=is_debug=false cc=\"cc \" cxx=\"c++ \""
+ "--args=cc=\"cc\" cxx=\"c++\" is_debug=false extra_cflags=\"\""
],
"cwd": "[CUSTOM_C:\\_B_WORK]\\skia",
"env": {