Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2016 Google Inc. | |
| 4 # | |
| 5 # Use of this source code is governed by a BSD-style license that can be | |
| 6 # found in the LICENSE file. | |
| 7 | |
| 8 | |
| 9 import json | |
|
rmistry
2016/02/18 15:29:21
Not used? I wonder why the linter did not catch th
borenet
2016/02/18 15:40:56
Done. I wonder the same.
| |
| 10 import os | |
| 11 import subprocess | |
| 12 import sys | |
| 13 | |
| 14 from flavor import android_flavor | |
| 15 from flavor import chromeos_flavor | |
| 16 from flavor import cmake_flavor | |
| 17 from flavor import coverage_flavor | |
| 18 from flavor import default_flavor | |
| 19 from flavor import ios_flavor | |
| 20 from flavor import valgrind_flavor | |
| 21 from flavor import xsan_flavor | |
| 22 | |
| 23 | |
| 24 CONFIG_COVERAGE = 'Coverage' | |
| 25 CONFIG_DEBUG = 'Debug' | |
| 26 CONFIG_RELEASE = 'Release' | |
| 27 VALID_CONFIGS = (CONFIG_COVERAGE, CONFIG_DEBUG, CONFIG_RELEASE) | |
| 28 | |
| 29 GM_ACTUAL_FILENAME = 'actual-results.json' | |
| 30 GM_EXPECTATIONS_FILENAME = 'expected-results.json' | |
| 31 GM_IGNORE_TESTS_FILENAME = 'ignored-tests.txt' | |
| 32 | |
| 33 GS_GM_BUCKET = 'chromium-skia-gm' | |
| 34 GS_SUMMARIES_BUCKET = 'chromium-skia-gm-summaries' | |
| 35 | |
| 36 SKIA_REPO = 'https://skia.googlesource.com/skia.git' | |
| 37 INFRA_REPO = 'https://skia.googlesource.com/buildbot.git' | |
| 38 | |
| 39 SERVICE_ACCOUNT_FILE = 'service-account-skia.json' | |
| 40 SERVICE_ACCOUNT_INTERNAL_FILE = 'service-account-skia-internal.json' | |
| 41 | |
| 42 | |
| 43 def is_android(bot_cfg): | |
| 44 """Determine whether the given bot is an Android bot.""" | |
| 45 return ('Android' in bot_cfg.get('extra_config', '') or | |
| 46 bot_cfg.get('os') == 'Android') | |
| 47 | |
| 48 def is_chromeos(bot_cfg): | |
| 49 return ('CrOS' in bot_cfg.get('extra_config', '') or | |
| 50 bot_cfg.get('os') == 'ChromeOS') | |
| 51 | |
| 52 def is_cmake(bot_cfg): | |
| 53 return 'CMake' in bot_cfg.get('extra_config', '') | |
| 54 | |
| 55 def is_ios(bot_cfg): | |
| 56 return ('iOS' in bot_cfg.get('extra_config', '') or | |
| 57 bot_cfg.get('os') == 'iOS') | |
| 58 | |
| 59 | |
| 60 def is_valgrind(bot_cfg): | |
| 61 return 'Valgrind' in bot_cfg.get('extra_config', '') | |
| 62 | |
| 63 | |
| 64 def is_xsan(bot_cfg): | |
| 65 return (bot_cfg.get('extra_config') == 'ASAN' or | |
| 66 bot_cfg.get('extra_config') == 'MSAN' or | |
| 67 bot_cfg.get('extra_config') == 'TSAN') | |
| 68 | |
| 69 | |
| 70 class BotInfo(object): | |
| 71 def __init__(self, bot_name, slave_name, out_dir): | |
| 72 """Initialize the bot, given its name. | |
| 73 | |
| 74 Assumes that CWD is the directory containing this file. | |
| 75 """ | |
| 76 self.name = bot_name | |
| 77 self.slave_name = slave_name | |
| 78 self.skia_dir = os.path.abspath(os.path.join( | |
| 79 os.path.dirname(os.path.realpath(__file__)), | |
| 80 os.pardir, os.pardir)) | |
| 81 os.chdir(self.skia_dir) | |
| 82 self.build_dir = os.path.abspath(os.path.join(self.skia_dir, os.pardir)) | |
| 83 self.out_dir = out_dir | |
| 84 self.spec = self.get_bot_spec(bot_name) | |
| 85 self.configuration = self.spec['configuration'] | |
| 86 self.default_env = { | |
| 87 'SKIA_OUT': self.out_dir, | |
| 88 'BUILDTYPE': self.configuration, | |
| 89 'PATH': os.environ['PATH'], | |
| 90 } | |
| 91 self.default_env.update(self.spec['env']) | |
| 92 self.build_targets = [str(t) for t in self.spec['build_targets']] | |
| 93 self.bot_cfg = self.spec['builder_cfg'] | |
| 94 self.is_trybot = self.bot_cfg['is_trybot'] | |
| 95 self.upload_dm_results = self.spec['upload_dm_results'] | |
| 96 self.upload_perf_results = self.spec['upload_perf_results'] | |
| 97 self.dm_flags = self.spec['dm_flags'] | |
| 98 self.nanobench_flags = self.spec['nanobench_flags'] | |
| 99 self._ccache = None | |
| 100 self._checked_for_ccache = False | |
| 101 self.flavor = self.get_flavor(self.bot_cfg) | |
| 102 | |
| 103 @property | |
| 104 def ccache(self): | |
| 105 if not self._checked_for_ccache: | |
| 106 self._checked_for_ccache = True | |
| 107 if sys.platform != 'win32': | |
| 108 try: | |
| 109 result = subprocess.check_output(['which', 'ccache']) | |
| 110 self._ccache = result.rstrip() | |
| 111 except subprocess.CalledProcessError: | |
| 112 pass | |
| 113 | |
| 114 return self._ccache | |
| 115 | |
| 116 def get_bot_spec(self, bot_name): | |
| 117 """Retrieve the bot spec for this bot.""" | |
| 118 sys.path.append(self.skia_dir) | |
| 119 from tools import buildbot_spec | |
| 120 return buildbot_spec.get_builder_spec(bot_name) | |
| 121 | |
| 122 def get_flavor(self, bot_cfg): | |
| 123 """Return a flavor utils object specific to the given bot.""" | |
| 124 if is_android(bot_cfg): | |
| 125 return android_flavor.AndroidFlavorUtils(self) | |
| 126 elif is_chromeos(bot_cfg): | |
| 127 return chromeos_flavor.ChromeOSFlavorUtils(self) | |
| 128 elif is_cmake(bot_cfg): | |
| 129 return cmake_flavor.CMakeFlavorUtils(self) | |
| 130 elif is_ios(bot_cfg): | |
| 131 return ios_flavor.iOSFlavorUtils(self) | |
| 132 elif is_valgrind(bot_cfg): | |
| 133 return valgrind_flavor.ValgrindFlavorUtils(self) | |
| 134 elif is_xsan(bot_cfg): | |
| 135 return xsan_flavor.XSanFlavorUtils(self) | |
| 136 elif bot_cfg.get('configuration') == CONFIG_COVERAGE: | |
| 137 return coverage_flavor.CoverageFlavorUtils(self) | |
| 138 else: | |
| 139 return default_flavor.DefaultFlavorUtils(self) | |
| 140 | |
| 141 def run(self, cmd, env=None, cwd=None): | |
| 142 _env = {} | |
| 143 _env.update(self.default_env) | |
| 144 _env.update(env or {}) | |
| 145 cwd = cwd or self.skia_dir | |
| 146 print '============' | |
| 147 print 'CMD: %s' % cmd | |
| 148 print 'CWD: %s' % cwd | |
| 149 print 'ENV: %s' % _env | |
| 150 print '============' | |
| 151 subprocess.check_call(cmd, env=_env, cwd=cwd) | |
| OLD | NEW |