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', '') |
| 11 os = self.m.vars.builder_cfg.get('os', '') |
| 12 target_arch = self.m.vars.builder_cfg.get('target_arch', '') |
11 | 13 |
12 return any([ | 14 return any([ |
13 'SAN' in extra_config, | 15 'SAN' in extra_config, |
14 extra_config == 'Fast', | 16 extra_config == 'Fast', |
15 extra_config == 'GN', | 17 extra_config == 'GN', |
16 extra_config.startswith('SK') | 18 extra_config.startswith('SK'), |
| 19 os == 'Ubuntu' and target_arch == 'x86', |
17 ]) | 20 ]) |
18 | 21 |
19 def _run(self, title, cmd, env=None, infra_step=False): | 22 def _run(self, title, cmd, env=None, infra_step=False): |
20 self.m.vars.default_env = {k: v for (k,v) | 23 self.m.vars.default_env = {k: v for (k,v) |
21 in self.m.vars.default_env.iteritems() | 24 in self.m.vars.default_env.iteritems() |
22 if k in ['PATH']} | 25 if k in ['PATH']} |
23 self.m.run(self.m.step, title, cmd=cmd, | 26 self.m.run(self.m.step, title, cmd=cmd, |
24 env=env, cwd=self.m.vars.skia_dir, infra_step=infra_step) | 27 env=env, cwd=self.m.vars.skia_dir, infra_step=infra_step) |
25 | 28 |
26 def compile(self, unused_target, **kwargs): | 29 def compile(self, unused_target, **kwargs): |
27 """Build Skia with GN.""" | 30 """Build Skia with GN.""" |
28 compiler = self.m.vars.builder_cfg.get('compiler', '') | 31 compiler = self.m.vars.builder_cfg.get('compiler', '') |
29 configuration = self.m.vars.builder_cfg.get('configuration', '') | 32 configuration = self.m.vars.builder_cfg.get('configuration', '') |
30 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | 33 extra_config = self.m.vars.builder_cfg.get('extra_config', '') |
31 os = self.m.vars.builder_cfg.get('os', '') | 34 os = self.m.vars.builder_cfg.get('os', '') |
| 35 target_arch = self.m.vars.builder_cfg.get('target_arch', '') |
32 | 36 |
33 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) | 37 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) |
34 | 38 |
35 cc, cxx = None, None | 39 cc, cxx = None, None |
36 extra_cflags = [] | 40 extra_cflags = [] |
37 extra_ldflags = [] | 41 extra_ldflags = [] |
38 | 42 |
39 if compiler == 'Clang' and os == 'Ubuntu': | 43 if compiler == 'Clang' and os == 'Ubuntu': |
40 cc = clang_linux + '/bin/clang' | 44 cc = clang_linux + '/bin/clang' |
41 cxx = clang_linux + '/bin/clang++' | 45 cxx = clang_linux + '/bin/clang++' |
(...skipping 16 matching lines...) Expand all Loading... |
58 args['is_debug'] = 'false' | 62 args['is_debug'] = 'false' |
59 if extra_config == 'MSAN': | 63 if extra_config == 'MSAN': |
60 args['skia_use_fontconfig'] = 'false' | 64 args['skia_use_fontconfig'] = 'false' |
61 | 65 |
62 for (k,v) in { | 66 for (k,v) in { |
63 'cc': cc, | 67 'cc': cc, |
64 'cxx': cxx, | 68 'cxx': cxx, |
65 'extra_cflags': ' '.join(extra_cflags), | 69 'extra_cflags': ' '.join(extra_cflags), |
66 'extra_ldflags': ' '.join(extra_ldflags), | 70 'extra_ldflags': ' '.join(extra_ldflags), |
67 'sanitize': extra_config if 'SAN' in extra_config else '', | 71 'sanitize': extra_config if 'SAN' in extra_config else '', |
| 72 'target_cpu': 'x86' if target_arch == 'x86' else '', |
68 }.iteritems(): | 73 }.iteritems(): |
69 if v: | 74 if v: |
70 args[k] = '"%s"' % v | 75 args[k] = '"%s"' % v |
71 | 76 |
72 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) | 77 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) |
73 | 78 |
74 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')], | 79 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')], |
75 infra_step=True) | 80 infra_step=True) |
76 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) | 81 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) |
77 self._run('ninja', ['ninja', '-C', self.out_dir]) | 82 self._run('ninja', ['ninja', '-C', self.out_dir]) |
(...skipping 15 matching lines...) Expand all Loading... |
93 if 'ASAN' == extra_config: | 98 if 'ASAN' == extra_config: |
94 env[ 'ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1' | 99 env[ 'ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1' |
95 env[ 'LSAN_OPTIONS'] = 'symbolize=1 print_suppressions=1' | 100 env[ 'LSAN_OPTIONS'] = 'symbolize=1 print_suppressions=1' |
96 env['UBSAN_OPTIONS'] = 'symbolize=1 print_stacktrace=1' | 101 env['UBSAN_OPTIONS'] = 'symbolize=1 print_stacktrace=1' |
97 | 102 |
98 if 'MSAN' == extra_config: | 103 if 'MSAN' == extra_config: |
99 # Find the MSAN-built libc++. | 104 # Find the MSAN-built libc++. |
100 env['LD_LIBRARY_PATH'] = clang_linux + '/msan' | 105 env['LD_LIBRARY_PATH'] = clang_linux + '/msan' |
101 | 106 |
102 self._run(name, cmd, env=env) | 107 self._run(name, cmd, env=env) |
OLD | NEW |