Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: infra/bots/recipe_modules/flavor/gn_flavor.py

Issue 2324573002: GN: do not set default GN args (Closed)
Patch Set: is_debug too Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | infra/bots/recipes/swarm_compile.expected/Build-Mac-Clang-x86_64-Release-GN.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import default_flavor 5 import default_flavor
6 6
7 """GN flavor utils, used for building Skia with GN.""" 7 """GN flavor utils, used for building Skia with GN."""
8 class GNFlavorUtils(default_flavor.DefaultFlavorUtils): 8 class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
9 def supported(self): 9 def supported(self):
10 extra_config = self.m.vars.builder_cfg.get('extra_config', '') 10 extra_config = self.m.vars.builder_cfg.get('extra_config', '')
11 11
12 return any([ 12 return any([
13 extra_config == 'GN', 13 extra_config == 'GN',
14 extra_config == 'Fast', 14 extra_config == 'Fast',
15 extra_config.startswith('SK') 15 extra_config.startswith('SK')
16 ]) 16 ])
17 17
18 def _run(self, title, cmd): 18 def _run(self, title, cmd):
19 path = self.m.vars.default_env['PATH'] 19 path = self.m.vars.default_env['PATH']
20 self.m.vars.default_env = {'PATH': path} 20 self.m.vars.default_env = {'PATH': path}
21 self.m.run(self.m.step, title, cmd=cmd, cwd=self.m.vars.skia_dir) 21 self.m.run(self.m.step, title, cmd=cmd, cwd=self.m.vars.skia_dir)
22 22
23 def compile(self, unused_target, **kwargs): 23 def compile(self, unused_target, **kwargs):
24 """Build Skia with GN.""" 24 """Build Skia with GN."""
25 compiler = self.m.vars.builder_cfg.get('compiler', '') 25 compiler = self.m.vars.builder_cfg.get('compiler', '')
26 configuration = self.m.vars.builder_cfg.get('configuration', '') 26 configuration = self.m.vars.builder_cfg.get('configuration', '')
27 extra_config = self.m.vars.builder_cfg.get('extra_config', '') 27 extra_config = self.m.vars.builder_cfg.get('extra_config', '')
28 os = self.m.vars.builder_cfg.get('os', '') 28 os = self.m.vars.builder_cfg.get('os', '')
29 29
30 cc, cxx = 'cc', 'c++' 30 cc, cxx = None, None
31 extra_cflags = [] 31 extra_cflags = []
32 extra_ldflags = [] 32 extra_ldflags = []
33 33
34 if compiler == 'Clang' and os == 'Ubuntu': 34 if compiler == 'Clang' and os == 'Ubuntu':
35 cc = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang') 35 cc = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang')
36 cxx = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang++') 36 cxx = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang++')
37 extra_ldflags.append('-fuse-ld=lld') 37 extra_ldflags.append('-fuse-ld=lld')
38 elif compiler == 'Clang': 38 elif compiler == 'Clang':
39 cc, cxx = 'clang', 'clang++' 39 cc, cxx = 'clang', 'clang++'
40 elif compiler == 'GCC': 40 elif compiler == 'GCC':
41 cc, cxx = 'gcc', 'g++' 41 cc, cxx = 'gcc', 'g++'
42 42
43 if extra_config == 'Fast': 43 if extra_config == 'Fast':
44 extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3']) 44 extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3'])
45 if extra_config.startswith('SK'): 45 if extra_config.startswith('SK'):
46 extra_cflags.append('-D' + extra_config) 46 extra_cflags.append('-D' + extra_config)
47 47
48 quote = lambda x: '"%s"' % x 48 args = {}
49 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted({ 49
50 'cc': quote(cc), 50 if configuration != 'Debug':
51 'cxx': quote(cxx), 51 args['is_debug'] = 'false'
52 'extra_cflags': quote(' '.join(extra_cflags)), 52
53 'extra_ldflags': quote(' '.join(extra_ldflags)), 53 for (k,v) in {
54 'is_debug': 'true' if configuration == 'Debug' else 'false', 54 'cc': cc,
55 }.iteritems())) 55 'cxx': cxx,
56 'extra_cflags': ' '.join(extra_cflags),
57 'extra_ldflags': ' '.join(extra_ldflags),
58 }.iteritems():
59 if v:
60 args[k] = '"%s"' % v
61
62 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems()))
56 63
57 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) 64 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')])
58 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) 65 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args])
59 self._run('ninja', ['ninja', '-C', self.out_dir]) 66 self._run('ninja', ['ninja', '-C', self.out_dir])
OLDNEW
« no previous file with comments | « no previous file | infra/bots/recipes/swarm_compile.expected/Build-Mac-Clang-x86_64-Release-GN.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698