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

Side by Side Diff: bin/cbuildbot.py

Issue 3337007: Faster checkout and cleanup of old builds. (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: ws Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """CBuildbot is wrapper around the build process used by the pre-flight queue""" 7 """CBuildbot is wrapper around the build process used by the pre-flight queue"""
8 8
9 import errno 9 import errno
10 import re 10 import re
(...skipping 29 matching lines...) Expand all
40 40
41 41
42 def RepoSync(buildroot, rw_checkout=False, retries=_DEFAULT_RETRIES): 42 def RepoSync(buildroot, rw_checkout=False, retries=_DEFAULT_RETRIES):
43 """Uses repo to checkout the source code. 43 """Uses repo to checkout the source code.
44 44
45 Keyword arguments: 45 Keyword arguments:
46 rw_checkout -- Reconfigure repo after sync'ing to read-write. 46 rw_checkout -- Reconfigure repo after sync'ing to read-write.
47 retries -- Number of retries to try before failing on the sync. 47 retries -- Number of retries to try before failing on the sync.
48 48
49 """ 49 """
50 # Get the number of processors to use with repo sync.
51 num_procs = int(RunCommand('grep -c processor /proc/cpuinfo'.split(),
52 print_cmd=False, redirect_stdout=True))
53
50 while retries > 0: 54 while retries > 0:
51 try: 55 try:
52 RunCommand(['repo', 'sync'], cwd=buildroot) 56 RunCommand(['repo', 'sync', '--jobs=%d' % (num_procs)], cwd=buildroot)
53 if rw_checkout: 57 if rw_checkout:
54 # Always re-run in case of new git repos or repo sync 58 # Always re-run in case of new git repos or repo sync
55 # failed in a previous run because of a forced Stop Build. 59 # failed in a previous run because of a forced Stop Build.
56 RunCommand(['repo', 'forall', '-c', 'git', 'config', 60 RunCommand(['repo', 'forall', '-c', 'git', 'config',
57 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof', 61 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof',
58 'http://git.chromium.org/git'], cwd=buildroot) 62 'http://git.chromium.org/git'], cwd=buildroot)
59 63
60 retries = 0 64 retries = 0
61 except: 65 except:
62 retries -= 1 66 retries -= 1
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 cwd = os.path.join(buildroot, 'src', 'scripts') 235 cwd = os.path.join(buildroot, 'src', 'scripts')
232 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], 236 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board],
233 cwd=cwd, enter_chroot=True) 237 cwd=cwd, enter_chroot=True)
234 238
235 239
236 def _Build(buildroot): 240 def _Build(buildroot):
237 """Wrapper around build_packages.""" 241 """Wrapper around build_packages."""
238 cwd = os.path.join(buildroot, 'src', 'scripts') 242 cwd = os.path.join(buildroot, 'src', 'scripts')
239 RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True) 243 RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True)
240 244
245 def _WipeOldOutput(buildroot):
246 RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
247
241 def _BuildImage(buildroot): 248 def _BuildImage(buildroot):
249 _WipeOldOutput(buildroot)
250
242 cwd = os.path.join(buildroot, 'src', 'scripts') 251 cwd = os.path.join(buildroot, 'src', 'scripts')
243 RunCommand(['./build_image', '--replace'], cwd=cwd, enter_chroot=True) 252 RunCommand(['./build_image', '--replace'], cwd=cwd, enter_chroot=True)
244 253
245 def _RunUnitTests(buildroot): 254 def _RunUnitTests(buildroot):
246 cwd = os.path.join(buildroot, 'src', 'scripts') 255 cwd = os.path.join(buildroot, 'src', 'scripts')
247 RunCommand(['./cros_run_unit_tests'], cwd=cwd, enter_chroot=True) 256 RunCommand(['./cros_run_unit_tests'], cwd=cwd, enter_chroot=True)
248 257
249 258
250 def _UprevPackages(buildroot, revisionfile, board): 259 def _UprevPackages(buildroot, revisionfile, board):
251 """Uprevs a package based on given revisionfile. 260 """Uprevs a package based on given revisionfile.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 except: 400 except:
392 # Send failure to master bot. 401 # Send failure to master bot.
393 if not buildconfig['master'] and buildconfig['important']: 402 if not buildconfig['master'] and buildconfig['important']:
394 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) 403 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED)
395 404
396 raise 405 raise
397 406
398 407
399 if __name__ == '__main__': 408 if __name__ == '__main__':
400 main() 409 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698