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._skia_api.skia_dir.join('bin', 'fetch-gn') |
13 self._skia_api.run(self._skia_api.m.step, 'fetch-gn', cmd=[fetch_gn], | 13 self._skia_api.run(self._skia_api.m.step, 'fetch-gn', cmd=[fetch_gn], |
14 cwd=self._skia_api.skia_dir) | 14 cwd=self._skia_api.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._skia_api.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 cc, cxx = 'cc', 'c++' | 21 cc, cxx = 'cc', 'c++' |
22 if 'Clang' in self._skia_api.builder_name: | 22 if 'Clang' in self._skia_api.builder_name: |
23 cc, cxx = 'clang', 'clang++' | 23 cc, cxx = 'clang', 'clang++' |
24 elif 'GCC' in self._skia_api.builder_name: | 24 elif 'GCC' in self._skia_api.builder_name: |
25 cc, cxx = 'gcc', 'g++' | 25 cc, cxx = 'gcc', 'g++' |
26 | 26 |
27 ccache = self._skia_api.ccache() | 27 ccache = self._skia_api.ccache() |
28 if ccache: | 28 if ccache: |
29 cc, cxx = '"%s %s"' % (ccache, cc), '"%s %s"' % (ccache, cxx) | 29 cc, cxx = '%s %s' % (ccache, cc), '%s %s' % (ccache, cxx) |
30 | 30 |
31 gn_args += [ 'cc=' + cc, 'cxx=' + cxx ] | 31 gn_args += [ 'cc="%s"' % cc, 'cxx="%s"' % cxx ] |
32 | 32 |
33 # Run gn gen. | 33 # Run gn gen. |
34 gn_exe = 'gn' | 34 gn_exe = 'gn' |
35 if self._skia_api.m.platform.is_win: | 35 if self._skia_api.m.platform.is_win: |
36 gn_exe = 'gn.exe' | 36 gn_exe = 'gn.exe' |
37 gn_gen = [gn_exe, 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)] | 37 gn_gen = [gn_exe, 'gen', self.out_dir, '--args=%s' % ' '.join(gn_args)] |
38 self._skia_api.run(self._skia_api.m.step, 'gn_gen', cmd=gn_gen, | 38 self._skia_api.run(self._skia_api.m.step, 'gn_gen', cmd=gn_gen, |
39 cwd=self._skia_api.skia_dir) | 39 cwd=self._skia_api.skia_dir) |
40 | 40 |
41 # Run ninja. | 41 # Run ninja. |
42 ninja_cmd = ['ninja', '-C', self.out_dir] | 42 ninja_cmd = ['ninja', '-C', self.out_dir] |
43 self._skia_api.run(self._skia_api.m.step, 'compile %s' % target, | 43 self._skia_api.run(self._skia_api.m.step, 'compile %s' % target, |
44 cmd=ninja_cmd, | 44 cmd=ninja_cmd, |
45 cwd=self._skia_api.skia_dir) | 45 cwd=self._skia_api.skia_dir) |
OLD | NEW |