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 Android flavor utils, used for building Skia for Android with GN.""" | 7 """GN Android flavor utils, used for building Skia for Android with GN.""" |
8 class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils): | 8 class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils): |
9 def supported(self): | 9 def supported(self): |
10 return 'GN_Android' == self.m.vars.builder_cfg.get('extra_config', '') | 10 return 'GN_Android' == self.m.vars.builder_cfg.get('extra_config', '') |
11 | 11 |
12 def _run(self, title, cmd): | 12 def _run(self, title, cmd): |
13 path = self.m.vars.default_env['PATH'] | 13 path = self.m.vars.default_env['PATH'] |
14 self.m.vars.default_env = {'PATH': path} | 14 self.m.vars.default_env = {'PATH': path} |
15 self.m.run(self.m.step, title, cmd=cmd, cwd=self.m.vars.skia_dir, env={}) | 15 self.m.run(self.m.step, title, cmd=cmd, cwd=self.m.vars.skia_dir, env={}) |
16 | 16 |
17 def compile(self, unused_target, **kwargs): | 17 def compile(self, unused_target, **kwargs): |
18 compiler = self.m.vars.builder_cfg.get('compiler') | 18 compiler = self.m.vars.builder_cfg.get('compiler') |
19 configuration = self.m.vars.builder_cfg.get('configuration') | 19 configuration = self.m.vars.builder_cfg.get('configuration') |
20 os = self.m.vars.builder_cfg.get('os') | 20 os = self.m.vars.builder_cfg.get('os') |
21 target_arch = self.m.vars.builder_cfg.get('target_arch') | 21 target_arch = self.m.vars.builder_cfg.get('target_arch') |
22 | 22 |
23 assert compiler == 'Clang' # At this rate we might not ever support GCC. | 23 assert compiler == 'Clang' # At this rate we might not ever support GCC. |
24 | 24 |
25 compiler_prefix = '' | |
26 extra_cflags = [] | |
27 ccache = self.m.run.ccache() | |
28 if ccache: | |
29 compiler_prefix = ccache | |
30 extra_cflags.append('-Qunused-arguments') | |
31 | |
32 ndk_asset = 'android_ndk_linux' if os == 'Ubuntu' else 'android_ndk_darwin' | 25 ndk_asset = 'android_ndk_linux' if os == 'Ubuntu' else 'android_ndk_darwin' |
33 | 26 |
34 quote = lambda x: '"%s"' % x | 27 quote = lambda x: '"%s"' % x |
35 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted({ | 28 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted({ |
36 'compiler_prefix': quote(compiler_prefix), | |
37 'extra_cflags': quote(' '.join(extra_cflags)), | |
38 'is_debug': 'true' if configuration == 'Debug' else 'false', | 29 'is_debug': 'true' if configuration == 'Debug' else 'false', |
39 'ndk': quote(self.m.vars.slave_dir.join(ndk_asset)), | 30 'ndk': quote(self.m.vars.slave_dir.join(ndk_asset)), |
40 'target_cpu': quote(target_arch), | 31 'target_cpu': quote(target_arch), |
41 }.iteritems())) | 32 }.iteritems())) |
42 | 33 |
43 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) | 34 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) |
44 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) | 35 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) |
45 self._run('ninja', ['ninja', '-C', self.out_dir]) | 36 self._run('ninja', ['ninja', '-C', self.out_dir]) |
OLD | NEW |