Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tools/buildbot_spec.py

Issue 1269023007: Cherry-pick buildbot_spec.py onto m45 (Closed) Base URL: https://skia.googlesource.com/skia.git@m45
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/buildbot_spec.json ('k') | tools/builder_name_schema.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 import dm_flags
24 import nanobench_flags
25
26
27 CONFIG_DEBUG = 'Debug'
28 CONFIG_RELEASE = 'Release'
29
30
31 def lineno():
32 caller = inspect.stack()[1] # Up one level to our caller.
33 return inspect.getframeinfo(caller[0]).lineno
34
35 # Since we don't actually start coverage until we're in the self-test,
36 # some function def lines aren't reported as covered. Add them to this
37 # list so that we can ignore them.
38 cov_skip = []
39
40 cov_start = lineno()+1 # We care about coverage starting just past this def.
41 def gyp_defines(builder_dict):
42 gyp_defs = {}
43
44 # skia_arch_type.
45 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_BUILD:
46 arch = builder_dict['target_arch']
47 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
48 arch = None
49 else:
50 arch = builder_dict['arch']
51
52 arch_types = {
53 'x86': 'x86',
54 'x86_64': 'x86_64',
55 'Arm7': 'arm',
56 'Arm64': 'arm64',
57 'Mips': 'mips32',
58 'Mips64': 'mips64',
59 'MipsDSP2': 'mips32',
60 }
61 if arch in arch_types:
62 gyp_defs['skia_arch_type'] = arch_types[arch]
63
64 # housekeeper: build shared lib.
65 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
66 gyp_defs['skia_shared_lib'] = '1'
67
68 # skia_gpu.
69 if builder_dict.get('cpu_or_gpu') == 'CPU':
70 gyp_defs['skia_gpu'] = '0'
71
72 # skia_warnings_as_errors.
73 werr = False
74 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_BUILD:
75 if 'Win' in builder_dict.get('os', ''):
76 if not ('GDI' in builder_dict.get('extra_config', '') or
77 'Exceptions' in builder_dict.get('extra_config', '')):
78 werr = True
79 elif ('Mac' in builder_dict.get('os', '') and
80 'Android' in builder_dict.get('extra_config', '')):
81 werr = False
82 else:
83 werr = True
84 gyp_defs['skia_warnings_as_errors'] = str(int(werr)) # True/False -> '1'/'0'
85
86 # Win debugger.
87 if 'Win' in builder_dict.get('os', ''):
88 gyp_defs['skia_win_debuggers_path'] = 'c:/DbgHelp'
89
90 # Qt SDK (Win).
91 if 'Win' in builder_dict.get('os', ''):
92 if builder_dict.get('os') == 'Win8':
93 gyp_defs['qt_sdk'] = 'C:/Qt/Qt5.1.0/5.1.0/msvc2012_64/'
94 else:
95 gyp_defs['qt_sdk'] = 'C:/Qt/4.8.5/'
96
97 # ANGLE.
98 if builder_dict.get('extra_config') == 'ANGLE':
99 gyp_defs['skia_angle'] = '1'
100
101 # GDI.
102 if builder_dict.get('extra_config') == 'GDI':
103 gyp_defs['skia_gdi'] = '1'
104
105 # Build with Exceptions on Windows.
106 if ('Win' in builder_dict.get('os', '') and
107 builder_dict.get('extra_config') == 'Exceptions'):
108 gyp_defs['skia_win_exceptions'] = '1'
109
110 # iOS.
111 if (builder_dict.get('os') == 'iOS' or
112 builder_dict.get('extra_config') == 'iOS'):
113 gyp_defs['skia_os'] = 'ios'
114
115 # Shared library build.
116 if builder_dict.get('extra_config') == 'Shared':
117 gyp_defs['skia_shared_lib'] = '1'
118
119 # PDF viewer in GM.
120 if (builder_dict.get('os') == 'Mac10.8' and
121 builder_dict.get('arch') == 'x86_64' and
122 builder_dict.get('configuration') == 'Release'):
123 gyp_defs['skia_run_pdfviewer_in_gm'] = '1'
124
125 # Clang.
126 if builder_dict.get('compiler') == 'Clang':
127 gyp_defs['skia_clang_build'] = '1'
128
129 # Valgrind.
130 if 'Valgrind' in builder_dict.get('extra_config', ''):
131 gyp_defs['skia_release_optimization_level'] = '1'
132
133 # Link-time code generation just wastes time on compile-only bots.
134 if (builder_dict.get('role') == builder_name_schema.BUILDER_ROLE_BUILD and
135 builder_dict.get('compiler') == 'MSVC'):
136 gyp_defs['skia_win_ltcg'] = '0'
137
138 # Mesa.
139 if (builder_dict.get('extra_config') == 'Mesa' or
140 builder_dict.get('cpu_or_gpu_value') == 'Mesa'):
141 gyp_defs['skia_mesa'] = '1'
142
143 # SKNX_NO_SIMD
144 if builder_dict.get('extra_config') == 'SKNX_NO_SIMD':
145 gyp_defs['sknx_no_simd'] = '1'
146
147 # skia_use_android_framework_defines.
148 if builder_dict.get('extra_config') == 'Android_FrameworkDefs':
149 gyp_defs['skia_use_android_framework_defines'] = '1'
150
151 return gyp_defs
152
153
154 cov_skip.extend([lineno(), lineno() + 1])
155 def get_extra_env_vars(builder_dict):
156 env = {}
157 if builder_dict.get('configuration') == 'Coverage':
158 # We have to use Clang 3.6 because earlier versions do not support the
159 # compile flags we use and 3.7 and 3.8 hit asserts during compilation.
160 env['CC'] = '/usr/bin/clang-3.6'
161 env['CXX'] = '/usr/bin/clang++-3.6'
162 elif builder_dict.get('compiler') == 'Clang':
163 env['CC'] = '/usr/bin/clang'
164 env['CXX'] = '/usr/bin/clang++'
165 return env
166
167
168 cov_skip.extend([lineno(), lineno() + 1])
169 def build_targets_from_builder_dict(builder_dict):
170 """Return a list of targets to build, depending on the builder type."""
171 if builder_dict['role'] in ('Test', 'Perf') and builder_dict['os'] == 'iOS':
172 return ['iOSShell']
173 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_TEST:
174 t = ['dm']
175 if builder_dict.get('configuration') == 'Debug':
176 t.append('nanobench')
177 return t
178 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_PERF:
179 return ['nanobench']
180 else:
181 return ['most']
182
183
184 cov_skip.extend([lineno(), lineno() + 1])
185 def device_cfg(builder_dict):
186 # Android.
187 if 'Android' in builder_dict.get('extra_config', ''):
188 if 'NoNeon' in builder_dict['extra_config']:
189 return 'arm_v7'
190 return {
191 'Arm64': 'arm64',
192 'x86': 'x86',
193 'x86_64': 'x86_64',
194 'Mips': 'mips',
195 'Mips64': 'mips64',
196 'MipsDSP2': 'mips_dsp2',
197 }.get(builder_dict['target_arch'], 'arm_v7_neon')
198 elif builder_dict.get('os') == 'Android':
199 return {
200 'GalaxyS3': 'arm_v7_neon',
201 'GalaxyS4': 'arm_v7_neon',
202 'Nexus5': 'arm_v7', # This'd be 'nexus_5', but we simulate no-NEON Clank.
203 'Nexus6': 'arm_v7_neon',
204 'Nexus7': 'nexus_7',
205 'Nexus9': 'nexus_9',
206 'Nexus10': 'nexus_10',
207 'NexusPlayer': 'x86',
208 'NVIDIA_Shield': 'arm64',
209 }[builder_dict['model']]
210
211 # ChromeOS.
212 if 'CrOS' in builder_dict.get('extra_config', ''):
213 if 'Link' in builder_dict['extra_config']:
214 return 'link'
215 if 'Daisy' in builder_dict['extra_config']:
216 return 'daisy'
217 elif builder_dict.get('os') == 'ChromeOS':
218 return {
219 'Link': 'link',
220 'Daisy': 'daisy',
221 }[builder_dict['model']]
222
223 return None
224
225
226 cov_skip.extend([lineno(), lineno() + 1])
227 def get_builder_spec(builder_name):
228 builder_dict = builder_name_schema.DictForBuilderName(builder_name)
229 env = get_extra_env_vars(builder_dict)
230 gyp_defs = gyp_defines(builder_dict)
231 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()]
232 gyp_defs_list.sort()
233 env['GYP_DEFINES'] = ' '.join(gyp_defs_list)
234 rv = {
235 'build_targets': build_targets_from_builder_dict(builder_dict),
236 'builder_cfg': builder_dict,
237 'dm_flags': dm_flags.get_args(builder_name),
238 'env': env,
239 'nanobench_flags': nanobench_flags.get_args(builder_name),
240 }
241 device = device_cfg(builder_dict)
242 if device:
243 rv['device_cfg'] = device
244
245 role = builder_dict['role']
246 if role == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
247 configuration = CONFIG_RELEASE
248 else:
249 configuration = builder_dict.get(
250 'configuration', CONFIG_DEBUG)
251 arch = (builder_dict.get('arch') or builder_dict.get('target_arch'))
252 if ('Win' in builder_dict.get('os', '') and arch == 'x86_64'):
253 configuration += '_x64'
254 rv['configuration'] = configuration
255 rv['do_test_steps'] = role == builder_name_schema.BUILDER_ROLE_TEST
256 rv['do_perf_steps'] = (role == builder_name_schema.BUILDER_ROLE_PERF or
257 (role == builder_name_schema.BUILDER_ROLE_TEST and
258 configuration == CONFIG_DEBUG) or
259 'Valgrind' in builder_name)
260
261 # Do we upload perf results?
262 upload_perf_results = False
263 if role == builder_name_schema.BUILDER_ROLE_PERF:
264 upload_perf_results = True
265 rv['upload_perf_results'] = upload_perf_results
266
267 # Do we upload correctness results?
268 skip_upload_bots = [
269 'ASAN',
270 'Coverage',
271 'TSAN',
272 'UBSAN',
273 'Valgrind',
274 ]
275 upload_dm_results = True
276 for s in skip_upload_bots:
277 if s in builder_name:
278 upload_dm_results = False
279 break
280 rv['upload_dm_results'] = upload_dm_results
281
282 return rv
283
284
285 cov_end = lineno() # Don't care about code coverage past here.
286
287
288 def self_test():
289 import coverage # This way the bots don't need coverage.py to be installed.
290 args = {}
291 cases = [
292 'Build-Mac10.8-Clang-Arm7-Debug-Android',
293 'Build-Win-MSVC-x86-Debug',
294 'Build-Win-MSVC-x86-Debug-GDI',
295 'Build-Win-MSVC-x86-Debug-Exceptions',
296 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs',
297 'Build-Ubuntu-GCC-Arm7-Debug-Android_NoNeon',
298 'Build-Ubuntu-GCC-Arm7-Debug-CrOS_Daisy',
299 'Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link',
300 'Build-Ubuntu-GCC-x86_64-Release-Mesa',
301 'Housekeeper-PerCommit',
302 'Perf-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Release-Trybot',
303 'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
304 'Test-ChromeOS-GCC-Link-CPU-AVX-x86_64-Debug',
305 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
306 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
307 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD',
308 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
309 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
310 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE',
311 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug',
312 ]
313
314 cov = coverage.coverage()
315 cov.start()
316 for case in cases:
317 args[case] = get_builder_spec(case)
318 cov.stop()
319
320 this_file = os.path.basename(__file__)
321 _, _, not_run, _ = cov.analysis(this_file)
322 filtered = [line for line in not_run if
323 line > cov_start and line < cov_end and line not in cov_skip]
324 if filtered:
325 print 'Lines not covered by test cases: ', filtered
326 sys.exit(1)
327
328 golden = this_file.replace('.py', '.json')
329 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
330 json.dump(args, f, indent=2, sort_keys=True)
331
332
333 if __name__ == '__main__':
334 if len(sys.argv) == 2 and sys.argv[1] == 'test':
335 self_test()
336 sys.exit(0)
337
338 if len(sys.argv) != 3:
339 print usage
340 sys.exit(1)
341
342 with open(sys.argv[1], 'w') as out:
343 json.dump(get_builder_spec(sys.argv[2]), out)
OLDNEW
« no previous file with comments | « tools/buildbot_spec.json ('k') | tools/builder_name_schema.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698