Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: infra/bots/common.py

Issue 1791513002: Fix compile on Windows swarming bot (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Handle AccessDenied Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | infra/bots/flavor/default_flavor.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 8
9 import contextlib 9 import contextlib
10 import math 10 import math
11 import os 11 import os
12 import psutil
12 import shutil 13 import shutil
13 import socket 14 import socket
14 import subprocess 15 import subprocess
15 import sys 16 import sys
16 import time 17 import time
17 import urllib2 18 import urllib2
18 19
19 from flavor import android_flavor 20 from flavor import android_flavor
20 from flavor import chromeos_flavor 21 from flavor import chromeos_flavor
21 from flavor import cmake_flavor 22 from flavor import cmake_flavor
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 151
151 Assumes that CWD is the directory containing this file. 152 Assumes that CWD is the directory containing this file.
152 """ 153 """
153 self.name = bot_name 154 self.name = bot_name
154 self.skia_dir = os.path.abspath(os.path.join( 155 self.skia_dir = os.path.abspath(os.path.join(
155 os.path.dirname(os.path.realpath(__file__)), 156 os.path.dirname(os.path.realpath(__file__)),
156 os.pardir, os.pardir)) 157 os.pardir, os.pardir))
157 self.swarm_out_dir = swarm_out_dir 158 self.swarm_out_dir = swarm_out_dir
158 os.chdir(self.skia_dir) 159 os.chdir(self.skia_dir)
159 self.build_dir = os.path.abspath(os.path.join(self.skia_dir, os.pardir)) 160 self.build_dir = os.path.abspath(os.path.join(self.skia_dir, os.pardir))
161 self.infrabots_dir = os.path.join(self.skia_dir, 'infra', 'bots')
162 self.home_dir = os.path.expanduser('~')
163
160 self.spec = self.get_bot_spec(bot_name) 164 self.spec = self.get_bot_spec(bot_name)
161 self.bot_cfg = self.spec['builder_cfg'] 165 self.bot_cfg = self.spec['builder_cfg']
162 self.out_dir = os.path.join(os.pardir, 'out') 166 self.out_dir = os.path.join(os.pardir, 'out')
163 self.configuration = self.spec['configuration'] 167 self.configuration = self.spec['configuration']
164 self.default_env = { 168 self.default_env = {
169 'CHROME_HEADLESS': '1',
165 'SKIA_OUT': self.out_dir, 170 'SKIA_OUT': self.out_dir,
166 'BUILDTYPE': self.configuration, 171 'BUILDTYPE': self.configuration,
167 'PATH': os.environ['PATH'], 172 'PATH': os.environ['PATH'],
168 } 173 }
174 if 'Win' in self.bot_cfg['os']:
175 self.default_env['SystemRoot'] = 'C:\\Windows'
176 self.default_env['TEMP'] = os.path.join(
177 self.home_dir, 'AppData', 'Local', 'Temp')
178 self.default_env['TMP'] = self.default_env['TEMP']
169 self.default_env.update(self.spec['env']) 179 self.default_env.update(self.spec['env'])
170 self.build_targets = [str(t) for t in self.spec['build_targets']] 180 self.build_targets = [str(t) for t in self.spec['build_targets']]
171 self.is_trybot = self.bot_cfg['is_trybot'] 181 self.is_trybot = self.bot_cfg['is_trybot']
172 self.upload_dm_results = self.spec['upload_dm_results'] 182 self.upload_dm_results = self.spec['upload_dm_results']
173 self.upload_perf_results = self.spec['upload_perf_results'] 183 self.upload_perf_results = self.spec['upload_perf_results']
174 self.perf_data_dir = os.path.join(self.swarm_out_dir, 'perfdata', 184 self.perf_data_dir = os.path.join(self.swarm_out_dir, 'perfdata',
175 self.name, 'data') 185 self.name, 'data')
176 self.resource_dir = os.path.join(self.skia_dir, 'resources') 186 self.resource_dir = os.path.join(self.skia_dir, 'resources')
177 self.images_dir = os.path.join(self.build_dir, 'images') 187 self.images_dir = os.path.join(self.build_dir, 'images')
178 self.local_skp_dir = os.path.join(self.build_dir, 'playback', 'skps') 188 self.local_skp_dir = os.path.join(self.build_dir, 'playback', 'skps')
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 def compile_steps(self): 254 def compile_steps(self):
245 for t in self.build_targets: 255 for t in self.build_targets:
246 self.flavor.compile(t) 256 self.flavor.compile(t)
247 dst = os.path.join(self.swarm_out_dir, 'out', self.configuration) 257 dst = os.path.join(self.swarm_out_dir, 'out', self.configuration)
248 os.makedirs(dst) 258 os.makedirs(dst)
249 for f in BUILD_PRODUCTS_WHITELIST: 259 for f in BUILD_PRODUCTS_WHITELIST:
250 path = os.path.join(self.out_dir, self.configuration, f) 260 path = os.path.join(self.out_dir, self.configuration, f)
251 if os.path.exists(path): 261 if os.path.exists(path):
252 print 'Copying build product %s' % path 262 print 'Copying build product %s' % path
253 shutil.copy(path, dst) 263 shutil.copy(path, dst)
264 self.cleanup()
254 265
255 def _run_once(self, fn, *args, **kwargs): 266 def _run_once(self, fn, *args, **kwargs):
256 if not fn.__name__ in self._already_ran: 267 if not fn.__name__ in self._already_ran:
257 self._already_ran[fn.__name__] = True 268 self._already_ran[fn.__name__] = True
258 fn(*args, **kwargs) 269 fn(*args, **kwargs)
259 270
260 def install(self): 271 def install(self):
261 """Copy the required executables and files to the device.""" 272 """Copy the required executables and files to the device."""
262 self.device_dirs = self.flavor.get_device_dirs() 273 self.device_dirs = self.flavor.get_device_dirs()
263 274
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 # See skia:2789. 387 # See skia:2789.
377 if ('Valgrind' in self.name and 388 if ('Valgrind' in self.name and
378 self.bot_cfg.get('cpu_or_gpu') == 'GPU'): 389 self.bot_cfg.get('cpu_or_gpu') == 'GPU'):
379 abandonGpuContext = list(args) 390 abandonGpuContext = list(args)
380 abandonGpuContext.append('--abandonGpuContext') 391 abandonGpuContext.append('--abandonGpuContext')
381 self.flavor.run(abandonGpuContext) 392 self.flavor.run(abandonGpuContext)
382 preAbandonGpuContext = list(args) 393 preAbandonGpuContext = list(args)
383 preAbandonGpuContext.append('--preAbandonGpuContext') 394 preAbandonGpuContext.append('--preAbandonGpuContext')
384 self.flavor.run(preAbandonGpuContext) 395 self.flavor.run(preAbandonGpuContext)
385 396
386 self.flavor.cleanup_steps() 397 self.cleanup()
387 398
388 def perf_steps(self, got_revision, master_name, slave_name, build_number, 399 def perf_steps(self, got_revision, master_name, slave_name, build_number,
389 issue=None, patchset=None): 400 issue=None, patchset=None):
390 """Run Skia benchmarks.""" 401 """Run Skia benchmarks."""
391 self.build_number = build_number 402 self.build_number = build_number
392 self.got_revision = got_revision 403 self.got_revision = got_revision
393 self.master_name = master_name 404 self.master_name = master_name
394 self.slave_name = slave_name 405 self.slave_name = slave_name
395 self._run_once(self.install) 406 self._run_once(self.install)
396 if self.upload_perf_results: 407 if self.upload_perf_results:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 abandonGpuContext.extend(['--abandonGpuContext', '--nocpu']) 466 abandonGpuContext.extend(['--abandonGpuContext', '--nocpu'])
456 self.flavor.run(abandonGpuContext, env=self.default_env) 467 self.flavor.run(abandonGpuContext, env=self.default_env)
457 468
458 # Copy results to host. 469 # Copy results to host.
459 if self.upload_perf_results: 470 if self.upload_perf_results:
460 if not os.path.exists(self.perf_data_dir): 471 if not os.path.exists(self.perf_data_dir):
461 os.makedirs(self.perf_data_dir) 472 os.makedirs(self.perf_data_dir)
462 self.flavor.copy_directory_contents_to_host( 473 self.flavor.copy_directory_contents_to_host(
463 self.device_dirs.perf_data_dir, self.perf_data_dir) 474 self.device_dirs.perf_data_dir, self.perf_data_dir)
464 475
476 self.cleanup()
477
478 def cleanup(self):
479 if sys.platform == 'win32':
480 # Kill mspdbsrv.exe, which tends to hang around after the build finishes.
481 for p in psutil.process_iter():
482 try:
483 if p.name == 'mspdbsrv.exe':
484 p.kill()
485 except psutil._error.AccessDenied:
486 pass
465 self.flavor.cleanup_steps() 487 self.flavor.cleanup_steps()
OLDNEW
« no previous file with comments | « no previous file | infra/bots/flavor/default_flavor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698