blob: 603f36d5ed2177a437132596fad05a661233e429 [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
benjaminwagner31b84172016-05-06 09:30:08 -070083 elif 'Fast' in builder_dict.get('extra_config', ''):
84 # See https://bugs.chromium.org/p/skia/issues/detail?id=5257
85 werr = False
borenetb76c1f72015-07-29 07:38:49 -070086 else:
87 werr = True
88 gyp_defs['skia_warnings_as_errors'] = str(int(werr)) # True/False -> '1'/'0'
89
90 # Win debugger.
91 if 'Win' in builder_dict.get('os', ''):
92 gyp_defs['skia_win_debuggers_path'] = 'c:/DbgHelp'
93
94 # Qt SDK (Win).
95 if 'Win' in builder_dict.get('os', ''):
96 if builder_dict.get('os') == 'Win8':
97 gyp_defs['qt_sdk'] = 'C:/Qt/Qt5.1.0/5.1.0/msvc2012_64/'
98 else:
99 gyp_defs['qt_sdk'] = 'C:/Qt/4.8.5/'
100
101 # ANGLE.
102 if builder_dict.get('extra_config') == 'ANGLE':
103 gyp_defs['skia_angle'] = '1'
borenet08d77472015-09-21 08:20:24 -0700104 if builder_dict.get('os', '') in ('Ubuntu', 'Linux'):
105 gyp_defs['use_x11'] = '1'
106 gyp_defs['chromeos'] = '0'
borenetb76c1f72015-07-29 07:38:49 -0700107
108 # GDI.
109 if builder_dict.get('extra_config') == 'GDI':
110 gyp_defs['skia_gdi'] = '1'
111
112 # Build with Exceptions on Windows.
113 if ('Win' in builder_dict.get('os', '') and
114 builder_dict.get('extra_config') == 'Exceptions'):
115 gyp_defs['skia_win_exceptions'] = '1'
116
117 # iOS.
118 if (builder_dict.get('os') == 'iOS' or
119 builder_dict.get('extra_config') == 'iOS'):
120 gyp_defs['skia_os'] = 'ios'
121
122 # Shared library build.
123 if builder_dict.get('extra_config') == 'Shared':
124 gyp_defs['skia_shared_lib'] = '1'
125
mtklein6f659572016-02-16 06:42:51 -0800126 # Build fastest Skia possible.
127 if builder_dict.get('extra_config') == 'Fast':
128 gyp_defs['skia_fast'] = '1'
129
borenetb76c1f72015-07-29 07:38:49 -0700130 # PDF viewer in GM.
131 if (builder_dict.get('os') == 'Mac10.8' and
132 builder_dict.get('arch') == 'x86_64' and
133 builder_dict.get('configuration') == 'Release'):
134 gyp_defs['skia_run_pdfviewer_in_gm'] = '1'
135
136 # Clang.
137 if builder_dict.get('compiler') == 'Clang':
138 gyp_defs['skia_clang_build'] = '1'
139
140 # Valgrind.
141 if 'Valgrind' in builder_dict.get('extra_config', ''):
142 gyp_defs['skia_release_optimization_level'] = '1'
143
144 # Link-time code generation just wastes time on compile-only bots.
145 if (builder_dict.get('role') == builder_name_schema.BUILDER_ROLE_BUILD and
146 builder_dict.get('compiler') == 'MSVC'):
147 gyp_defs['skia_win_ltcg'] = '0'
148
149 # Mesa.
150 if (builder_dict.get('extra_config') == 'Mesa' or
151 builder_dict.get('cpu_or_gpu_value') == 'Mesa'):
152 gyp_defs['skia_mesa'] = '1'
153
joshualitt64673af2015-12-16 12:54:19 -0800154 # VisualBench
155 if builder_dict.get('extra_config') == 'VisualBench':
156 gyp_defs['skia_use_sdl'] = '1'
157
borenetb76c1f72015-07-29 07:38:49 -0700158 # skia_use_android_framework_defines.
159 if builder_dict.get('extra_config') == 'Android_FrameworkDefs':
160 gyp_defs['skia_use_android_framework_defines'] = '1'
161
joshualitt7384d072015-12-02 14:04:46 -0800162 # Skia dump stats for perf tests and gpu
163 if (builder_dict.get('cpu_or_gpu') == 'GPU' and
164 builder_dict.get('role') == 'Perf'):
165 gyp_defs['skia_dump_stats'] = '1'
166
borenet48b88cc2016-04-11 10:16:01 -0700167 # CommandBuffer.
168 if builder_dict.get('extra_config') == 'CommandBuffer':
169 gyp_defs['skia_command_buffer'] = '1'
170
borenet71e185c2016-04-12 08:13:56 -0700171 # Vulkan.
172 if builder_dict.get('extra_config') == 'Vulkan':
173 gyp_defs['skia_vulkan'] = '1'
174
borenetb76c1f72015-07-29 07:38:49 -0700175 return gyp_defs
176
177
178cov_skip.extend([lineno(), lineno() + 1])
179def get_extra_env_vars(builder_dict):
180 env = {}
rmistry43e8f672016-04-18 04:14:17 -0700181 if builder_dict.get('configuration') == CONFIG_COVERAGE:
borenetdbf9f012015-07-30 07:09:20 -0700182 # We have to use Clang 3.6 because earlier versions do not support the
183 # compile flags we use and 3.7 and 3.8 hit asserts during compilation.
184 env['CC'] = '/usr/bin/clang-3.6'
185 env['CXX'] = '/usr/bin/clang++-3.6'
186 elif builder_dict.get('compiler') == 'Clang':
borenetb76c1f72015-07-29 07:38:49 -0700187 env['CC'] = '/usr/bin/clang'
188 env['CXX'] = '/usr/bin/clang++'
borenet98f7e332015-08-24 12:50:59 -0700189
mtkleind0fff5b2015-09-18 06:15:55 -0700190 # SKNX_NO_SIMD, SK_USE_DISCARDABLE_SCALEDIMAGECACHE, etc.
191 extra_config = builder_dict.get('extra_config', '')
192 if extra_config.startswith('SK') and extra_config.isupper():
193 env['CPPFLAGS'] = '-D' + extra_config
194
borenetb76c1f72015-07-29 07:38:49 -0700195 return env
196
197
198cov_skip.extend([lineno(), lineno() + 1])
borenetb64b1952015-10-21 07:50:57 -0700199def build_targets_from_builder_dict(builder_dict, do_test_steps, do_perf_steps):
borenetb76c1f72015-07-29 07:38:49 -0700200 """Return a list of targets to build, depending on the builder type."""
201 if builder_dict['role'] in ('Test', 'Perf') and builder_dict['os'] == 'iOS':
202 return ['iOSShell']
borenetb64b1952015-10-21 07:50:57 -0700203 if builder_dict.get('extra_config') == 'Appurify':
204 return ['VisualBenchTest_APK']
benjaminwagnerae5c01d2016-05-04 06:35:50 -0700205 if 'SAN' in builder_dict.get('extra_config', ''):
206 # 'most' does not compile under MSAN.
207 return ['dm', 'nanobench']
borenetb64b1952015-10-21 07:50:57 -0700208 t = []
209 if do_test_steps:
210 t.append('dm')
borenetb55448b2016-05-17 10:26:15 -0700211 if builder_dict.get('extra_config') == 'VisualBench':
212 t.append('visualbench')
joshualitt64673af2015-12-16 12:54:19 -0800213 elif do_perf_steps:
borenetb55448b2016-05-17 10:26:15 -0700214 t.append('nanobench')
borenetb64b1952015-10-21 07:50:57 -0700215 if t:
borenetb76c1f72015-07-29 07:38:49 -0700216 return t
borenetb76c1f72015-07-29 07:38:49 -0700217 else:
218 return ['most']
219
220
221cov_skip.extend([lineno(), lineno() + 1])
borenet7bccca12015-07-29 11:15:42 -0700222def device_cfg(builder_dict):
223 # Android.
224 if 'Android' in builder_dict.get('extra_config', ''):
225 if 'NoNeon' in builder_dict['extra_config']:
226 return 'arm_v7'
227 return {
228 'Arm64': 'arm64',
229 'x86': 'x86',
230 'x86_64': 'x86_64',
231 'Mips': 'mips',
232 'Mips64': 'mips64',
233 'MipsDSP2': 'mips_dsp2',
234 }.get(builder_dict['target_arch'], 'arm_v7_neon')
235 elif builder_dict.get('os') == 'Android':
236 return {
mtklein80fc19c2016-01-21 14:24:10 -0800237 'AndroidOne': 'arm_v7_neon',
238 'GalaxyS3': 'arm_v7_neon',
239 'GalaxyS4': 'arm_v7_neon',
borenet7bccca12015-07-29 11:15:42 -0700240 'NVIDIA_Shield': 'arm64',
mtklein80fc19c2016-01-21 14:24:10 -0800241 'Nexus10': 'arm_v7_neon',
242 'Nexus5': 'arm_v7_neon',
243 'Nexus6': 'arm_v7_neon',
244 'Nexus7': 'arm_v7_neon',
borenetcafbfe62016-04-01 07:18:27 -0700245 'Nexus7v2': 'arm_v7_neon',
mtklein80fc19c2016-01-21 14:24:10 -0800246 'Nexus9': 'arm64',
247 'NexusPlayer': 'x86',
borenet7bccca12015-07-29 11:15:42 -0700248 }[builder_dict['model']]
249
borenetd32eac22016-04-05 12:14:59 -0700250 # iOS.
251 if 'iOS' in builder_dict.get('os', ''):
252 return {
253 'iPad4': 'iPad4,1',
254 }[builder_dict['model']]
255
borenet7bccca12015-07-29 11:15:42 -0700256 return None
257
258
259cov_skip.extend([lineno(), lineno() + 1])
borenetcafbfe62016-04-01 07:18:27 -0700260def product_board(builder_dict):
261 if 'Android' in builder_dict.get('os', ''):
262 return {
263 'AndroidOne': None, # TODO(borenet,kjlubick)
borenet649becd2016-05-26 11:21:02 -0700264 'GalaxyS3': 'm0', #'smdk4x12', Detected incorrectly by swarming?
borenetcafbfe62016-04-01 07:18:27 -0700265 'GalaxyS4': None, # TODO(borenet,kjlubick)
borenet9d19cc62016-06-03 07:01:32 -0700266 'NVIDIA_Shield': 'foster',
borenetcafbfe62016-04-01 07:18:27 -0700267 'Nexus10': 'manta',
268 'Nexus5': 'hammerhead',
269 'Nexus6': 'shamu',
270 'Nexus7': 'grouper',
271 'Nexus7v2': 'flo',
272 'Nexus9': 'flounder',
273 'NexusPlayer': 'fugu',
274 }[builder_dict['model']]
275 return None
276
277
278cov_skip.extend([lineno(), lineno() + 1])
borenetb76c1f72015-07-29 07:38:49 -0700279def get_builder_spec(builder_name):
280 builder_dict = builder_name_schema.DictForBuilderName(builder_name)
281 env = get_extra_env_vars(builder_dict)
282 gyp_defs = gyp_defines(builder_dict)
283 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()]
284 gyp_defs_list.sort()
285 env['GYP_DEFINES'] = ' '.join(gyp_defs_list)
borenet7bccca12015-07-29 11:15:42 -0700286 rv = {
borenet7bccca12015-07-29 11:15:42 -0700287 'builder_cfg': builder_dict,
borenet2481b8b2015-07-29 11:43:07 -0700288 'dm_flags': dm_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700289 'env': env,
borenet2481b8b2015-07-29 11:43:07 -0700290 'nanobench_flags': nanobench_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700291 }
borenet7bccca12015-07-29 11:15:42 -0700292 device = device_cfg(builder_dict)
293 if device:
294 rv['device_cfg'] = device
borenetcafbfe62016-04-01 07:18:27 -0700295 board = product_board(builder_dict)
296 if board:
297 rv['product.board'] = board
borenetdbf9f012015-07-30 07:09:20 -0700298
299 role = builder_dict['role']
300 if role == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
301 configuration = CONFIG_RELEASE
302 else:
303 configuration = builder_dict.get(
304 'configuration', CONFIG_DEBUG)
305 arch = (builder_dict.get('arch') or builder_dict.get('target_arch'))
306 if ('Win' in builder_dict.get('os', '') and arch == 'x86_64'):
307 configuration += '_x64'
308 rv['configuration'] = configuration
rmistry43e8f672016-04-18 04:14:17 -0700309 if configuration == CONFIG_COVERAGE:
310 rv['do_compile_steps'] = False
borenetdbf9f012015-07-30 07:09:20 -0700311 rv['do_test_steps'] = role == builder_name_schema.BUILDER_ROLE_TEST
312 rv['do_perf_steps'] = (role == builder_name_schema.BUILDER_ROLE_PERF or
313 (role == builder_name_schema.BUILDER_ROLE_TEST and
borenet5eaaad22015-10-22 07:06:28 -0700314 configuration == CONFIG_DEBUG))
rmistry0adac462016-04-05 08:24:29 -0700315 if rv['do_test_steps'] and 'Valgrind' in builder_name:
borenet5eaaad22015-10-22 07:06:28 -0700316 rv['do_perf_steps'] = True
317 if 'GalaxyS4' in builder_name:
318 rv['do_perf_steps'] = False
319
borenetb64b1952015-10-21 07:50:57 -0700320 rv['build_targets'] = build_targets_from_builder_dict(
321 builder_dict, rv['do_test_steps'], rv['do_perf_steps'])
borenetdbf9f012015-07-30 07:09:20 -0700322
323 # Do we upload perf results?
324 upload_perf_results = False
325 if role == builder_name_schema.BUILDER_ROLE_PERF:
326 upload_perf_results = True
327 rv['upload_perf_results'] = upload_perf_results
328
329 # Do we upload correctness results?
330 skip_upload_bots = [
331 'ASAN',
332 'Coverage',
mtklein001cc1f2016-02-05 06:16:59 -0800333 'MSAN',
borenetdbf9f012015-07-30 07:09:20 -0700334 'TSAN',
335 'UBSAN',
336 'Valgrind',
337 ]
338 upload_dm_results = True
339 for s in skip_upload_bots:
340 if s in builder_name:
341 upload_dm_results = False
342 break
343 rv['upload_dm_results'] = upload_dm_results
344
borenet7bccca12015-07-29 11:15:42 -0700345 return rv
borenetb76c1f72015-07-29 07:38:49 -0700346
347
348cov_end = lineno() # Don't care about code coverage past here.
349
350
351def self_test():
352 import coverage # This way the bots don't need coverage.py to be installed.
353 args = {}
354 cases = [
355 'Build-Mac10.8-Clang-Arm7-Debug-Android',
356 'Build-Win-MSVC-x86-Debug',
357 'Build-Win-MSVC-x86-Debug-GDI',
358 'Build-Win-MSVC-x86-Debug-Exceptions',
359 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs',
borenet7bccca12015-07-29 11:15:42 -0700360 'Build-Ubuntu-GCC-Arm7-Debug-Android_NoNeon',
borenet08d77472015-09-21 08:20:24 -0700361 'Build-Ubuntu-GCC-x86_64-Release-ANGLE',
borenetb55448b2016-05-17 10:26:15 -0700362 'Build-Ubuntu-GCC-x64_64-Release-Fast',
363 'Build-Ubuntu-GCC-x86_64-Release-Mesa',
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',
borenetb76c1f72015-07-29 07:38:49 -0700370 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
borenet48b88cc2016-04-11 10:16:01 -0700371 'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer',
borenetb76c1f72015-07-29 07:38:49 -0700372 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
borenet98f7e332015-08-24 12:50:59 -0700373 'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage',
borenetb55448b2016-05-17 10:26:15 -0700374 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN',
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',
borenet71e185c2016-04-12 08:13:56 -0700381 'Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan',
borenetb76c1f72015-07-29 07:38:49 -0700382 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE',
383 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug',
384 ]
385
386 cov = coverage.coverage()
387 cov.start()
388 for case in cases:
389 args[case] = get_builder_spec(case)
390 cov.stop()
391
392 this_file = os.path.basename(__file__)
393 _, _, not_run, _ = cov.analysis(this_file)
394 filtered = [line for line in not_run if
395 line > cov_start and line < cov_end and line not in cov_skip]
396 if filtered:
397 print 'Lines not covered by test cases: ', filtered
398 sys.exit(1)
399
400 golden = this_file.replace('.py', '.json')
401 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
402 json.dump(args, f, indent=2, sort_keys=True)
403
404
405if __name__ == '__main__':
406 if len(sys.argv) == 2 and sys.argv[1] == 'test':
407 self_test()
408 sys.exit(0)
409
410 if len(sys.argv) != 3:
411 print usage
412 sys.exit(1)
413
414 with open(sys.argv[1], 'w') as out:
415 json.dump(get_builder_spec(sys.argv[2]), out)