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, | |
14 extra_config == 'Fast', | |
13 extra_config == 'GN', | 15 extra_config == 'GN', |
14 extra_config == 'Fast', | |
15 extra_config.startswith('SK') | 16 extra_config.startswith('SK') |
16 ]) | 17 ]) |
17 | 18 |
18 def _run(self, title, cmd): | 19 def _run(self, title, cmd, env=None): |
19 path = self.m.vars.default_env['PATH'] | 20 self.m.vars.default_env = {k: v for (k,v) |
20 self.m.vars.default_env = {'PATH': path} | 21 in self.m.vars.default_env.iteritems() |
21 self.m.run(self.m.step, title, cmd=cmd, cwd=self.m.vars.skia_dir) | 22 if k in ['PATH']} |
23 self.m.run(self.m.step, title, cmd=cmd, env=env, cwd=self.m.vars.skia_dir) | |
22 | 24 |
23 def compile(self, unused_target, **kwargs): | 25 def compile(self, unused_target, **kwargs): |
24 """Build Skia with GN.""" | 26 """Build Skia with GN.""" |
25 compiler = self.m.vars.builder_cfg.get('compiler', '') | 27 compiler = self.m.vars.builder_cfg.get('compiler', '') |
26 configuration = self.m.vars.builder_cfg.get('configuration', '') | 28 configuration = self.m.vars.builder_cfg.get('configuration', '') |
27 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | 29 extra_config = self.m.vars.builder_cfg.get('extra_config', '') |
28 os = self.m.vars.builder_cfg.get('os', '') | 30 os = self.m.vars.builder_cfg.get('os', '') |
29 | 31 |
32 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) | |
borenet
2016/09/08 14:47:33
Why str() instead of using pathObj.join(...) ?
mtklein
2016/09/08 14:51:10
Just seems easier to convert to string here once t
borenet
2016/09/08 15:06:39
Ok, I'm not sure that str(pathObj) will resolve th
| |
33 | |
30 cc, cxx = None, None | 34 cc, cxx = None, None |
31 extra_cflags = [] | 35 extra_cflags = [] |
32 extra_ldflags = [] | 36 extra_ldflags = [] |
33 | 37 |
34 if compiler == 'Clang' and os == 'Ubuntu': | 38 if compiler == 'Clang' and os == 'Ubuntu': |
35 cc = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang') | 39 cc = clang_linux + '/bin/clang' |
36 cxx = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang++') | 40 cxx = clang_linux + '/bin/clang++' |
37 extra_ldflags.append('-fuse-ld=lld') | 41 extra_ldflags.append('-fuse-ld=lld') |
38 elif compiler == 'Clang': | 42 elif compiler == 'Clang': |
39 cc, cxx = 'clang', 'clang++' | 43 cc, cxx = 'clang', 'clang++' |
40 elif compiler == 'GCC': | 44 elif compiler == 'GCC': |
41 cc, cxx = 'gcc', 'g++' | 45 cc, cxx = 'gcc', 'g++' |
42 | 46 |
43 if extra_config == 'Fast': | 47 if extra_config == 'Fast': |
44 extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3']) | 48 extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3']) |
45 if extra_config.startswith('SK'): | 49 if extra_config.startswith('SK'): |
46 extra_cflags.append('-D' + extra_config) | 50 extra_cflags.append('-D' + extra_config) |
51 if extra_config == 'MSAN': | |
52 extra_ldflags.append('-L' + clang_linux + '/msan') | |
47 | 53 |
48 args = {} | 54 args = {} |
49 | 55 |
50 if configuration != 'Debug': | 56 if configuration != 'Debug': |
51 args['is_debug'] = 'false' | 57 args['is_debug'] = 'false' |
58 if extra_config == 'MSAN': | |
59 args['skia_use_fontconfig'] = 'false' | |
52 | 60 |
53 for (k,v) in { | 61 for (k,v) in { |
54 'cc': cc, | 62 'cc': cc, |
55 'cxx': cxx, | 63 'cxx': cxx, |
56 'extra_cflags': ' '.join(extra_cflags), | 64 'extra_cflags': ' '.join(extra_cflags), |
57 'extra_ldflags': ' '.join(extra_ldflags), | 65 'extra_ldflags': ' '.join(extra_ldflags), |
66 'sanitize': extra_config if 'SAN' in extra_config else '', | |
58 }.iteritems(): | 67 }.iteritems(): |
59 if v: | 68 if v: |
60 args[k] = '"%s"' % v | 69 args[k] = '"%s"' % v |
61 | 70 |
62 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) | 71 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) |
63 | 72 |
64 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) | 73 self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')]) |
65 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) | 74 self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args]) |
66 self._run('ninja', ['ninja', '-C', self.out_dir]) | 75 self._run('ninja', ['ninja', '-C', self.out_dir]) |
76 | |
77 def step(self, name, cmd, env=None, **kwargs): | |
78 app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0]) | |
79 cmd = [app] + cmd[1:] | |
80 env = {} | |
81 | |
82 clang_linux = str(self.m.vars.slave_dir.join('clang_linux')) | |
83 extra_config = self.m.vars.builder_cfg.get('extra_config', '') | |
84 | |
85 if 'SAN' in extra_config: | |
86 # Sanitized binaries may want to run clang_linux/bin/llvm-symbolizer. | |
87 self.m.vars.default_env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin' | |
88 elif 'Ubuntu' == self.m.vars.builder_cfg.get('os', ''): | |
89 cmd = ['catchsegv'] + cmd | |
90 | |
91 if 'ASAN' == extra_config: | |
92 env[ 'ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1' | |
93 env[ 'LSAN_OPTIONS'] = 'symbolize=1 print_suppressions=1' | |
94 env['UBSAN_OPTIONS'] = 'symbolize=1 print_stacktrace=1' | |
95 | |
96 if 'MSAN' == extra_config: | |
97 # Find the MSAN-built libc++. | |
98 env['LD_LIBRARY_PATH'] = clang_linux + '/msan' | |
99 | |
100 self._run(name, cmd, env=env) | |
OLD | NEW |