OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 import json | 6 import json |
7 import os | 7 import os |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
11 from recipe_engine import recipe_api | 11 from recipe_engine import recipe_api |
| 12 from recipe_engine import config_types |
12 | 13 |
13 # TODO(luqui): Make this recipe stop depending on common so we can make it | 14 # TODO(luqui): Make this recipe stop depending on common so we can make it |
14 # independent of build/. | 15 # independent of build/. |
15 sys.path.append( | 16 sys.path.append( |
16 os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname( | 17 os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname( |
17 os.path.abspath(__file__)))))) | 18 os.path.abspath(__file__)))))) |
18 from common.skia import global_constants | 19 from common.skia import global_constants |
19 | 20 |
20 from . import android_flavor | 21 from . import android_flavor |
21 from . import appurify_flavor | 22 from . import appurify_flavor |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 fake_spec = None | 142 fake_spec = None |
142 if self._test_data.enabled: | 143 if self._test_data.enabled: |
143 fake_spec = fake_specs.FAKE_SPECS[builder_name] | 144 fake_spec = fake_specs.FAKE_SPECS[builder_name] |
144 builder_spec = self.json_from_file( | 145 builder_spec = self.json_from_file( |
145 skia_dir.join('tools', 'buildbot_spec.py'), | 146 skia_dir.join('tools', 'buildbot_spec.py'), |
146 skia_dir, | 147 skia_dir, |
147 builder_name, | 148 builder_name, |
148 fake_spec) | 149 fake_spec) |
149 return builder_spec | 150 return builder_spec |
150 | 151 |
| 152 def make_path(self, *path): |
| 153 """Return a Path object for the given path.""" |
| 154 key = 'custom_%s' % '_'.join(path) |
| 155 self.m.path.c.base_paths[key] = tuple(path) |
| 156 return self.m.path[key] |
| 157 |
151 def setup(self, running_in_swarming=False): | 158 def setup(self, running_in_swarming=False): |
152 """Prepare the bot to run.""" | 159 """Prepare the bot to run.""" |
153 # Setup | 160 # Setup |
154 self.failed = [] | 161 self.failed = [] |
155 | 162 |
156 self.builder_name = self.m.properties['buildername'] | 163 self.builder_name = self.m.properties['buildername'] |
157 self.master_name = self.m.properties['mastername'] | 164 self.master_name = self.m.properties['mastername'] |
158 self.slave_name = self.m.properties['slavename'] | 165 self.slave_name = self.m.properties['slavename'] |
159 | 166 |
160 self.slave_dir = self.m.path['slave_build'] | 167 self.slave_dir = self.m.path['slave_build'] |
161 self.skia_dir = self.slave_dir.join('skia') | 168 self.checkout_root = self.slave_dir |
162 self.infrabots_dir = self.skia_dir.join('infra', 'bots') | 169 self.default_env = {} |
| 170 self.is_compile_bot = self.builder_name.startswith('Build-') |
163 | 171 |
164 self.default_env = {} | |
165 if running_in_swarming: | 172 if running_in_swarming: |
166 self.default_env['CHROME_HEADLESS'] = '1' | 173 self.default_env['CHROME_HEADLESS'] = '1' |
167 depot_tools = self.slave_dir.join('depot_tools') | 174 # The 'build' and 'depot_tools' directories are provided through isolate |
168 self.default_env['PATH'] = '%s:%%(PATH)s' % depot_tools | 175 # and aren't in the expected location, so we need to override them. |
| 176 self.m.path.c.base_paths['depot_tools'] = ( |
| 177 self.m.path.c.base_paths['slave_build'] + ('depot_tools',)) |
| 178 self.default_env['PATH'] = '%s:%%(PATH)s' % self.m.path['depot_tools'] |
| 179 self.m.path.c.base_paths['build'] = ( |
| 180 self.m.path.c.base_paths['slave_build'] + ('build',)) |
| 181 self.default_env['PYTHONPATH'] = self.m.path['build'].join('scripts') |
| 182 |
| 183 # Compile bots keep a persistent checkout. |
| 184 if self.is_compile_bot: |
| 185 if 'Win' in self.builder_name: |
| 186 self.checkout_root = self.make_path('C:\\', 'b', 'cache') |
| 187 else: |
| 188 self.checkout_root = self.make_path('/', 'b', 'cache') |
| 189 |
| 190 self.skia_dir = self.checkout_root.join('skia') |
| 191 self.infrabots_dir = self.skia_dir.join('infra', 'bots') |
169 | 192 |
170 # We run through this recipe in one of two ways: | 193 # We run through this recipe in one of two ways: |
171 # 1. Normal bot: run all of the steps. | 194 # 1. Normal bot: run all of the steps. |
172 # 2. Running as a Swarming task: perform the given task only, with | 195 # 2. Running as a Swarming task: perform the given task only, with |
173 # adaptations for running within Swarming, eg. copying build results | 196 # adaptations for running within Swarming, eg. copying build results |
174 # into the correct output directory. | 197 # into the correct output directory. |
175 self.running_in_swarming = running_in_swarming | 198 self.running_in_swarming = running_in_swarming |
176 | 199 |
177 # Some bots also require a checkout of chromium. | 200 # Some bots also require a checkout of chromium. |
178 self._need_chromium_checkout = 'CommandBuffer' in self.builder_name | 201 self._need_chromium_checkout = 'CommandBuffer' in self.builder_name |
179 | 202 |
180 # Check out the Skia code. | 203 # Check out the Skia code. |
181 self.checkout_steps() | 204 self.checkout_steps() |
182 | 205 |
183 # Obtain the spec for this builder from the Skia repo. Use it to set more | 206 # Obtain the spec for this builder from the Skia repo. Use it to set more |
184 # properties. | 207 # properties. |
185 self.builder_spec = self.get_builder_spec(self.skia_dir, self.builder_name) | 208 self.builder_spec = self.get_builder_spec(self.skia_dir, self.builder_name) |
186 | 209 |
187 self.builder_cfg = self.builder_spec['builder_cfg'] | 210 self.builder_cfg = self.builder_spec['builder_cfg'] |
188 self.role = self.builder_cfg['role'] | 211 self.role = self.builder_cfg['role'] |
189 | 212 |
190 # Set some important variables. | 213 # Set some important variables. |
191 self.resource_dir = self.skia_dir.join('resources') | 214 self.resource_dir = self.skia_dir.join('resources') |
192 self.images_dir = self.slave_dir.join('images') | 215 self.images_dir = self.slave_dir.join('images') |
| 216 self.out_dir = self.skia_dir.join('out', self.builder_name) |
193 if self.running_in_swarming: | 217 if self.running_in_swarming: |
194 self.swarming_out_dir = self.m.properties['swarm_out_dir'] | 218 self.swarming_out_dir = self.m.properties['swarm_out_dir'] |
195 self.out_dir = self.slave_dir.join('out') | |
196 self.local_skp_dir = self.slave_dir.join('skps') | 219 self.local_skp_dir = self.slave_dir.join('skps') |
| 220 if not self.is_compile_bot: |
| 221 self.out_dir = self.slave_dir.join('out') |
197 else: | 222 else: |
198 self.out_dir = self.m.path['checkout'].join('out', self.builder_name) | |
199 self.local_skp_dir = self.slave_dir.join('playback', 'skps') | 223 self.local_skp_dir = self.slave_dir.join('playback', 'skps') |
200 self.tmp_dir = self.m.path['slave_build'].join('tmp') | 224 self.tmp_dir = self.m.path['slave_build'].join('tmp') |
201 | 225 |
202 self.gsutil_env_chromium_skia_gm = self.gsutil_env(BOTO_CHROMIUM_SKIA_GM) | 226 self.gsutil_env_chromium_skia_gm = self.gsutil_env(BOTO_CHROMIUM_SKIA_GM) |
203 | 227 |
204 self.device_dirs = None | 228 self.device_dirs = None |
205 self._ccache = None | 229 self._ccache = None |
206 self._checked_for_ccache = False | 230 self._checked_for_ccache = False |
207 self.configuration = self.builder_spec['configuration'] | 231 self.configuration = self.builder_spec['configuration'] |
208 self.default_env.update({'SKIA_OUT': self.out_dir, | 232 self.default_env.update({'SKIA_OUT': self.out_dir, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 raise self.m.step.StepFailure('Failed build steps: %s' % | 272 raise self.m.step.StepFailure('Failed build steps: %s' % |
249 ', '.join([f.name for f in self.failed])) | 273 ', '.join([f.name for f in self.failed])) |
250 | 274 |
251 def _run_once(self, fn, *args, **kwargs): | 275 def _run_once(self, fn, *args, **kwargs): |
252 if not hasattr(self, '_already_ran'): | 276 if not hasattr(self, '_already_ran'): |
253 self._already_ran = {} | 277 self._already_ran = {} |
254 if not fn.__name__ in self._already_ran: | 278 if not fn.__name__ in self._already_ran: |
255 self._already_ran[fn.__name__] = True | 279 self._already_ran[fn.__name__] = True |
256 fn(*args, **kwargs) | 280 fn(*args, **kwargs) |
257 | 281 |
258 def update_repo(self, repo): | 282 def update_repo(self, parent_dir, repo): |
259 """Update an existing repo. This is safe to call without gen_steps.""" | 283 """Update an existing repo. This is safe to call without gen_steps.""" |
260 repo_path = self.m.path['slave_build'].join(repo.name) | 284 repo_path = parent_dir.join(repo.name) |
261 if self.m.path.exists(repo_path): | 285 if self.m.path.exists(repo_path): |
262 if self.m.platform.is_win: | 286 if self.m.platform.is_win: |
263 git = 'git.bat' | 287 git = 'git.bat' |
264 else: | 288 else: |
265 git = 'git' | 289 git = 'git' |
266 self.m.step('git remote set-url', | 290 self.m.step('git remote set-url', |
267 cmd=[git, 'remote', 'set-url', 'origin', repo.url], | 291 cmd=[git, 'remote', 'set-url', 'origin', repo.url], |
268 cwd=repo_path, | 292 cwd=repo_path, |
269 infra_step=True) | 293 infra_step=True) |
270 self.m.step('git fetch', | 294 self.m.step('git fetch', |
271 cmd=[git, 'fetch'], | 295 cmd=[git, 'fetch'], |
272 cwd=repo_path, | 296 cwd=repo_path, |
273 infra_step=True) | 297 infra_step=True) |
274 self.m.step('git reset', | 298 self.m.step('git reset', |
275 cmd=[git, 'reset', '--hard', repo.revision], | 299 cmd=[git, 'reset', '--hard', repo.revision], |
276 cwd=repo_path, | 300 cwd=repo_path, |
277 infra_step=True) | 301 infra_step=True) |
278 self.m.step('git clean', | 302 self.m.step('git clean', |
279 cmd=[git, 'clean', '-d', '-f'], | 303 cmd=[git, 'clean', '-d', '-f'], |
280 cwd=repo_path, | 304 cwd=repo_path, |
281 infra_step=True) | 305 infra_step=True) |
282 | 306 |
283 def checkout_steps(self): | 307 def checkout_steps(self): |
284 """Run the steps to obtain a checkout of Skia.""" | 308 """Run the steps to obtain a checkout of Skia.""" |
| 309 cfg_kwargs = {} |
285 if self.running_in_swarming: | 310 if self.running_in_swarming: |
286 # We should've obtained the Skia checkout through isolates, so we don't | 311 if not self.is_compile_bot: |
287 # need to perform the checkout ourselves. | 312 # We should've obtained the Skia checkout through isolates, so we don't |
288 self.m.path['checkout'] = self.m.path['slave_build'].join('skia') | 313 # need to perform the checkout ourselves. |
289 self.got_revision = self.m.properties['revision'] | 314 self.m.path['checkout'] = self.skia_dir |
290 return | 315 self.got_revision = self.m.properties['revision'] |
| 316 return |
| 317 |
| 318 # The gclient cache gets deleted by Swarming, so don't use it. |
| 319 cfg_kwargs['CACHE_DIR'] = None |
| 320 |
| 321 # Create the checkout path if necessary. |
| 322 if not self.m.path.exists(self.checkout_root): |
| 323 self.m.file.makedirs('checkout_path', self.checkout_root, infra_step=True) |
291 | 324 |
292 # Initial cleanup. | 325 # Initial cleanup. |
293 gclient_cfg = self.m.gclient.make_config() | 326 gclient_cfg = self.m.gclient.make_config(**cfg_kwargs) |
294 skia = gclient_cfg.solutions.add() | 327 skia = gclient_cfg.solutions.add() |
295 skia.name = 'skia' | 328 skia.name = 'skia' |
296 skia.managed = False | 329 skia.managed = False |
297 skia.url = global_constants.SKIA_REPO | 330 skia.url = global_constants.SKIA_REPO |
298 skia.revision = self.m.properties.get('revision') or 'origin/master' | 331 skia.revision = self.m.properties.get('revision') or 'origin/master' |
299 self.update_repo(skia) | 332 self.update_repo(self.checkout_root, skia) |
300 | 333 |
301 if self._need_chromium_checkout: | 334 if self._need_chromium_checkout: |
302 chromium = gclient_cfg.solutions.add() | 335 chromium = gclient_cfg.solutions.add() |
303 chromium.name = 'src' | 336 chromium.name = 'src' |
304 chromium.managed = False | 337 chromium.managed = False |
305 chromium.url = 'https://chromium.googlesource.com/chromium/src.git' | 338 chromium.url = 'https://chromium.googlesource.com/chromium/src.git' |
306 chromium.revision = 'origin/lkgr' | 339 chromium.revision = 'origin/lkgr' |
307 self.update_repo(chromium) | 340 self.update_repo(self.checkout_root, chromium) |
308 | 341 |
309 # Run 'gclient sync'. | 342 # Run 'gclient sync'. |
310 gclient_cfg.got_revision_mapping['skia'] = 'got_revision' | 343 gclient_cfg.got_revision_mapping['skia'] = 'got_revision' |
311 gclient_cfg.target_os.add('llvm') | 344 gclient_cfg.target_os.add('llvm') |
312 update_step = self.m.gclient.checkout(gclient_config=gclient_cfg) | 345 checkout_kwargs = {} |
| 346 if self.running_in_swarming: |
| 347 checkout_kwargs['env'] = self.default_env |
| 348 update_step = self.m.gclient.checkout(gclient_config=gclient_cfg, |
| 349 cwd=self.checkout_root, |
| 350 **checkout_kwargs) |
313 | 351 |
314 self.got_revision = update_step.presentation.properties['got_revision'] | 352 self.got_revision = update_step.presentation.properties['got_revision'] |
315 self.m.tryserver.maybe_apply_issue() | 353 self.m.tryserver.maybe_apply_issue() |
316 | 354 |
317 if self._need_chromium_checkout: | 355 if self._need_chromium_checkout: |
318 self.m.gclient.runhooks() | 356 self.m.gclient.runhooks() |
319 | 357 |
320 def copy_build_products(self, src, dst): | 358 def copy_build_products(self, src, dst): |
321 """Copy whitelisted build products from src to dst.""" | 359 """Copy whitelisted build products from src to dst.""" |
322 self.m.python.inline( | 360 self.m.python.inline( |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 # Don't bother to include role, which is always Test. | 895 # Don't bother to include role, which is always Test. |
858 # TryBots are uploaded elsewhere so they can use the same key. | 896 # TryBots are uploaded elsewhere so they can use the same key. |
859 blacklist = ['role', 'is_trybot'] | 897 blacklist = ['role', 'is_trybot'] |
860 | 898 |
861 flat = [] | 899 flat = [] |
862 for k in sorted(self.builder_cfg.keys()): | 900 for k in sorted(self.builder_cfg.keys()): |
863 if k not in blacklist: | 901 if k not in blacklist: |
864 flat.append(k) | 902 flat.append(k) |
865 flat.append(self.builder_cfg[k]) | 903 flat.append(self.builder_cfg[k]) |
866 return flat | 904 return flat |
OLD | NEW |