OLD | NEW |
---|---|
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 compile(self, target, **kwargs): | 9 def supported(self): |
10 has = lambda s: s in self.m.vars.builder_name | |
borenet
2016/08/11 12:29:47
Please change this to target a specific portion of
| |
11 | |
12 return has('GN') or any([ | |
13 has('Fast'), | |
14 has('-SK'), | |
15 ]) | |
16 | |
17 def compile(self, unused_target, **kwargs): | |
10 """Build Skia with GN.""" | 18 """Build Skia with GN.""" |
11 # Get the gn executable. | 19 has = lambda s: s in self.m.vars.builder_name |
borenet
2016/08/11 12:29:47
Same here.
| |
12 fetch_gn = self.m.vars.skia_dir.join('bin', 'fetch-gn') | 20 run = lambda title, cmd: self.m.run(self.m.step, title, cmd=cmd, |
13 self.m.run(self.m.step, 'fetch-gn', | 21 cwd=self.m.vars.skia_dir, **kwargs) |
14 cmd=[fetch_gn], | |
15 cwd=self.m.vars.skia_dir, | |
16 **kwargs) | |
17 | 22 |
18 is_debug = 'is_debug=true' | 23 gn_args = [] |
19 if self.m.vars.configuration != 'Debug': | 24 if not has('Debug'): |
20 is_debug = 'is_debug=false' | 25 gn_args.append('is_debug=false') |
21 gn_args = [is_debug] | |
22 | |
23 is_clang = 'Clang' in self.m.vars.builder_name | |
24 is_gcc = 'GCC' in self.m.vars.builder_name | |
25 | 26 |
26 cc, cxx = 'cc', 'c++' | 27 cc, cxx = 'cc', 'c++' |
27 if is_clang: | 28 cflags = [] |
29 | |
30 if has('Clang'): | |
28 cc, cxx = 'clang', 'clang++' | 31 cc, cxx = 'clang', 'clang++' |
29 elif is_gcc: | 32 elif has('GCC'): |
30 cc, cxx = 'gcc', 'g++' | 33 cc, cxx = 'gcc', 'g++' |
31 | 34 |
32 ccache = self.m.run.ccache() | 35 ccache = self.m.run.ccache() |
33 if ccache: | 36 if ccache: |
34 cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx) | 37 cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx) |
35 if is_clang: | 38 if has('Clang'): |
36 # Stifle "argument unused during compilation: ..." warnings. | 39 # Stifle "argument unused during compilation: ..." warnings. |
37 stifle = '-Qunused-arguments' | 40 cflags.append('-Qunused-arguments') |
38 cc, cxx = '%s %s' % (cc, stifle), '%s %s' % (cxx, stifle) | |
39 | 41 |
40 gn_args += [ 'cc="%s"' % cc, 'cxx="%s"' % cxx ] | 42 if has('Fast'): |
43 cflags.extend(['-march=native', '-fomit-frame-pointer']) | |
44 if has('-SK'): | |
45 cflags.append('-D' + self.m.vars.builder_cfg['extra_config']) | |
41 | 46 |
42 # Run gn gen. | 47 cflags = ' '.join(cflags) |
43 gn_exe = 'gn' | 48 gn_args += [ 'cc="%s %s"' % (cc, cflags), 'cxx="%s %s"' % (cxx, cflags) ] |
44 if self.m.platform.is_win: | |
45 gn_exe = 'gn.exe' | |
46 gn_gen = [gn_exe, 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)] | |
47 self.m.run(self.m.step, 'gn_gen', cmd=gn_gen, | |
48 cwd=self.m.vars.skia_dir, **kwargs) | |
49 | 49 |
50 # Run ninja. | 50 run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) |
51 ninja_cmd = ['ninja', '-C', self.out_dir] | 51 run('gn gen', ['gn', 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)]) |
52 self.m.run(self.m.step, 'compile %s' % target, | 52 run('ninja', ['ninja', '-C', self.out_dir]) |
53 cmd=ninja_cmd, | |
54 cwd=self.m.vars.skia_dir, | |
55 **kwargs) | |
OLD | NEW |