blob: ae3d4eff7fdd5f3961d0edfa8ea7e804ff88e847 [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']
202 t = []
203 if do_test_steps:
204 t.append('dm')
joshualitt64673af2015-12-16 12:54:19 -0800205 if do_perf_steps and builder_dict.get('extra_config') == 'VisualBench':
206 t.append('visualbench')
207 elif do_perf_steps:
208 t.append('nanobench')
borenetb64b1952015-10-21 07:50:57 -0700209 if t:
borenetb76c1f72015-07-29 07:38:49 -0700210 return t
borenetb76c1f72015-07-29 07:38:49 -0700211 else:
212 return ['most']
213
214
215cov_skip.extend([lineno(), lineno() + 1])
borenet7bccca12015-07-29 11:15:42 -0700216def device_cfg(builder_dict):
217 # Android.
218 if 'Android' in builder_dict.get('extra_config', ''):
219 if 'NoNeon' in builder_dict['extra_config']:
220 return 'arm_v7'
221 return {
222 'Arm64': 'arm64',
223 'x86': 'x86',
224 'x86_64': 'x86_64',
225 'Mips': 'mips',
226 'Mips64': 'mips64',
227 'MipsDSP2': 'mips_dsp2',
228 }.get(builder_dict['target_arch'], 'arm_v7_neon')
229 elif builder_dict.get('os') == 'Android':
230 return {
mtklein80fc19c2016-01-21 14:24:10 -0800231 'AndroidOne': 'arm_v7_neon',
232 'GalaxyS3': 'arm_v7_neon',
233 'GalaxyS4': 'arm_v7_neon',
borenet7bccca12015-07-29 11:15:42 -0700234 'NVIDIA_Shield': 'arm64',
mtklein80fc19c2016-01-21 14:24:10 -0800235 'Nexus10': 'arm_v7_neon',
236 'Nexus5': 'arm_v7_neon',
237 'Nexus6': 'arm_v7_neon',
238 'Nexus7': 'arm_v7_neon',
borenetcafbfe62016-04-01 07:18:27 -0700239 'Nexus7v2': 'arm_v7_neon',
mtklein80fc19c2016-01-21 14:24:10 -0800240 'Nexus9': 'arm64',
241 'NexusPlayer': 'x86',
borenet7bccca12015-07-29 11:15:42 -0700242 }[builder_dict['model']]
243
borenetd32eac22016-04-05 12:14:59 -0700244 # iOS.
245 if 'iOS' in builder_dict.get('os', ''):
246 return {
247 'iPad4': 'iPad4,1',
248 }[builder_dict['model']]
249
borenet7bccca12015-07-29 11:15:42 -0700250 return None
251
252
253cov_skip.extend([lineno(), lineno() + 1])
borenetcafbfe62016-04-01 07:18:27 -0700254def product_board(builder_dict):
255 if 'Android' in builder_dict.get('os', ''):
256 return {
257 'AndroidOne': None, # TODO(borenet,kjlubick)
258 'GalaxyS3': 'smdk4x12',
259 'GalaxyS4': None, # TODO(borenet,kjlubick)
260 'NVIDIA_Shield': None, # TODO(borenet,kjlubick)
261 'Nexus10': 'manta',
262 'Nexus5': 'hammerhead',
263 'Nexus6': 'shamu',
264 'Nexus7': 'grouper',
265 'Nexus7v2': 'flo',
266 'Nexus9': 'flounder',
267 'NexusPlayer': 'fugu',
268 }[builder_dict['model']]
269 return None
270
271
272cov_skip.extend([lineno(), lineno() + 1])
borenetb76c1f72015-07-29 07:38:49 -0700273def get_builder_spec(builder_name):
274 builder_dict = builder_name_schema.DictForBuilderName(builder_name)
275 env = get_extra_env_vars(builder_dict)
276 gyp_defs = gyp_defines(builder_dict)
277 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()]
278 gyp_defs_list.sort()
279 env['GYP_DEFINES'] = ' '.join(gyp_defs_list)
borenet7bccca12015-07-29 11:15:42 -0700280 rv = {
borenet7bccca12015-07-29 11:15:42 -0700281 'builder_cfg': builder_dict,
borenet2481b8b2015-07-29 11:43:07 -0700282 'dm_flags': dm_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700283 'env': env,
borenet2481b8b2015-07-29 11:43:07 -0700284 'nanobench_flags': nanobench_flags.get_args(builder_name),
borenetb76c1f72015-07-29 07:38:49 -0700285 }
borenet7bccca12015-07-29 11:15:42 -0700286 device = device_cfg(builder_dict)
287 if device:
288 rv['device_cfg'] = device
borenetcafbfe62016-04-01 07:18:27 -0700289 board = product_board(builder_dict)
290 if board:
291 rv['product.board'] = board
borenetdbf9f012015-07-30 07:09:20 -0700292
293 role = builder_dict['role']
294 if role == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
295 configuration = CONFIG_RELEASE
296 else:
297 configuration = builder_dict.get(
298 'configuration', CONFIG_DEBUG)
299 arch = (builder_dict.get('arch') or builder_dict.get('target_arch'))
300 if ('Win' in builder_dict.get('os', '') and arch == 'x86_64'):
301 configuration += '_x64'
302 rv['configuration'] = configuration
rmistry43e8f672016-04-18 04:14:17 -0700303 if configuration == CONFIG_COVERAGE:
304 rv['do_compile_steps'] = False
borenetdbf9f012015-07-30 07:09:20 -0700305 rv['do_test_steps'] = role == builder_name_schema.BUILDER_ROLE_TEST
306 rv['do_perf_steps'] = (role == builder_name_schema.BUILDER_ROLE_PERF or
307 (role == builder_name_schema.BUILDER_ROLE_TEST and
borenet5eaaad22015-10-22 07:06:28 -0700308 configuration == CONFIG_DEBUG))
rmistry0adac462016-04-05 08:24:29 -0700309 if rv['do_test_steps'] and 'Valgrind' in builder_name:
borenet5eaaad22015-10-22 07:06:28 -0700310 rv['do_perf_steps'] = True
311 if 'GalaxyS4' in builder_name:
312 rv['do_perf_steps'] = False
313
borenetb64b1952015-10-21 07:50:57 -0700314 rv['build_targets'] = build_targets_from_builder_dict(
315 builder_dict, rv['do_test_steps'], rv['do_perf_steps'])
borenetdbf9f012015-07-30 07:09:20 -0700316
317 # Do we upload perf results?
318 upload_perf_results = False
319 if role == builder_name_schema.BUILDER_ROLE_PERF:
320 upload_perf_results = True
321 rv['upload_perf_results'] = upload_perf_results
322
323 # Do we upload correctness results?
324 skip_upload_bots = [
325 'ASAN',
326 'Coverage',
mtklein001cc1f2016-02-05 06:16:59 -0800327 'MSAN',
borenetdbf9f012015-07-30 07:09:20 -0700328 'TSAN',
329 'UBSAN',
330 'Valgrind',
331 ]
332 upload_dm_results = True
333 for s in skip_upload_bots:
334 if s in builder_name:
335 upload_dm_results = False
336 break
337 rv['upload_dm_results'] = upload_dm_results
338
borenet7bccca12015-07-29 11:15:42 -0700339 return rv
borenetb76c1f72015-07-29 07:38:49 -0700340
341
342cov_end = lineno() # Don't care about code coverage past here.
343
344
345def self_test():
346 import coverage # This way the bots don't need coverage.py to be installed.
347 args = {}
348 cases = [
349 'Build-Mac10.8-Clang-Arm7-Debug-Android',
350 'Build-Win-MSVC-x86-Debug',
351 'Build-Win-MSVC-x86-Debug-GDI',
352 'Build-Win-MSVC-x86-Debug-Exceptions',
353 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs',
borenet7bccca12015-07-29 11:15:42 -0700354 'Build-Ubuntu-GCC-Arm7-Debug-Android_NoNeon',
borenetb76c1f72015-07-29 07:38:49 -0700355 'Build-Ubuntu-GCC-x86_64-Release-Mesa',
borenet08d77472015-09-21 08:20:24 -0700356 'Build-Ubuntu-GCC-x86_64-Release-ANGLE',
borenetb76c1f72015-07-29 07:38:49 -0700357 'Housekeeper-PerCommit',
358 'Perf-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Release-Trybot',
joshualitt64673af2015-12-16 12:54:19 -0800359 'Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release-VisualBench',
borenet5eaaad22015-10-22 07:06:28 -0700360 'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Debug',
borenet98f7e332015-08-24 12:50:59 -0700361 'Perf-Android-GCC-Nexus5-GPU-Adreno330-Arm7-Release-Appurify',
borenet7bccca12015-07-29 11:15:42 -0700362 'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
borenetb76c1f72015-07-29 07:38:49 -0700363 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
borenet48b88cc2016-04-11 10:16:01 -0700364 'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer',
borenetb76c1f72015-07-29 07:38:49 -0700365 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
borenet98f7e332015-08-24 12:50:59 -0700366 'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage',
borenet9063e422015-09-18 06:37:14 -0700367 ('Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-'
368 'SK_USE_DISCARDABLE_SCALEDIMAGECACHE'),
borenetb76c1f72015-07-29 07:38:49 -0700369 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD',
mtklein6f659572016-02-16 06:42:51 -0800370 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Fast',
borenetb76c1f72015-07-29 07:38:49 -0700371 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
372 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
borenet71e185c2016-04-12 08:13:56 -0700373 'Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan',
borenetb76c1f72015-07-29 07:38:49 -0700374 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE',
375 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug',
376 ]
377
378 cov = coverage.coverage()
379 cov.start()
380 for case in cases:
381 args[case] = get_builder_spec(case)
382 cov.stop()
383
384 this_file = os.path.basename(__file__)
385 _, _, not_run, _ = cov.analysis(this_file)
386 filtered = [line for line in not_run if
387 line > cov_start and line < cov_end and line not in cov_skip]
388 if filtered:
389 print 'Lines not covered by test cases: ', filtered
390 sys.exit(1)
391
392 golden = this_file.replace('.py', '.json')
393 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
394 json.dump(args, f, indent=2, sort_keys=True)
395
396
397if __name__ == '__main__':
398 if len(sys.argv) == 2 and sys.argv[1] == 'test':
399 self_test()
400 sys.exit(0)
401
402 if len(sys.argv) != 3:
403 print usage
404 sys.exit(1)
405
406 with open(sys.argv[1], 'w') as out:
407 json.dump(get_builder_spec(sys.argv[2]), out)