2 # Copyright 2015 Google Inc.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
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
14 $ python buildbot_spec.py test
22 import builder_name_schema
24 import nanobench_flags
27 CONFIG_DEBUG = 'Debug'
28 CONFIG_RELEASE = 'Release'
32 caller = inspect.stack()[1] # Up one level to our caller.
33 return inspect.getframeinfo(caller[0]).lineno
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.
40 cov_start = lineno()+1 # We care about coverage starting just past this def.
41 def gyp_defines(builder_dict):
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:
50 arch = builder_dict['arch']
61 if arch in arch_types:
62 gyp_defs['skia_arch_type'] = arch_types[arch]
64 # housekeeper: build shared lib.
65 if builder_dict['role'] == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
66 gyp_defs['skia_shared_lib'] = '1'
69 if builder_dict.get('cpu_or_gpu') == 'CPU':
70 gyp_defs['skia_gpu'] = '0'
72 # skia_warnings_as_errors.
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', '')):
79 elif ('Mac' in builder_dict.get('os', '') and
80 'Android' in builder_dict.get('extra_config', '')):
84 gyp_defs['skia_warnings_as_errors'] = str(int(werr)) # True/False -> '1'/'0'
87 if 'Win' in builder_dict.get('os', ''):
88 gyp_defs['skia_win_debuggers_path'] = 'c:/DbgHelp'
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/'
95 gyp_defs['qt_sdk'] = 'C:/Qt/4.8.5/'
98 if builder_dict.get('extra_config') == 'ANGLE':
99 gyp_defs['skia_angle'] = '1'
100 if builder_dict.get('os', '') in ('Ubuntu', 'Linux'):
101 gyp_defs['use_x11'] = '1'
102 gyp_defs['chromeos'] = '0'
105 if builder_dict.get('extra_config') == 'GDI':
106 gyp_defs['skia_gdi'] = '1'
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'
114 if (builder_dict.get('os') == 'iOS' or
115 builder_dict.get('extra_config') == 'iOS'):
116 gyp_defs['skia_os'] = 'ios'
118 # Shared library build.
119 if builder_dict.get('extra_config') == 'Shared':
120 gyp_defs['skia_shared_lib'] = '1'
123 if (builder_dict.get('os') == 'Mac10.8' and
124 builder_dict.get('arch') == 'x86_64' and
125 builder_dict.get('configuration') == 'Release'):
126 gyp_defs['skia_run_pdfviewer_in_gm'] = '1'
129 if builder_dict.get('compiler') == 'Clang':
130 gyp_defs['skia_clang_build'] = '1'
133 if 'Valgrind' in builder_dict.get('extra_config', ''):
134 gyp_defs['skia_release_optimization_level'] = '1'
136 # Link-time code generation just wastes time on compile-only bots.
137 if (builder_dict.get('role') == builder_name_schema.BUILDER_ROLE_BUILD and
138 builder_dict.get('compiler') == 'MSVC'):
139 gyp_defs['skia_win_ltcg'] = '0'
142 if (builder_dict.get('extra_config') == 'Mesa' or
143 builder_dict.get('cpu_or_gpu_value') == 'Mesa'):
144 gyp_defs['skia_mesa'] = '1'
146 # skia_use_android_framework_defines.
147 if builder_dict.get('extra_config') == 'Android_FrameworkDefs':
148 gyp_defs['skia_use_android_framework_defines'] = '1'
153 cov_skip.extend([lineno(), lineno() + 1])
154 def get_extra_env_vars(builder_dict):
156 if builder_dict.get('configuration') == 'Coverage':
157 # We have to use Clang 3.6 because earlier versions do not support the
158 # compile flags we use and 3.7 and 3.8 hit asserts during compilation.
159 env['CC'] = '/usr/bin/clang-3.6'
160 env['CXX'] = '/usr/bin/clang++-3.6'
161 elif builder_dict.get('compiler') == 'Clang':
162 env['CC'] = '/usr/bin/clang'
163 env['CXX'] = '/usr/bin/clang++'
165 # SKNX_NO_SIMD, SK_USE_DISCARDABLE_SCALEDIMAGECACHE, etc.
166 extra_config = builder_dict.get('extra_config', '')
167 if extra_config.startswith('SK') and extra_config.isupper():
168 env['CPPFLAGS'] = '-D' + extra_config
173 cov_skip.extend([lineno(), lineno() + 1])
174 def build_targets_from_builder_dict(builder_dict, do_test_steps, do_perf_steps):
175 """Return a list of targets to build, depending on the builder type."""
176 if builder_dict['role'] in ('Test', 'Perf') and builder_dict['os'] == 'iOS':
178 if builder_dict.get('extra_config') == 'Appurify':
179 return ['VisualBenchTest_APK']
184 t.append('nanobench')
191 cov_skip.extend([lineno(), lineno() + 1])
192 def device_cfg(builder_dict):
194 if 'Android' in builder_dict.get('extra_config', ''):
195 if 'NoNeon' in builder_dict['extra_config']:
203 'MipsDSP2': 'mips_dsp2',
204 }.get(builder_dict['target_arch'], 'arm_v7_neon')
205 elif builder_dict.get('os') == 'Android':
207 'GalaxyS3': 'arm_v7_neon',
208 'GalaxyS4': 'arm_v7_neon',
209 'Nexus5': 'arm_v7', # This'd be 'nexus_5', but we simulate no-NEON Clank.
210 'Nexus6': 'arm_v7_neon',
213 'Nexus10': 'nexus_10',
214 'NexusPlayer': 'x86',
215 'NVIDIA_Shield': 'arm64',
216 }[builder_dict['model']]
219 if 'CrOS' in builder_dict.get('extra_config', ''):
220 if 'Link' in builder_dict['extra_config']:
222 if 'Daisy' in builder_dict['extra_config']:
224 elif builder_dict.get('os') == 'ChromeOS':
228 }[builder_dict['model']]
233 cov_skip.extend([lineno(), lineno() + 1])
234 def get_builder_spec(builder_name):
235 builder_dict = builder_name_schema.DictForBuilderName(builder_name)
236 env = get_extra_env_vars(builder_dict)
237 gyp_defs = gyp_defines(builder_dict)
238 gyp_defs_list = ['%s=%s' % (k, v) for k, v in gyp_defs.iteritems()]
240 env['GYP_DEFINES'] = ' '.join(gyp_defs_list)
242 'builder_cfg': builder_dict,
243 'dm_flags': dm_flags.get_args(builder_name),
245 'nanobench_flags': nanobench_flags.get_args(builder_name),
247 device = device_cfg(builder_dict)
249 rv['device_cfg'] = device
251 role = builder_dict['role']
252 if role == builder_name_schema.BUILDER_ROLE_HOUSEKEEPER:
253 configuration = CONFIG_RELEASE
255 configuration = builder_dict.get(
256 'configuration', CONFIG_DEBUG)
257 arch = (builder_dict.get('arch') or builder_dict.get('target_arch'))
258 if ('Win' in builder_dict.get('os', '') and arch == 'x86_64'):
259 configuration += '_x64'
260 rv['configuration'] = configuration
261 rv['do_test_steps'] = role == builder_name_schema.BUILDER_ROLE_TEST
262 rv['do_perf_steps'] = (role == builder_name_schema.BUILDER_ROLE_PERF or
263 (role == builder_name_schema.BUILDER_ROLE_TEST and
264 configuration == CONFIG_DEBUG))
265 if 'Valgrind' in builder_name:
266 rv['do_perf_steps'] = True
267 if 'GalaxyS4' in builder_name:
268 rv['do_perf_steps'] = False
270 rv['build_targets'] = build_targets_from_builder_dict(
271 builder_dict, rv['do_test_steps'], rv['do_perf_steps'])
273 # Do we upload perf results?
274 upload_perf_results = False
275 if role == builder_name_schema.BUILDER_ROLE_PERF:
276 upload_perf_results = True
277 rv['upload_perf_results'] = upload_perf_results
279 # Do we upload correctness results?
287 upload_dm_results = True
288 for s in skip_upload_bots:
289 if s in builder_name:
290 upload_dm_results = False
292 rv['upload_dm_results'] = upload_dm_results
297 cov_end = lineno() # Don't care about code coverage past here.
301 import coverage # This way the bots don't need coverage.py to be installed.
304 'Build-Mac10.8-Clang-Arm7-Debug-Android',
305 'Build-Win-MSVC-x86-Debug',
306 'Build-Win-MSVC-x86-Debug-GDI',
307 'Build-Win-MSVC-x86-Debug-Exceptions',
308 'Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs',
309 'Build-Ubuntu-GCC-Arm7-Debug-Android_NoNeon',
310 'Build-Ubuntu-GCC-Arm7-Debug-CrOS_Daisy',
311 'Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link',
312 'Build-Ubuntu-GCC-x86_64-Release-Mesa',
313 'Build-Ubuntu-GCC-x86_64-Release-ANGLE',
314 'Housekeeper-PerCommit',
315 'Perf-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Release-Trybot',
316 'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Debug',
317 'Perf-Android-GCC-Nexus5-GPU-Adreno330-Arm7-Release-Appurify',
318 'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
319 'Test-ChromeOS-GCC-Link-CPU-AVX-x86_64-Debug',
320 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
321 'Test-Mac10.8-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
322 'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage',
323 ('Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-'
324 'SK_USE_DISCARDABLE_SCALEDIMAGECACHE'),
325 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD',
326 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
327 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
328 'Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86-Release-ANGLE',
329 'Test-Win8-MSVC-ShuttleA-CPU-AVX-x86_64-Debug',
332 cov = coverage.coverage()
335 args[case] = get_builder_spec(case)
338 this_file = os.path.basename(__file__)
339 _, _, not_run, _ = cov.analysis(this_file)
340 filtered = [line for line in not_run if
341 line > cov_start and line < cov_end and line not in cov_skip]
343 print 'Lines not covered by test cases: ', filtered
346 golden = this_file.replace('.py', '.json')
347 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
348 json.dump(args, f, indent=2, sort_keys=True)
351 if __name__ == '__main__':
352 if len(sys.argv) == 2 and sys.argv[1] == 'test':
356 if len(sys.argv) != 3:
360 with open(sys.argv[1], 'w') as out:
361 json.dump(get_builder_spec(sys.argv[2]), out)