blob: 17ccfec7983f85c3e911f632c6e75a78fdb5430d [file] [log] [blame]
borenetb76c1f72015-07-29 07:38:49 -07001#
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
10usage = '''
11Write buildbot spec to outfile based on the bot name:
12 $ python buildbot_spec.py outfile Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug
13Or run self-tests:
14 $ python buildbot_spec.py test
15'''
16
17import inspect
18import json
19import os
20import sys
21
22import builder_name_schema
borenet2481b8b2015-07-29 11:43:07 -070023import dm_flags
24import nanobench_flags
borenetb76c1f72015-07-29 07:38:49 -070025
26
borenetdbf9f012015-07-30 07:09:20 -070027CONFIG_DEBUG = 'Debug'
28CONFIG_RELEASE = 'Release'
29
30
borenetb76c1f72015-07-29 07:38:49 -070031def 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.
38cov_skip = []
39
40cov_start = lineno()+1 # We care about coverage starting just past this def.
41def 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'
borenet08d77472015-09-21 08:20:24 -0700100 if builder_dict.get('os', '') in ('Ubuntu', 'Linux'):
101 gyp_defs['use_x11'] = '1'
102 gyp_defs['chromeos'] = '0'
borenetb76c1f72015-07-29 07:38:49 -0700103
104 # GDI.
105 if builder_dict.get('extra_config') == 'GDI':
106 gyp_defs['skia_gdi'] = '1'
107
108 # Build with Exceptions on Windows.
109 if ('Win' in builder_dict.get('os', '') and
110 builder_dict.get('extra_config') == 'Exceptions'):
111 gyp_defs['skia_win_exceptions'] = '1'
112
113 # iOS.
114 if (builder_dict.get('os') == 'iOS' or
115 builder_dict.get('extra_config') == 'iOS'):
116 gyp_defs['skia_os'] = 'ios'
117
118 # Shared library build.
119 if builder_dict.get('extra_config') == 'Shared':
120 gyp_defs['skia_shared_lib'] = '1'
121
mtklein6f659572016-02-16 06:42:51 -0800122 # Build fastest Skia possible.
123 if builder_dict.get('extra_config') == 'Fast':
124 gyp_defs['skia_fast'] = '1'
125
borenetb76c1f72015-07-29 07:38:49 -0700126 # PDF viewer in GM.
127 if (builder_dict.get('os') == 'Mac10.8' and
128 builder_dict.get('arch') == 'x86_64' and
129 builder_dict.get('configuration') == 'Release'):
130 gyp_defs['skia_run_pdfviewer_in_gm'] = '1'
131
132 # Clang.
133 if builder_dict.get('compiler') == 'Clang':
134 gyp_defs['skia_clang_build'] = '1'
135
136 # Valgrind.
137 if 'Valgrind' in builder_dict.get('extra_config', ''):
138 gyp_defs['skia_release_optimization_level'] = '1'
139
140 # Link-time code generation just wastes time on compile-only bots.
141 if (builder_dict.get('role') == builder_name_schema.BUILDER_ROLE_BUILD and
142 builder_dict.get('compiler') == 'MSVC'):
143 gyp_defs['skia_win_ltcg'] = '0'
144
145 # Mesa.
146 if (builder_dict.get('extra_config') == 'Mesa' or
147 builder_dict.get('cpu_or_gpu_value') == 'Mesa'):
148 gyp_defs['skia_mesa'] = '1'
149
joshualitt64673af2015-12-16 12:54:19 -0800150 # VisualBench
151 if builder_dict.get('extra_config') == 'VisualBench':
152 gyp_defs['skia_use_sdl'] = '1'
153
borenetb76c1f72015-07-29 07:38:49 -0700154 # skia_use_android_framework_defines.
155 if builder_dict.get('extra_config') == 'Android_FrameworkDefs':
156 gyp_defs['skia_use_android_framework_defines'] = '1'
157
joshualitt7384d072015-12-02 14:04:46 -0800158 # Skia dump stats for perf tests and gpu
159 if (builder_dict.get('cpu_or_gpu') == 'GPU' and
160 builder_dict.get('role') == 'Perf'):
161 gyp_defs['skia_dump_stats'] = '1'
162
borenet48b88cc2016-04-11 10:16:01 -0700163 # CommandBuffer.
164 if builder_dict.get('extra_config') == 'CommandBuffer':
165 gyp_defs['skia_command_buffer'] = '1'
166
borenetb76c1f72015-07-29 07:38:49 -0700167 return gyp_defs
168
169
170cov_skip.extend([lineno(), lineno() + 1])
171def get_extra_env_vars(builder_dict):
172 env = {}
borenetdbf9f012015-07-30 07:09:20 -0700173 if builder_dict.get('configuration') == 'Coverage':
174 # We have to use Clang 3.6 because earlier versions do not support the
175 # compile flags we use and 3.7 and 3.8 hit asserts during compilation.
176 env['CC'] = '/usr/bin/clang-3.6'
177 env['CXX'] = '/usr/bin/clang++-3.6'
178 elif builder_dict.get('compiler') == 'Clang':
borenetb76c1f72015-07-29 07:38:49 -0700179 env['CC'] = '/usr/bin/clang'
180 env['CXX'] = '/usr/bin/clang++'
borenet98f7e332015-08-24 12:50:59 -0700181
mtkleind0fff5b2015-09-18 06:15:55 -0700182 # SKNX_NO_SIMD, SK_USE_DISCARDABLE_SCALEDIMAGECACHE, etc.
183 extra_config = builder_dict.get('extra_config', '')
184 if extra_config.startswith('SK') and extra_config.isupper():
185 env['CPPFLAGS'] = '-D' + extra_config
186
borenetb76c1f72015-07-29 07:38:49 -0700187 return env
188
189
190cov_skip.extend([lineno(), lineno() + 1])
borenetb64b1952015-10-21 07:50:57 -0700191def build_targets_from_builder_dict(builder_dict, do_test_steps, do_perf_steps):
borenetb76c1f72015-07-29 07:38:49 -0700192 """Return a list of targets to build, depending on the builder type."""
193 if builder_dict['role'] in ('Test', 'Perf') and builder_dict['os'] == 'iOS':
194 return ['iOSShell']
borenetb64b1952015-10-21 07:50:57 -0700195 if builder_dict.get('extra_config') == 'Appurify':
196 return ['VisualBenchTest_APK']
197 t = []
198 if do_test_steps:
199 t.append('dm')
joshualitt64673af2015-12-16 12:54:19 -0800200 if do_perf_steps and builder_dict.get('extra_config') == 'VisualBench':
201 t.append('visualbench')
202 elif do_perf_steps:
203 t.append('nanobench')
borenetb64b1952015-10-21 07:50:57 -0700204 if t:
borenetb76c1f72015-07-29 07:38:49 -0700205 return t
borenetb76c1f72015-07-29 07:38:49 -0700206 else:
207 return ['most']
208
209
210cov_skip.extend([lineno(), lineno() + 1])
borenet7bccca12015-07-29 11:15:42 -0700211def device_cfg(builder_dict):
212 # Android.
213 if 'Android' in builder_dict.get('extra_config', ''):
214 if 'NoNeon' in builder_dict['extra_config']:
215 return 'arm_v7'
216 return {
217 'Arm64': 'arm64',
218 'x86': 'x86',
219 'x86_64': 'x86_64',
220 'Mips': 'mips',
221 'Mips64': 'mips64',
222 'MipsDSP2': 'mips_dsp2',
223 }.get(builder_dict['target_arch'], 'arm_v7_neon')
224 elif builder_dict.get('os') == 'Android':
225 return {
mtklein80fc19c2016-01-21 14:24:10 -0800226 'AndroidOne': 'arm_v7_neon',
227 'GalaxyS3': 'arm_v7_neon',
228 'GalaxyS4': 'arm_v7_neon',
borenet7bccca12015-07-29 11:15:42 -0700229 'NVIDIA_Shield': 'arm64',
mtklein80fc19c2016-01-21 14:24:10 -0800230 'Nexus10': 'arm_v7_neon',
231 'Nexus5': 'arm_v7_neon',
232 'Nexus6': 'arm_v7_neon',
233 'Nexus7': 'arm_v7_neon',
borenetcafbfe62016-04-01 07:18:27 -0700234 'Nexus7v2': 'arm_v7_neon',
mtklein80fc19c2016-01-21 14:24:10 -0800235 'Nexus9': 'arm64',
236 'NexusPlayer': 'x86',
borenet7bccca12015-07-29 11:15:42 -0700237 }[builder_dict['model']]
238
239 # ChromeOS.
240 if 'CrOS' in builder_dict.get('extra_config', ''):
241 if 'Link' in builder_dict['extra_config']:
242 return 'link'
243 if 'Daisy' in builder_dict['extra_config']:
244 return 'daisy'
245 elif builder_dict.get('os') == 'ChromeOS':
246 return {
247 'Link': 'link',
248 'Daisy': 'daisy',
249 }[builder_dict['model']]
250
borenetd32eac22016-04-05 12:14:59 -0700251 # iOS.
252 if 'iOS' in builder_dict.get('os', ''):
253 return {
254 'iPad4': 'iPad4,1',
255 }[builder_dict['model']]
256
borenet7bccca12015-07-29 11:15:42 -0700257 return None
258
259
260cov_skip.extend([lineno(), lineno() + 1])
borenetcafbfe62016-04-01 07:18:27 -0700261def product_board(builder_dict):
262 if 'Android' in builder_dict.get('os', ''):
263 return {
264 'AndroidOne': None, # TODO(borenet,kjlubick)
265 'GalaxyS3': 'smdk4x12',
266 'GalaxyS4': None, # TODO(borenet,kjlubick)
267 'NVIDIA_Shield': None, # TODO(borenet,kjlubick)
268 'Nexus10': 'manta',
269 'Nexus5': 'hammerhead',
270 'Nexus6': 'shamu',
271 'Nexus7': 'grouper',
272 'Nexus7v2': 'flo',
273 'Nexus9': 'flounder',
274 'NexusPlayer': 'fugu',
275 }[builder_dict['model']]
276 return None
277
278
279cov_skip.extend([lineno(), lineno() + 1])
borenetb76c1f72015-07-29 07:38:49 -0700280def get_builder_spec(builder_name):
281 builder_dict = builder_name_schema.DictForBuilderName(builder_name)
282 env = get_extra_env_vars(builder_dict)
283 gyp_defs = gyp_defines(builder_dict)
284 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()]
285 gyp_defs_list.sort()
286 env['GYP_DEFINES'] = ' '.join(gyp_defs_list)
borenet7bccca12015-07-29 11:15:42 -0700287 rv = {
borenet7bccca12015-07-29 11:15:42 -0700288 'builder_cfg': builder_dict,
borenet2481b8b2015-07-29 11:43:07 -0700289 'dm_flags': dm_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700290 'env': env,
borenet2481b8b2015-07-29 11:43:07 -0700291 'nanobench_flags': nanobench_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700292 }
borenet7bccca12015-07-29 11:15:42 -0700293 device = device_cfg(builder_dict)
294 if device:
295 rv['device_cfg'] = device
borenetcafbfe62016-04-01 07:18:27 -0700296 board = product_board(builder_dict)
297 if board:
298 rv['product.board'] = board
borenetdbf9f012015-07-30 07:09:20 -0700299
300 role = builder_dict['role']
301 if role == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
302 configuration = CONFIG_RELEASE
303 else:
304 configuration = builder_dict.get(
305 'configuration', CONFIG_DEBUG)
306 arch = (builder_dict.get('arch') or builder_dict.get('target_arch'))
307 if ('Win' in builder_dict.get('os', '') and arch == 'x86_64'):
308 configuration += '_x64'
309 rv['configuration'] = configuration
310 rv['do_test_steps'] = role == builder_name_schema.BUILDER_ROLE_TEST
311 rv['do_perf_steps'] = (role == builder_name_schema.BUILDER_ROLE_PERF or
312 (role == builder_name_schema.BUILDER_ROLE_TEST and
borenet5eaaad22015-10-22 07:06:28 -0700313 configuration == CONFIG_DEBUG))
rmistry0adac462016-04-05 08:24:29 -0700314 if rv['do_test_steps'] and 'Valgrind' in builder_name:
borenet5eaaad22015-10-22 07:06:28 -0700315 rv['do_perf_steps'] = True
316 if 'GalaxyS4' in builder_name:
317 rv['do_perf_steps'] = False
318
borenetb64b1952015-10-21 07:50:57 -0700319 rv['build_targets'] = build_targets_from_builder_dict(
320 builder_dict, rv['do_test_steps'], rv['do_perf_steps'])
borenetdbf9f012015-07-30 07:09:20 -0700321
322 # Do we upload perf results?
323 upload_perf_results = False
324 if role == builder_name_schema.BUILDER_ROLE_PERF:
325 upload_perf_results = True
326 rv['upload_perf_results'] = upload_perf_results
327
328 # Do we upload correctness results?
329 skip_upload_bots = [
330 'ASAN',
331 'Coverage',
mtklein001cc1f2016-02-05 06:16:59 -0800332 'MSAN',
borenetdbf9f012015-07-30 07:09:20 -0700333 'TSAN',
334 'UBSAN',
335 'Valgrind',
336 ]
337 upload_dm_results = True
338 for s in skip_upload_bots:
339 if s in builder_name:
340 upload_dm_results = False
341 break
342 rv['upload_dm_results'] = upload_dm_results
343
borenet7bccca12015-07-29 11:15:42 -0700344 return rv
borenetb76c1f72015-07-29 07:38:49 -0700345
346
347cov_end = lineno() # Don't care about code coverage past here.
348
349
350def self_test():
351 import coverage # This way the bots don't need coverage.py to be installed.
352 args = {}
353 cases = [
354 'Build-Mac10.8-Clang-Arm7-Debug-Android',
355 'Build-Win-MSVC-x86-Debug',
356 'Build-Win-MSVC-x86-Debug-GDI',
357 'Build-Win-MSVC-x86-Debug-Exceptions',
358 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs',
borenet7bccca12015-07-29 11:15:42 -0700359 'Build-Ubuntu-GCC-Arm7-Debug-Android_NoNeon',
360 'Build-Ubuntu-GCC-Arm7-Debug-CrOS_Daisy',
361 'Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link',
borenetb76c1f72015-07-29 07:38:49 -0700362 'Build-Ubuntu-GCC-x86_64-Release-Mesa',
borenet08d77472015-09-21 08:20:24 -0700363 'Build-Ubuntu-GCC-x86_64-Release-ANGLE',
borenetb76c1f72015-07-29 07:38:49 -0700364 'Housekeeper-PerCommit',
365 'Perf-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Release-Trybot',
joshualitt64673af2015-12-16 12:54:19 -0800366 'Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release-VisualBench',
borenet5eaaad22015-10-22 07:06:28 -0700367 'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Debug',
borenet98f7e332015-08-24 12:50:59 -0700368 'Perf-Android-GCC-Nexus5-GPU-Adreno330-Arm7-Release-Appurify',
borenet7bccca12015-07-29 11:15:42 -0700369 'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
370 'Test-ChromeOS-GCC-Link-CPU-AVX-x86_64-Debug',
borenetb76c1f72015-07-29 07:38:49 -0700371 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
borenet48b88cc2016-04-11 10:16:01 -0700372 'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer',
borenetb76c1f72015-07-29 07:38:49 -0700373 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
borenet98f7e332015-08-24 12:50:59 -0700374 'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage',
borenet9063e422015-09-18 06:37:14 -0700375 ('Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-'
376 'SK_USE_DISCARDABLE_SCALEDIMAGECACHE'),
borenetb76c1f72015-07-29 07:38:49 -0700377 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD',
mtklein6f659572016-02-16 06:42:51 -0800378 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Fast',
borenetb76c1f72015-07-29 07:38:49 -0700379 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
380 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
381 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE',
382 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug',
383 ]
384
385 cov = coverage.coverage()
386 cov.start()
387 for case in cases:
388 args[case] = get_builder_spec(case)
389 cov.stop()
390
391 this_file = os.path.basename(__file__)
392 _, _, not_run, _ = cov.analysis(this_file)
393 filtered = [line for line in not_run if
394 line > cov_start and line < cov_end and line not in cov_skip]
395 if filtered:
396 print 'Lines not covered by test cases: ', filtered
397 sys.exit(1)
398
399 golden = this_file.replace('.py', '.json')
400 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
401 json.dump(args, f, indent=2, sort_keys=True)
402
403
404if __name__ == '__main__':
405 if len(sys.argv) == 2 and sys.argv[1] == 'test':
406 self_test()
407 sys.exit(0)
408
409 if len(sys.argv) != 3:
410 print usage
411 sys.exit(1)
412
413 with open(sys.argv[1], 'w') as out:
414 json.dump(get_builder_spec(sys.argv[2]), out)