blob: edc05f0b0344a1f6e8f3df57c08cc85b1f2bc428 [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
rmistry43e8f672016-04-18 04:14:17 -070027CONFIG_COVERAGE = 'Coverage'
borenetdbf9f012015-07-30 07:09:20 -070028CONFIG_DEBUG = 'Debug'
29CONFIG_RELEASE = 'Release'
30
31
borenetb76c1f72015-07-29 07:38:49 -070032def lineno():
33 caller = inspect.stack()[1] # Up one level to our caller.
34 return inspect.getframeinfo(caller[0]).lineno
35
36# Since we don't actually start coverage until we're in the self-test,
37# some function def lines aren't reported as covered. Add them to this
38# list so that we can ignore them.
39cov_skip = []
40
41cov_start = lineno()+1 # We care about coverage starting just past this def.
42def gyp_defines(builder_dict):
43 gyp_defs = {}
44
45 # skia_arch_type.
46 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_BUILD:
47 arch = builder_dict['target_arch']
48 elif builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
49 arch = None
50 else:
51 arch = builder_dict['arch']
52
53 arch_types = {
54 'x86': 'x86',
55 'x86_64': 'x86_64',
56 'Arm7': 'arm',
57 'Arm64': 'arm64',
58 'Mips': 'mips32',
59 'Mips64': 'mips64',
60 'MipsDSP2': 'mips32',
61 }
62 if arch in arch_types:
63 gyp_defs['skia_arch_type'] = arch_types[arch]
64
65 # housekeeper: build shared lib.
66 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
67 gyp_defs['skia_shared_lib'] = '1'
68
69 # skia_gpu.
70 if builder_dict.get('cpu_or_gpu') == 'CPU':
71 gyp_defs['skia_gpu'] = '0'
72
73 # skia_warnings_as_errors.
74 werr = False
75 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_BUILD:
76 if 'Win' in builder_dict.get('os', ''):
77 if not ('GDI' in builder_dict.get('extra_config', '') or
78 'Exceptions' in builder_dict.get('extra_config', '')):
79 werr = True
80 elif ('Mac' in builder_dict.get('os', '') and
81 'Android' in builder_dict.get('extra_config', '')):
82 werr = False
83 else:
84 werr = True
85 gyp_defs['skia_warnings_as_errors'] = str(int(werr)) # True/False -> '1'/'0'
86
87 # Win debugger.
88 if 'Win' in builder_dict.get('os', ''):
89 gyp_defs['skia_win_debuggers_path'] = 'c:/DbgHelp'
90
91 # Qt SDK (Win).
92 if 'Win' in builder_dict.get('os', ''):
93 if builder_dict.get('os') == 'Win8':
94 gyp_defs['qt_sdk'] = 'C:/Qt/Qt5.1.0/5.1.0/msvc2012_64/'
95 else:
96 gyp_defs['qt_sdk'] = 'C:/Qt/4.8.5/'
97
98 # ANGLE.
99 if builder_dict.get('extra_config') == 'ANGLE':
100 gyp_defs['skia_angle'] = '1'
borenet08d77472015-09-21 08:20:24 -0700101 if builder_dict.get('os', '') in ('Ubuntu', 'Linux'):
102 gyp_defs['use_x11'] = '1'
103 gyp_defs['chromeos'] = '0'
borenetb76c1f72015-07-29 07:38:49 -0700104
105 # GDI.
106 if builder_dict.get('extra_config') == 'GDI':
107 gyp_defs['skia_gdi'] = '1'
108
109 # Build with Exceptions on Windows.
110 if ('Win' in builder_dict.get('os', '') and
111 builder_dict.get('extra_config') == 'Exceptions'):
112 gyp_defs['skia_win_exceptions'] = '1'
113
114 # iOS.
115 if (builder_dict.get('os') == 'iOS' or
116 builder_dict.get('extra_config') == 'iOS'):
117 gyp_defs['skia_os'] = 'ios'
118
119 # Shared library build.
120 if builder_dict.get('extra_config') == 'Shared':
121 gyp_defs['skia_shared_lib'] = '1'
122
mtklein6f659572016-02-16 06:42:51 -0800123 # Build fastest Skia possible.
124 if builder_dict.get('extra_config') == 'Fast':
125 gyp_defs['skia_fast'] = '1'
126
borenetb76c1f72015-07-29 07:38:49 -0700127 # PDF viewer in GM.
128 if (builder_dict.get('os') == 'Mac10.8' and
129 builder_dict.get('arch') == 'x86_64' and
130 builder_dict.get('configuration') == 'Release'):
131 gyp_defs['skia_run_pdfviewer_in_gm'] = '1'
132
133 # Clang.
134 if builder_dict.get('compiler') == 'Clang':
135 gyp_defs['skia_clang_build'] = '1'
136
137 # Valgrind.
138 if 'Valgrind' in builder_dict.get('extra_config', ''):
139 gyp_defs['skia_release_optimization_level'] = '1'
140
141 # Link-time code generation just wastes time on compile-only bots.
142 if (builder_dict.get('role') == builder_name_schema.BUILDER_ROLE_BUILD and
143 builder_dict.get('compiler') == 'MSVC'):
144 gyp_defs['skia_win_ltcg'] = '0'
145
146 # Mesa.
147 if (builder_dict.get('extra_config') == 'Mesa' or
148 builder_dict.get('cpu_or_gpu_value') == 'Mesa'):
149 gyp_defs['skia_mesa'] = '1'
150
joshualitt64673af2015-12-16 12:54:19 -0800151 # VisualBench
152 if builder_dict.get('extra_config') == 'VisualBench':
153 gyp_defs['skia_use_sdl'] = '1'
154
borenetb76c1f72015-07-29 07:38:49 -0700155 # skia_use_android_framework_defines.
156 if builder_dict.get('extra_config') == 'Android_FrameworkDefs':
157 gyp_defs['skia_use_android_framework_defines'] = '1'
158
joshualitt7384d072015-12-02 14:04:46 -0800159 # Skia dump stats for perf tests and gpu
160 if (builder_dict.get('cpu_or_gpu') == 'GPU' and
161 builder_dict.get('role') == 'Perf'):
162 gyp_defs['skia_dump_stats'] = '1'
163
borenet48b88cc2016-04-11 10:16:01 -0700164 # CommandBuffer.
165 if builder_dict.get('extra_config') == 'CommandBuffer':
166 gyp_defs['skia_command_buffer'] = '1'
167
borenet71e185c2016-04-12 08:13:56 -0700168 # Vulkan.
169 if builder_dict.get('extra_config') == 'Vulkan':
170 gyp_defs['skia_vulkan'] = '1'
171
borenetb76c1f72015-07-29 07:38:49 -0700172 return gyp_defs
173
174
175cov_skip.extend([lineno(), lineno() + 1])
176def get_extra_env_vars(builder_dict):
177 env = {}
rmistry43e8f672016-04-18 04:14:17 -0700178 if builder_dict.get('configuration') == CONFIG_COVERAGE:
borenetdbf9f012015-07-30 07:09:20 -0700179 # We have to use Clang 3.6 because earlier versions do not support the
180 # compile flags we use and 3.7 and 3.8 hit asserts during compilation.
181 env['CC'] = '/usr/bin/clang-3.6'
182 env['CXX'] = '/usr/bin/clang++-3.6'
183 elif builder_dict.get('compiler') == 'Clang':
borenetb76c1f72015-07-29 07:38:49 -0700184 env['CC'] = '/usr/bin/clang'
185 env['CXX'] = '/usr/bin/clang++'
borenet98f7e332015-08-24 12:50:59 -0700186
mtkleind0fff5b2015-09-18 06:15:55 -0700187 # SKNX_NO_SIMD, SK_USE_DISCARDABLE_SCALEDIMAGECACHE, etc.
188 extra_config = builder_dict.get('extra_config', '')
189 if extra_config.startswith('SK') and extra_config.isupper():
190 env['CPPFLAGS'] = '-D' + extra_config
191
borenetb76c1f72015-07-29 07:38:49 -0700192 return env
193
194
195cov_skip.extend([lineno(), lineno() + 1])
borenetb64b1952015-10-21 07:50:57 -0700196def build_targets_from_builder_dict(builder_dict, do_test_steps, do_perf_steps):
borenetb76c1f72015-07-29 07:38:49 -0700197 """Return a list of targets to build, depending on the builder type."""
198 if builder_dict['role'] in ('Test', 'Perf') and builder_dict['os'] == 'iOS':
199 return ['iOSShell']
borenetb64b1952015-10-21 07:50:57 -0700200 if builder_dict.get('extra_config') == 'Appurify':
201 return ['VisualBenchTest_APK']
benjaminwagnerae5c01d2016-05-04 06:35:50 -0700202 if 'SAN' in builder_dict.get('extra_config', ''):
203 # 'most' does not compile under MSAN.
204 return ['dm', 'nanobench']
borenetb64b1952015-10-21 07:50:57 -0700205 t = []
206 if do_test_steps:
207 t.append('dm')
joshualitt64673af2015-12-16 12:54:19 -0800208 if do_perf_steps and builder_dict.get('extra_config') == 'VisualBench':
209 t.append('visualbench')
210 elif do_perf_steps:
211 t.append('nanobench')
borenetb64b1952015-10-21 07:50:57 -0700212 if t:
borenetb76c1f72015-07-29 07:38:49 -0700213 return t
borenetb76c1f72015-07-29 07:38:49 -0700214 else:
215 return ['most']
216
217
218cov_skip.extend([lineno(), lineno() + 1])
borenet7bccca12015-07-29 11:15:42 -0700219def device_cfg(builder_dict):
220 # Android.
221 if 'Android' in builder_dict.get('extra_config', ''):
222 if 'NoNeon' in builder_dict['extra_config']:
223 return 'arm_v7'
224 return {
225 'Arm64': 'arm64',
226 'x86': 'x86',
227 'x86_64': 'x86_64',
228 'Mips': 'mips',
229 'Mips64': 'mips64',
230 'MipsDSP2': 'mips_dsp2',
231 }.get(builder_dict['target_arch'], 'arm_v7_neon')
232 elif builder_dict.get('os') == 'Android':
233 return {
mtklein80fc19c2016-01-21 14:24:10 -0800234 'AndroidOne': 'arm_v7_neon',
235 'GalaxyS3': 'arm_v7_neon',
236 'GalaxyS4': 'arm_v7_neon',
borenet7bccca12015-07-29 11:15:42 -0700237 'NVIDIA_Shield': 'arm64',
mtklein80fc19c2016-01-21 14:24:10 -0800238 'Nexus10': 'arm_v7_neon',
239 'Nexus5': 'arm_v7_neon',
240 'Nexus6': 'arm_v7_neon',
241 'Nexus7': 'arm_v7_neon',
borenetcafbfe62016-04-01 07:18:27 -0700242 'Nexus7v2': 'arm_v7_neon',
mtklein80fc19c2016-01-21 14:24:10 -0800243 'Nexus9': 'arm64',
244 'NexusPlayer': 'x86',
borenet7bccca12015-07-29 11:15:42 -0700245 }[builder_dict['model']]
246
borenetd32eac22016-04-05 12:14:59 -0700247 # iOS.
248 if 'iOS' in builder_dict.get('os', ''):
249 return {
250 'iPad4': 'iPad4,1',
251 }[builder_dict['model']]
252
borenet7bccca12015-07-29 11:15:42 -0700253 return None
254
255
256cov_skip.extend([lineno(), lineno() + 1])
borenetcafbfe62016-04-01 07:18:27 -0700257def product_board(builder_dict):
258 if 'Android' in builder_dict.get('os', ''):
259 return {
260 'AndroidOne': None, # TODO(borenet,kjlubick)
261 'GalaxyS3': 'smdk4x12',
262 'GalaxyS4': None, # TODO(borenet,kjlubick)
263 'NVIDIA_Shield': None, # TODO(borenet,kjlubick)
264 'Nexus10': 'manta',
265 'Nexus5': 'hammerhead',
266 'Nexus6': 'shamu',
267 'Nexus7': 'grouper',
268 'Nexus7v2': 'flo',
269 'Nexus9': 'flounder',
270 'NexusPlayer': 'fugu',
271 }[builder_dict['model']]
272 return None
273
274
275cov_skip.extend([lineno(), lineno() + 1])
borenetb76c1f72015-07-29 07:38:49 -0700276def get_builder_spec(builder_name):
277 builder_dict = builder_name_schema.DictForBuilderName(builder_name)
278 env = get_extra_env_vars(builder_dict)
279 gyp_defs = gyp_defines(builder_dict)
280 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()]
281 gyp_defs_list.sort()
282 env['GYP_DEFINES'] = ' '.join(gyp_defs_list)
borenet7bccca12015-07-29 11:15:42 -0700283 rv = {
borenet7bccca12015-07-29 11:15:42 -0700284 'builder_cfg': builder_dict,
borenet2481b8b2015-07-29 11:43:07 -0700285 'dm_flags': dm_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700286 'env': env,
borenet2481b8b2015-07-29 11:43:07 -0700287 'nanobench_flags': nanobench_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700288 }
borenet7bccca12015-07-29 11:15:42 -0700289 device = device_cfg(builder_dict)
290 if device:
291 rv['device_cfg'] = device
borenetcafbfe62016-04-01 07:18:27 -0700292 board = product_board(builder_dict)
293 if board:
294 rv['product.board'] = board
borenetdbf9f012015-07-30 07:09:20 -0700295
296 role = builder_dict['role']
297 if role == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
298 configuration = CONFIG_RELEASE
299 else:
300 configuration = builder_dict.get(
301 'configuration', CONFIG_DEBUG)
302 arch = (builder_dict.get('arch') or builder_dict.get('target_arch'))
303 if ('Win' in builder_dict.get('os', '') and arch == 'x86_64'):
304 configuration += '_x64'
305 rv['configuration'] = configuration
rmistry43e8f672016-04-18 04:14:17 -0700306 if configuration == CONFIG_COVERAGE:
307 rv['do_compile_steps'] = False
borenetdbf9f012015-07-30 07:09:20 -0700308 rv['do_test_steps'] = role == builder_name_schema.BUILDER_ROLE_TEST
309 rv['do_perf_steps'] = (role == builder_name_schema.BUILDER_ROLE_PERF or
310 (role == builder_name_schema.BUILDER_ROLE_TEST and
borenet5eaaad22015-10-22 07:06:28 -0700311 configuration == CONFIG_DEBUG))
rmistry0adac462016-04-05 08:24:29 -0700312 if rv['do_test_steps'] and 'Valgrind' in builder_name:
borenet5eaaad22015-10-22 07:06:28 -0700313 rv['do_perf_steps'] = True
314 if 'GalaxyS4' in builder_name:
315 rv['do_perf_steps'] = False
316
borenetb64b1952015-10-21 07:50:57 -0700317 rv['build_targets'] = build_targets_from_builder_dict(
318 builder_dict, rv['do_test_steps'], rv['do_perf_steps'])
borenetdbf9f012015-07-30 07:09:20 -0700319
320 # Do we upload perf results?
321 upload_perf_results = False
322 if role == builder_name_schema.BUILDER_ROLE_PERF:
323 upload_perf_results = True
324 rv['upload_perf_results'] = upload_perf_results
325
326 # Do we upload correctness results?
327 skip_upload_bots = [
328 'ASAN',
329 'Coverage',
mtklein001cc1f2016-02-05 06:16:59 -0800330 'MSAN',
borenetdbf9f012015-07-30 07:09:20 -0700331 'TSAN',
332 'UBSAN',
333 'Valgrind',
334 ]
335 upload_dm_results = True
336 for s in skip_upload_bots:
337 if s in builder_name:
338 upload_dm_results = False
339 break
340 rv['upload_dm_results'] = upload_dm_results
341
borenet7bccca12015-07-29 11:15:42 -0700342 return rv
borenetb76c1f72015-07-29 07:38:49 -0700343
344
345cov_end = lineno() # Don't care about code coverage past here.
346
347
348def self_test():
349 import coverage # This way the bots don't need coverage.py to be installed.
350 args = {}
351 cases = [
352 'Build-Mac10.8-Clang-Arm7-Debug-Android',
353 'Build-Win-MSVC-x86-Debug',
354 'Build-Win-MSVC-x86-Debug-GDI',
355 'Build-Win-MSVC-x86-Debug-Exceptions',
356 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs',
borenet7bccca12015-07-29 11:15:42 -0700357 'Build-Ubuntu-GCC-Arm7-Debug-Android_NoNeon',
borenetb76c1f72015-07-29 07:38:49 -0700358 'Build-Ubuntu-GCC-x86_64-Release-Mesa',
borenet08d77472015-09-21 08:20:24 -0700359 'Build-Ubuntu-GCC-x86_64-Release-ANGLE',
borenetb76c1f72015-07-29 07:38:49 -0700360 'Housekeeper-PerCommit',
361 'Perf-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Release-Trybot',
joshualitt64673af2015-12-16 12:54:19 -0800362 'Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release-VisualBench',
borenet5eaaad22015-10-22 07:06:28 -0700363 'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Debug',
borenet98f7e332015-08-24 12:50:59 -0700364 'Perf-Android-GCC-Nexus5-GPU-Adreno330-Arm7-Release-Appurify',
borenet7bccca12015-07-29 11:15:42 -0700365 'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
borenetb76c1f72015-07-29 07:38:49 -0700366 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
borenet48b88cc2016-04-11 10:16:01 -0700367 'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer',
borenetb76c1f72015-07-29 07:38:49 -0700368 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
borenet98f7e332015-08-24 12:50:59 -0700369 'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage',
borenet9063e422015-09-18 06:37:14 -0700370 ('Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-'
371 'SK_USE_DISCARDABLE_SCALEDIMAGECACHE'),
borenetb76c1f72015-07-29 07:38:49 -0700372 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD',
mtklein6f659572016-02-16 06:42:51 -0800373 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Fast',
borenetb76c1f72015-07-29 07:38:49 -0700374 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
375 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
borenet71e185c2016-04-12 08:13:56 -0700376 'Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan',
borenetb76c1f72015-07-29 07:38:49 -0700377 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE',
378 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug',
379 ]
380
381 cov = coverage.coverage()
382 cov.start()
383 for case in cases:
384 args[case] = get_builder_spec(case)
385 cov.stop()
386
387 this_file = os.path.basename(__file__)
388 _, _, not_run, _ = cov.analysis(this_file)
389 filtered = [line for line in not_run if
390 line > cov_start and line < cov_end and line not in cov_skip]
391 if filtered:
392 print 'Lines not covered by test cases: ', filtered
393 sys.exit(1)
394
395 golden = this_file.replace('.py', '.json')
396 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
397 json.dump(args, f, indent=2, sort_keys=True)
398
399
400if __name__ == '__main__':
401 if len(sys.argv) == 2 and sys.argv[1] == 'test':
402 self_test()
403 sys.exit(0)
404
405 if len(sys.argv) != 3:
406 print usage
407 sys.exit(1)
408
409 with open(sys.argv[1], 'w') as out:
410 json.dump(get_builder_spec(sys.argv[2]), out)