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 | 11 |
12 return any([ | 12 return any([ |
13 'SAN' in extra_config, | 13 'SAN' in extra_config, |
14 extra_config == 'Fast', | 14 extra_config == 'Fast', |
15 extra_config == 'GN', | 15 extra_config == 'GN', |
16 extra_config.startswith('SK') | 16 extra_config.startswith('SK') |
17 ]) | 17 ]) |
18 | 18 |
19 def _run(self, title, cmd, env=None): | 19 def _run(self, title, cmd, env=None, infra_step=False): |
20 self.m.vars.default_env = {k: v for (k,v) | 20 self.m.vars.default_env = {k: v for (k,v) |
21 in self.m.vars.default_env.iteritems() | 21 in self.m.vars.default_env.iteritems() |
22 if k in ['PATH']} | 22 if k in ['PATH']} |
23 self.m.run(self.m.step, title, cmd=cmd, env=env, cwd=self.m.vars.skia_dir) | 23 self.m.run(self.m.step, title, cmd=cmd, |
| 24 env=env, cwd=self.m.vars.skia_dir, infra_step=infra_step) |
24 | 25 |
25 def compile(self, unused_target, **kwargs): | 26 def compile(self, unused_target, **kwargs): |
26 """Build Skia with GN.""" | 27 """Build Skia with GN.""" |
27 compiler = self.m.vars.builder_cfg.get('compiler', '') | 28 compiler = self.m.vars.builder_cfg.get('compiler', '') |
28 configuration = self.m.vars.builder_cfg.get('configuration', '') | 29 configuration = self.m.vars.builder_cfg.get('configuration', '') |
29 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | 30 extra_config = self.m.vars.builder_cfg.get('extra_config', '') |
30 os = self.m.vars.builder_cfg.get('os', '') | 31 os = self.m.vars.builder_cfg.get('os', '') |
31 | 32 |
32 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) | 33 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) |
33 | 34 |
(...skipping 29 matching lines...) Expand all Loading... |
63 'cxx': cxx, | 64 'cxx': cxx, |
64 'extra_cflags': ' '.join(extra_cflags), | 65 'extra_cflags': ' '.join(extra_cflags), |
65 'extra_ldflags': ' '.join(extra_ldflags), | 66 'extra_ldflags': ' '.join(extra_ldflags), |
66 'sanitize': extra_config if 'SAN' in extra_config else '', | 67 'sanitize': extra_config if 'SAN' in extra_config else '', |
67 }.iteritems(): | 68 }.iteritems(): |
68 if v: | 69 if v: |
69 args[k] = '"%s"' % v | 70 args[k] = '"%s"' % v |
70 | 71 |
71 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) | 72 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) |
72 | 73 |
73 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) | 74 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')], |
| 75 infra_step=True) |
74 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) | 76 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) |
75 self._run('ninja', ['ninja', '-C', self.out_dir]) | 77 self._run('ninja', ['ninja', '-C', self.out_dir]) |
76 | 78 |
77 def step(self, name, cmd, env=None, **kwargs): | 79 def step(self, name, cmd, env=None, **kwargs): |
78 app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0]) | 80 app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0]) |
79 cmd = [app] + cmd[1:] | 81 cmd = [app] + cmd[1:] |
80 env = {} | 82 env = {} |
81 | 83 |
82 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) | 84 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) |
83 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | 85 extra_config = self.m.vars.builder_cfg.get('extra_config', '') |
84 | 86 |
85 if 'SAN' in extra_config: | 87 if 'SAN' in extra_config: |
86 # Sanitized binaries may want to run clang_linux/bin/llvm-symbolizer. | 88 # Sanitized binaries may want to run clang_linux/bin/llvm-symbolizer. |
87 self.m.vars.default_env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin' | 89 self.m.vars.default_env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin' |
88 elif 'Ubuntu' == self.m.vars.builder_cfg.get('os', ''): | 90 elif 'Ubuntu' == self.m.vars.builder_cfg.get('os', ''): |
89 cmd = ['catchsegv'] + cmd | 91 cmd = ['catchsegv'] + cmd |
90 | 92 |
91 if 'ASAN' == extra_config: | 93 if 'ASAN' == extra_config: |
92 env[ 'ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1' | 94 env[ 'ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1' |
93 env[ 'LSAN_OPTIONS'] = 'symbolize=1 print_suppressions=1' | 95 env[ 'LSAN_OPTIONS'] = 'symbolize=1 print_suppressions=1' |
94 env['UBSAN_OPTIONS'] = 'symbolize=1 print_stacktrace=1' | 96 env['UBSAN_OPTIONS'] = 'symbolize=1 print_stacktrace=1' |
95 | 97 |
96 if 'MSAN' == extra_config: | 98 if 'MSAN' == extra_config: |
97 # Find the MSAN-built libc++. | 99 # Find the MSAN-built libc++. |
98 env['LD_LIBRARY_PATH'] = clang_linux + '/msan' | 100 env['LD_LIBRARY_PATH'] = clang_linux + '/msan' |
99 | 101 |
100 self._run(name, cmd, env=env) | 102 self._run(name, cmd, env=env) |
OLD | NEW |