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