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): | 9 def compile(self, target): |
10 """Build Skia with GN.""" | 10 """Build Skia with GN.""" |
11 # Get the gn executable. | 11 # Get the gn executable. |
12 fetch_gn = self._skia_api.skia_dir.join('bin', 'fetch-gn') | 12 fetch_gn = self.m.vars.skia_dir.join('bin', 'fetch-gn') |
13 self._skia_api.run(self._skia_api.m.step, 'fetch-gn', cmd=[fetch_gn], | 13 self.m.run(self.m.step, 'fetch-gn', cmd=[fetch_gn], |
14 cwd=self._skia_api.skia_dir) | 14 cwd=self.m.vars.skia_dir) |
15 | 15 |
16 is_debug = 'is_debug=true' | 16 is_debug = 'is_debug=true' |
17 if self._skia_api.configuration != 'Debug': | 17 if self.m.vars.configuration != 'Debug': |
18 is_debug = 'is_debug=false' | 18 is_debug = 'is_debug=false' |
19 gn_args = [is_debug] | 19 gn_args = [is_debug] |
20 | 20 |
21 is_clang = 'Clang' in self._skia_api.builder_name | 21 is_clang = 'Clang' in self.m.vars.builder_name |
22 is_gcc = 'GCC' in self._skia_api.builder_name | 22 is_gcc = 'GCC' in self.m.vars.builder_name |
23 | 23 |
24 cc, cxx = 'cc', 'c++' | 24 cc, cxx = 'cc', 'c++' |
25 if is_clang: | 25 if is_clang: |
26 cc, cxx = 'clang', 'clang++' | 26 cc, cxx = 'clang', 'clang++' |
27 elif is_gcc: | 27 elif is_gcc: |
28 cc, cxx = 'gcc', 'g++' | 28 cc, cxx = 'gcc', 'g++' |
29 | 29 |
30 ccache = self._skia_api.ccache() | 30 ccache = self.m.run.ccache() |
31 if ccache: | 31 if ccache: |
32 cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx) | 32 cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx) |
33 if is_clang: | 33 if is_clang: |
34 # Stifle "argument unused during compilation: ..." warnings. | 34 # Stifle "argument unused during compilation: ..." warnings. |
35 stifle = '-Qunused-arguments' | 35 stifle = '-Qunused-arguments' |
36 cc, cxx = '%s %s' % (cc, stifle), '%s %s' % (cxx, stifle) | 36 cc, cxx = '%s %s' % (cc, stifle), '%s %s' % (cxx, stifle) |
37 | 37 |
38 gn_args += [ 'cc="%s"' % cc, 'cxx="%s"' % cxx ] | 38 gn_args += [ 'cc="%s"' % cc, 'cxx="%s"' % cxx ] |
39 | 39 |
40 # Run gn gen. | 40 # Run gn gen. |
41 gn_exe = 'gn' | 41 gn_exe = 'gn' |
42 if self._skia_api.m.platform.is_win: | 42 if self.m.platform.is_win: |
43 gn_exe = 'gn.exe' | 43 gn_exe = 'gn.exe' |
44 gn_gen = [gn_exe, 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)] | 44 gn_gen = [gn_exe, 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)] |
45 self._skia_api.run(self._skia_api.m.step, 'gn_gen', cmd=gn_gen, | 45 self.m.run(self.m.step, 'gn_gen', cmd=gn_gen, |
46 cwd=self._skia_api.skia_dir) | 46 cwd=self.m.vars.skia_dir) |
47 | 47 |
48 # Run ninja. | 48 # Run ninja. |
49 ninja_cmd = ['ninja', '-C', self.out_dir] | 49 ninja_cmd = ['ninja', '-C', self.out_dir] |
50 self._skia_api.run(self._skia_api.m.step, 'compile %s' % target, | 50 self.m.run(self.m.step, 'compile %s' % target, |
51 cmd=ninja_cmd, | 51 cmd=ninja_cmd, |
52 cwd=self._skia_api.skia_dir) | 52 cwd=self.m.vars.skia_dir) |
rmistry
2016/08/03 14:15:16
Nit: I think the alignment here and and above need
borenet
2016/08/03 14:30:00
Done.
| |
OLD | NEW |