OLD | NEW |
---|---|
(Empty) | |
1 # | |
2 # Copyright 2015 Google Inc. | |
3 # | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 # | |
7 | |
8 #!/usr/bin/env python | |
9 | |
10 usage = ''' | |
11 Write buildbot spec to outfile based on the bot name: | |
12 $ python buildbot_spec.py outfile Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug | |
13 Or run self-tests: | |
14 $ python buildbot_spec.py test | |
15 ''' | |
16 | |
17 import inspect | |
18 import json | |
19 import os | |
20 import sys | |
21 | |
22 import builder_name_schema | |
23 | |
24 | |
25 def lineno(): | |
26 caller = inspect.stack()[1] # Up one level to our caller. | |
27 return inspect.getframeinfo(caller[0]).lineno | |
28 | |
29 # Since we don't actually start coverage until we're in the self-test, | |
30 # some function def lines aren't reported as covered. Add them to this | |
31 # list so that we can ignore them. | |
32 cov_skip = [] | |
33 | |
34 cov_start = lineno()+1 # We care about coverage starting just past this def. | |
35 def gyp_defines(builder_dict): | |
borenet
2015/07/29 13:38:57
These functions are copied verbatim from https://c
| |
36 gyp_defs = {} | |
37 | |
38 # skia_arch_type. | |
39 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_BUILD: | |
40 arch = builder_dict['target_arch'] | |
41 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER: | |
42 arch = None | |
43 else: | |
44 arch = builder_dict['arch'] | |
45 | |
46 arch_types = { | |
47 'x86': 'x86', | |
48 'x86_64': 'x86_64', | |
49 'Arm7': 'arm', | |
50 'Arm64': 'arm64', | |
51 'Mips': 'mips32', | |
52 'Mips64': 'mips64', | |
53 'MipsDSP2': 'mips32', | |
54 } | |
55 if arch in arch_types: | |
56 gyp_defs['skia_arch_type'] = arch_types[arch] | |
57 | |
58 # housekeeper: build shared lib. | |
59 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER: | |
60 gyp_defs['skia_shared_lib'] = '1' | |
61 | |
62 # skia_gpu. | |
63 if builder_dict.get('cpu_or_gpu') == 'CPU': | |
64 gyp_defs['skia_gpu'] = '0' | |
65 | |
66 # skia_warnings_as_errors. | |
67 werr = False | |
68 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_BUILD: | |
69 if 'Win' in builder_dict.get('os', ''): | |
70 if not ('GDI' in builder_dict.get('extra_config', '') or | |
71 'Exceptions' in builder_dict.get('extra_config', '')): | |
72 werr = True | |
73 elif ('Mac' in builder_dict.get('os', '') and | |
74 'Android' in builder_dict.get('extra_config', '')): | |
75 werr = False | |
76 else: | |
77 werr = True | |
78 gyp_defs['skia_warnings_as_errors'] = str(int(werr)) # True/False -> '1'/'0' | |
79 | |
80 # Win debugger. | |
81 if 'Win' in builder_dict.get('os', ''): | |
82 gyp_defs['skia_win_debuggers_path'] = 'c:/DbgHelp' | |
83 | |
84 # Qt SDK (Win). | |
85 if 'Win' in builder_dict.get('os', ''): | |
86 if builder_dict.get('os') == 'Win8': | |
87 gyp_defs['qt_sdk'] = 'C:/Qt/Qt5.1.0/5.1.0/msvc2012_64/' | |
88 else: | |
89 gyp_defs['qt_sdk'] = 'C:/Qt/4.8.5/' | |
90 | |
91 # ANGLE. | |
92 if builder_dict.get('extra_config') == 'ANGLE': | |
93 gyp_defs['skia_angle'] = '1' | |
94 | |
95 # GDI. | |
96 if builder_dict.get('extra_config') == 'GDI': | |
97 gyp_defs['skia_gdi'] = '1' | |
98 | |
99 # Build with Exceptions on Windows. | |
100 if ('Win' in builder_dict.get('os', '') and | |
101 builder_dict.get('extra_config') == 'Exceptions'): | |
102 gyp_defs['skia_win_exceptions'] = '1' | |
103 | |
104 # iOS. | |
105 if (builder_dict.get('os') == 'iOS' or | |
106 builder_dict.get('extra_config') == 'iOS'): | |
107 gyp_defs['skia_os'] = 'ios' | |
108 | |
109 # Shared library build. | |
110 if builder_dict.get('extra_config') == 'Shared': | |
111 gyp_defs['skia_shared_lib'] = '1' | |
112 | |
113 # PDF viewer in GM. | |
114 if (builder_dict.get('os') == 'Mac10.8' and | |
115 builder_dict.get('arch') == 'x86_64' and | |
116 builder_dict.get('configuration') == 'Release'): | |
117 gyp_defs['skia_run_pdfviewer_in_gm'] = '1' | |
118 | |
119 # Clang. | |
120 if builder_dict.get('compiler') == 'Clang': | |
121 gyp_defs['skia_clang_build'] = '1' | |
122 | |
123 # Valgrind. | |
124 if 'Valgrind' in builder_dict.get('extra_config', ''): | |
125 gyp_defs['skia_release_optimization_level'] = '1' | |
126 | |
127 # Link-time code generation just wastes time on compile-only bots. | |
128 if (builder_dict.get('role') == builder_name_schema.BUILDER_ROLE_BUILD and | |
129 builder_dict.get('compiler') == 'MSVC'): | |
130 gyp_defs['skia_win_ltcg'] = '0' | |
131 | |
132 # Mesa. | |
133 if (builder_dict.get('extra_config') == 'Mesa' or | |
134 builder_dict.get('cpu_or_gpu_value') == 'Mesa'): | |
135 gyp_defs['skia_mesa'] = '1' | |
136 | |
137 # SKNX_NO_SIMD | |
138 if builder_dict.get('extra_config') == 'SKNX_NO_SIMD': | |
139 gyp_defs['sknx_no_simd'] = '1' | |
140 | |
141 # skia_use_android_framework_defines. | |
142 if builder_dict.get('extra_config') == 'Android_FrameworkDefs': | |
143 gyp_defs['skia_use_android_framework_defines'] = '1' | |
144 | |
145 return gyp_defs | |
146 | |
147 | |
148 cov_skip.extend([lineno(), lineno() + 1]) | |
149 def get_extra_env_vars(builder_dict): | |
150 env = {} | |
151 if builder_dict.get('compiler') == 'Clang': | |
152 env['CC'] = '/usr/bin/clang' | |
153 env['CXX'] = '/usr/bin/clang++' | |
154 return env | |
155 | |
156 | |
157 cov_skip.extend([lineno(), lineno() + 1]) | |
158 def build_targets_from_builder_dict(builder_dict): | |
159 """Return a list of targets to build, depending on the builder type.""" | |
160 if builder_dict['role'] in ('Test', 'Perf') and builder_dict['os'] == 'iOS': | |
161 return ['iOSShell'] | |
162 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_TEST: | |
163 return ['dm', 'nanobench'] | |
mtklein
2015/07/29 13:47:52
It occurs to me that Release test bots don't run n
borenet
2015/07/29 13:57:11
Good catch. Removed.
| |
164 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_PERF: | |
165 return ['nanobench'] | |
166 else: | |
167 return ['most'] | |
168 | |
169 | |
170 cov_skip.extend([lineno(), lineno() + 1]) | |
171 def get_builder_spec(builder_name): | |
172 builder_dict = builder_name_schema.DictForBuilderName(builder_name) | |
173 env = get_extra_env_vars(builder_dict) | |
174 gyp_defs = gyp_defines(builder_dict) | |
175 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()] | |
176 gyp_defs_list.sort() | |
177 env['GYP_DEFINES'] = ' '.join(gyp_defs_list) | |
178 return { | |
179 'build_targets': build_targets_from_builder_dict(builder_dict), | |
180 'env': env, | |
181 } | |
182 | |
183 | |
184 cov_end = lineno() # Don't care about code coverage past here. | |
185 | |
186 | |
187 def self_test(): | |
188 import coverage # This way the bots don't need coverage.py to be installed. | |
189 args = {} | |
190 cases = [ | |
191 'Build-Mac10.8-Clang-Arm7-Debug-Android', | |
192 'Build-Win-MSVC-x86-Debug', | |
193 'Build-Win-MSVC-x86-Debug-GDI', | |
194 'Build-Win-MSVC-x86-Debug-Exceptions', | |
195 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs', | |
196 'Build-Ubuntu-GCC-x86_64-Release-Mesa', | |
197 'Housekeeper-PerCommit', | |
198 'Perf-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Release-Trybot', | |
199 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug', | |
200 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release', | |
201 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD', | |
202 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared', | |
203 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind', | |
204 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE', | |
205 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug', | |
206 ] | |
207 | |
208 cov = coverage.coverage() | |
209 cov.start() | |
210 for case in cases: | |
211 args[case] = get_builder_spec(case) | |
212 cov.stop() | |
213 | |
214 this_file = os.path.basename(__file__) | |
215 _, _, not_run, _ = cov.analysis(this_file) | |
216 filtered = [line for line in not_run if | |
217 line > cov_start and line < cov_end and line not in cov_skip] | |
218 if filtered: | |
219 print 'Lines not covered by test cases: ', filtered | |
220 sys.exit(1) | |
221 | |
222 golden = this_file.replace('.py', '.json') | |
223 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f: | |
224 json.dump(args, f, indent=2, sort_keys=True) | |
225 | |
226 | |
227 if __name__ == '__main__': | |
228 if len(sys.argv) == 2 and sys.argv[1] == 'test': | |
229 self_test() | |
230 sys.exit(0) | |
231 | |
232 if len(sys.argv) != 3: | |
233 print usage | |
234 sys.exit(1) | |
235 | |
236 with open(sys.argv[1], 'w') as out: | |
237 json.dump(get_builder_spec(sys.argv[2]), out) | |
OLD | NEW |