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