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