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 supported(self): | 9 def supported(self): |
10 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | 10 extra_config = self.m.vars.builder_cfg.get('extra_config', '') |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 def compile(self, unused_target, **kwargs): | 23 def compile(self, unused_target, **kwargs): |
24 """Build Skia with GN.""" | 24 """Build Skia with GN.""" |
25 compiler = self.m.vars.builder_cfg.get('compiler', '') | 25 compiler = self.m.vars.builder_cfg.get('compiler', '') |
26 configuration = self.m.vars.builder_cfg.get('configuration', '') | 26 configuration = self.m.vars.builder_cfg.get('configuration', '') |
27 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | 27 extra_config = self.m.vars.builder_cfg.get('extra_config', '') |
28 os = self.m.vars.builder_cfg.get('os', '') | 28 os = self.m.vars.builder_cfg.get('os', '') |
29 | 29 |
30 cc, cxx = 'cc', 'c++' | 30 cc, cxx = 'cc', 'c++' |
31 extra_cflags = [] | 31 extra_cflags = [] |
| 32 extra_ldflags = [] |
32 | 33 |
33 if compiler == 'Clang' and os == 'Ubuntu': | 34 if compiler == 'Clang' and os == 'Ubuntu': |
34 cc = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang') | 35 cc = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang') |
35 cxx = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang++') | 36 cxx = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang++') |
| 37 extra_ldflags.append('-fuse-ld=lld') |
36 elif compiler == 'Clang': | 38 elif compiler == 'Clang': |
37 cc, cxx = 'clang', 'clang++' | 39 cc, cxx = 'clang', 'clang++' |
38 elif compiler == 'GCC': | 40 elif compiler == 'GCC': |
39 cc, cxx = 'gcc', 'g++' | 41 cc, cxx = 'gcc', 'g++' |
40 | 42 |
41 compiler_prefix = "" | 43 compiler_prefix = "" |
42 ccache = self.m.run.ccache() | 44 ccache = self.m.run.ccache() |
43 if ccache: | 45 if ccache: |
44 compiler_prefix = ccache | 46 compiler_prefix = ccache |
45 if compiler == 'Clang': | 47 if compiler == 'Clang': |
46 # Stifle "argument unused during compilation: ..." warnings. | 48 # Stifle "argument unused during compilation: ..." warnings. |
47 extra_cflags.append('-Qunused-arguments') | 49 extra_cflags.append('-Qunused-arguments') |
48 | 50 |
49 if extra_config == 'Fast': | 51 if extra_config == 'Fast': |
50 extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3']) | 52 extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3']) |
51 if extra_config.startswith('SK'): | 53 if extra_config.startswith('SK'): |
52 extra_cflags.append('-D' + extra_config) | 54 extra_cflags.append('-D' + extra_config) |
53 | 55 |
54 quote = lambda x: '"%s"' % x | 56 quote = lambda x: '"%s"' % x |
55 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted({ | 57 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted({ |
56 'cc': quote(cc), | 58 'cc': quote(cc), |
57 'cxx': quote(cxx), | 59 'cxx': quote(cxx), |
58 'compiler_prefix': quote(compiler_prefix), | 60 'compiler_prefix': quote(compiler_prefix), |
59 'extra_cflags': quote(' '.join(extra_cflags)), | 61 'extra_cflags': quote(' '.join(extra_cflags)), |
| 62 'extra_ldflags': quote(' '.join(extra_ldflags)), |
60 'is_debug': 'true' if configuration == 'Debug' else 'false', | 63 'is_debug': 'true' if configuration == 'Debug' else 'false', |
61 }.iteritems())) | 64 }.iteritems())) |
62 | 65 |
63 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) | 66 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) |
64 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) | 67 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) |
65 self._run('ninja', ['ninja', '-C', self.out_dir]) | 68 self._run('ninja', ['ninja', '-C', self.out_dir]) |
OLD | NEW |