| OLD | NEW |
| 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 heapq | 10 import heapq |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return binhost.rstrip('\n') | 334 return binhost.rstrip('\n') |
| 335 | 335 |
| 336 | 336 |
| 337 def _SetupBoard(buildroot, board='x86-generic'): | 337 def _SetupBoard(buildroot, board='x86-generic'): |
| 338 """Wrapper around setup_board.""" | 338 """Wrapper around setup_board.""" |
| 339 cwd = os.path.join(buildroot, 'src', 'scripts') | 339 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 340 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], | 340 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], |
| 341 cwd=cwd, enter_chroot=True) | 341 cwd=cwd, enter_chroot=True) |
| 342 | 342 |
| 343 | 343 |
| 344 def _Build(buildroot): | 344 def _Build(buildroot, emptytree): |
| 345 """Wrapper around build_packages.""" | 345 """Wrapper around build_packages.""" |
| 346 cwd = os.path.join(buildroot, 'src', 'scripts') | 346 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 347 RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True) | 347 cmd = ['./build_packages'] |
| 348 if emptytree: |
| 349 cmd.insert(0, 'EXTRA_BOARD_FLAGS=--emptytree') |
| 350 |
| 351 RunCommand(cmd, cwd=cwd, enter_chroot=True) |
| 348 | 352 |
| 349 | 353 |
| 350 def _BuildChrome(buildroot, board, chrome_atom_to_build): | 354 def _BuildChrome(buildroot, board, chrome_atom_to_build): |
| 351 """Wrapper for emerge call to build Chrome.""" | 355 """Wrapper for emerge call to build Chrome.""" |
| 352 cwd = os.path.join(buildroot, 'src', 'scripts') | 356 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 353 RunCommand(['emerge-%s' % board, '=%s' % chrome_atom_to_build], | 357 RunCommand(['emerge-%s' % board, '=%s' % chrome_atom_to_build], |
| 354 cwd=cwd, enter_chroot=True) | 358 cwd=cwd, enter_chroot=True) |
| 355 | 359 |
| 356 | 360 |
| 357 def _EnableLocalAccount(buildroot): | 361 def _EnableLocalAccount(buildroot): |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 chroot_path = os.path.join(buildroot, 'chroot') | 643 chroot_path = os.path.join(buildroot, 'chroot') |
| 640 boardpath = os.path.join(chroot_path, 'build', board) | 644 boardpath = os.path.join(chroot_path, 'build', board) |
| 641 if options.sync: | 645 if options.sync: |
| 642 if options.clobber or not os.path.isdir(buildroot): | 646 if options.clobber or not os.path.isdir(buildroot): |
| 643 _FullCheckout(buildroot, tracking_branch, url=options.url) | 647 _FullCheckout(buildroot, tracking_branch, url=options.url) |
| 644 else: | 648 else: |
| 645 old_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) | 649 old_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) |
| 646 _IncrementalCheckout(buildroot) | 650 _IncrementalCheckout(buildroot) |
| 647 | 651 |
| 648 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) | 652 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) |
| 649 if old_binhost and old_binhost != new_binhost: | 653 emptytree = (old_binhost and old_binhost != new_binhost) |
| 650 RunCommand(['sudo', 'rm', '-rf', boardpath]) | |
| 651 | 654 |
| 652 # Check that all overlays can be found. | 655 # Check that all overlays can be found. |
| 653 for path in rev_overlays: | 656 for path in rev_overlays: |
| 654 if not os.path.isdir(path): | 657 if not os.path.isdir(path): |
| 655 Die('Missing overlay: %s' % path) | 658 Die('Missing overlay: %s' % path) |
| 656 | 659 |
| 657 if not os.path.isdir(chroot_path): | 660 if not os.path.isdir(chroot_path): |
| 658 _MakeChroot(buildroot) | 661 _MakeChroot(buildroot) |
| 659 | 662 |
| 660 if not os.path.isdir(boardpath): | 663 if not os.path.isdir(boardpath): |
| 661 _SetupBoard(buildroot, board=buildconfig['board']) | 664 _SetupBoard(buildroot, board=buildconfig['board']) |
| 662 | 665 |
| 663 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds. | 666 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds. |
| 664 if options.chrome_rev: | 667 if options.chrome_rev: |
| 665 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch, | 668 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch, |
| 666 options.chrome_rev) | 669 options.chrome_rev) |
| 667 elif buildconfig['uprev']: | 670 elif buildconfig['uprev']: |
| 668 _UprevPackages(buildroot, tracking_branch, revisionfile, | 671 _UprevPackages(buildroot, tracking_branch, revisionfile, |
| 669 buildconfig['board'], rev_overlays) | 672 buildconfig['board'], rev_overlays) |
| 670 | 673 |
| 671 _EnableLocalAccount(buildroot) | 674 _EnableLocalAccount(buildroot) |
| 672 # Doesn't rebuild without acquiring more source. | 675 # Doesn't rebuild without acquiring more source. |
| 673 if options.sync: | 676 if options.sync: |
| 674 _Build(buildroot) | 677 _Build(buildroot, emptytree) |
| 675 | 678 |
| 676 if chrome_atom_to_build: | 679 if chrome_atom_to_build: |
| 677 _BuildChrome(buildroot, buildconfig['board'], chrome_atom_to_build) | 680 _BuildChrome(buildroot, buildconfig['board'], chrome_atom_to_build) |
| 678 | 681 |
| 679 if buildconfig['unittests'] and options.tests: | 682 if buildconfig['unittests'] and options.tests: |
| 680 _RunUnitTests(buildroot) | 683 _RunUnitTests(buildroot) |
| 681 | 684 |
| 682 _BuildImage(buildroot) | 685 _BuildImage(buildroot) |
| 683 | 686 |
| 684 if buildconfig['smoke_bvt'] and options.tests: | 687 if buildconfig['smoke_bvt'] and options.tests: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 except: | 720 except: |
| 718 # Send failure to master bot. | 721 # Send failure to master bot. |
| 719 if not buildconfig['master'] and buildconfig['important']: | 722 if not buildconfig['master'] and buildconfig['important']: |
| 720 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 723 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
| 721 | 724 |
| 722 raise | 725 raise |
| 723 | 726 |
| 724 | 727 |
| 725 if __name__ == '__main__': | 728 if __name__ == '__main__': |
| 726 main() | 729 main() |
| OLD | NEW |