Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A tool to build chrome, executed by buildbot. | 6 """A tool to build chrome, executed by buildbot. |
| 7 | 7 |
| 8 When this is run, the current directory (cwd) should be the outer build | 8 When this is run, the current directory (cwd) should be the outer build |
| 9 directory (e.g., chrome-release/build/). | 9 directory (e.g., chrome-release/build/). |
| 10 | 10 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 if (not options.solution or | 428 if (not options.solution or |
| 429 os.path.splitext(options.solution)[1] != '.xcodeproj'): | 429 os.path.splitext(options.solution)[1] != '.xcodeproj'): |
| 430 options.solution = 'all.xcodeproj' | 430 options.solution = 'all.xcodeproj' |
| 431 command.extend(['-project', options.solution]) | 431 command.extend(['-project', options.solution]) |
| 432 | 432 |
| 433 if options.xcode_target: | 433 if options.xcode_target: |
| 434 command.extend(['-target', options.xcode_target]) | 434 command.extend(['-target', options.xcode_target]) |
| 435 | 435 |
| 436 # Note: this clobbers all targets, not just Debug or Release. | 436 # Note: this clobbers all targets, not just Debug or Release. |
| 437 if options.clobber: | 437 if options.clobber: |
| 438 build_output_dir = os.path.join(os.path.dirname(options.build_dir), | 438 clobber_dir = os.path.dirname(options.target_build_dir) |
| 439 'xcodebuild') | 439 print('Removing %s' % clobber_dir) |
| 440 print('Removing %s' % build_output_dir) | |
| 441 # Deleting output_dir would also delete all the .ninja files. iOS builds | 440 # Deleting output_dir would also delete all the .ninja files. iOS builds |
| 442 # generates ninja configuration inside the xcodebuild directory to be able | 441 # generates ninja configuration inside the xcodebuild directory to be able |
| 443 # to run sub builds. crbug.com/138950 is tracking this issue. | 442 # to run sub builds. crbug.com/138950 is tracking this issue. |
| 444 # Moreover clobbering should run before runhooks (which creates | 443 # Moreover clobbering should run before runhooks (which creates |
| 445 # .ninja files). For now, only delete all non-.ninja files. | 444 # .ninja files). For now, only delete all non-.ninja files. |
| 446 # TODO(thakis): Make "clobber" a step that runs before "runhooks". Once the | 445 # TODO(thakis): Make "clobber" a step that runs before "runhooks". Once the |
| 447 # master has been restarted, remove all clobber handling from compile.py. | 446 # master has been restarted, remove all clobber handling from compile.py. |
| 448 ninja_clobber(build_output_dir) | 447 ninja_clobber(clobber_dir) |
| 449 | 448 |
| 450 common_xcode_settings(command, options, env, options.compiler) | 449 common_xcode_settings(command, options, env, options.compiler) |
| 451 | 450 |
| 452 # Add on any remaining args | 451 # Add on any remaining args |
| 453 command.extend(args) | 452 command.extend(args) |
| 454 | 453 |
| 455 # Set up the filter before changing directories so the raw build log can | 454 # Set up the filter before changing directories so the raw build log can |
| 456 # be recorded. | 455 # be recorded. |
| 457 # Support a local file blocking filters (for debugging). Also check the | 456 # Support a local file blocking filters (for debugging). Also check the |
| 458 # Xcode version to make sure it is 3.2, as that is what the filter is coded | 457 # Xcode version to make sure it is 3.2, as that is what the filter is coded |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 print 'using', compiler | 552 print 'using', compiler |
| 554 if compiler == 'goma': | 553 if compiler == 'goma': |
| 555 assert options.goma_dir | 554 assert options.goma_dir |
| 556 env['CC'] = 'gcc' | 555 env['CC'] = 'gcc' |
| 557 env['CXX'] = 'g++' | 556 env['CXX'] = 'g++' |
| 558 env['PATH'] = ':'.join([options.goma_dir, env['PATH']]) | 557 env['PATH'] = ':'.join([options.goma_dir, env['PATH']]) |
| 559 elif compiler == 'goma-clang': | 558 elif compiler == 'goma-clang': |
| 560 assert options.goma_dir | 559 assert options.goma_dir |
| 561 env['CC'] = 'clang' | 560 env['CC'] = 'clang' |
| 562 env['CXX'] = 'clang++' | 561 env['CXX'] = 'clang++' |
| 563 clang_dir = os.path.abspath(os.path.join( | 562 clang_dir = os.path.abspath(os.path.join(options.src_dir, |
|
M-A Ruel
2012/11/06 15:20:01
I guess adding "options.src_dir = os.path.abspath(
iannucci
2012/11/13 20:09:51
I believe this is already essentially implemented
| |
| 564 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', | 563 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) |
| 565 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) | |
| 566 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']]) | 564 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']]) |
| 567 else: # jsonclang | 565 else: # jsonclang |
| 568 env['CC'] = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'jsonclang') | 566 env['CC'] = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'jsonclang') |
| 569 env['CXX'] = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'jsonclang++') | 567 env['CXX'] = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'jsonclang++') |
| 570 command.append('-r') | 568 command.append('-r') |
| 571 command.append('-k') | 569 command.append('-k') |
| 572 # 'jsonclang' assumes the clang binary is in the path. | 570 # 'jsonclang' assumes the clang binary is in the path. |
| 573 clang_dir = os.path.abspath(os.path.join( | 571 clang_dir = os.path.abspath(os.path.join(options.src_dir, |
| 574 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', | 572 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) |
| 575 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) | |
| 576 if options.goma_dir: | 573 if options.goma_dir: |
| 577 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']]) | 574 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']]) |
| 578 else: | 575 else: |
| 579 env['PATH'] = ':'.join([clang_dir, env['PATH']]) | 576 env['PATH'] = ':'.join([clang_dir, env['PATH']]) |
| 580 | 577 |
| 581 command.append('CC.host=' + env['CC']) | 578 command.append('CC.host=' + env['CC']) |
| 582 command.append('CXX.host=' + env['CXX']) | 579 command.append('CXX.host=' + env['CXX']) |
| 583 | 580 |
| 584 if chromium_utils.IsMac(): | 581 if chromium_utils.IsMac(): |
| 585 # The default process limit on 10.6 is 266 (`sysctl kern.maxprocperuid`), | 582 # The default process limit on 10.6 is 266 (`sysctl kern.maxprocperuid`), |
| 586 # and about 100 processes are used by the system. The webkit bindings | 583 # and about 100 processes are used by the system. The webkit bindings |
| 587 # generation scripts open a preprocessor child process, so building at | 584 # generation scripts open a preprocessor child process, so building at |
| 588 # -j100 runs into the process limit. For now, just build with -j50. | 585 # -j100 runs into the process limit. For now, just build with -j50. |
| 589 goma_jobs = 50 | 586 goma_jobs = 50 |
| 590 if options.clobber: | 587 if options.clobber: |
| 591 # Disable compiles on local machine. When the goma server-side object | 588 # Disable compiles on local machine. When the goma server-side object |
| 592 # file cache is warm, this can speed up clobber builds by up to 30%. | 589 # file cache is warm, this can speed up clobber builds by up to 30%. |
| 593 env['GOMA_USE_LOCAL'] = '0' | 590 env['GOMA_USE_LOCAL'] = '0' |
| 594 else: | 591 else: |
| 595 goma_jobs = 100 | 592 goma_jobs = 100 |
| 596 if jobs < goma_jobs: | 593 if jobs < goma_jobs: |
| 597 jobs = goma_jobs | 594 jobs = goma_jobs |
| 598 command.append('-j%d' % jobs) | 595 command.append('-j%d' % jobs) |
| 599 return | 596 return |
| 600 | 597 |
| 601 if compiler == 'clang': | 598 if compiler == 'clang': |
| 602 clang_dir = os.path.abspath(os.path.join( | 599 clang_dir = os.path.abspath(os.path.join(options.src_dir, |
| 603 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', | |
| 604 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) | 600 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) |
| 605 env['CC'] = os.path.join(clang_dir, 'clang') | 601 env['CC'] = os.path.join(clang_dir, 'clang') |
| 606 env['CXX'] = os.path.join(clang_dir, 'clang++') | 602 env['CXX'] = os.path.join(clang_dir, 'clang++') |
| 607 command.append('CC.host=' + env['CC']) | 603 command.append('CC.host=' + env['CC']) |
| 608 command.append('CXX.host=' + env['CXX']) | 604 command.append('CXX.host=' + env['CXX']) |
| 609 command.append('-r') | 605 command.append('-r') |
| 610 | 606 |
| 611 if compiler == 'tsan_gcc': | 607 if compiler == 'tsan_gcc': |
| 612 # See | 608 # See |
| 613 # http://dev.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/ gcc-tsan | 609 # http://dev.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/ gcc-tsan |
| 614 # for build instructions. | 610 # for build instructions. |
| 615 tsan_base = os.path.abspath(os.path.join( | 611 tsan_base = os.path.abspath(os.path.join(options.src_dir, |
| 616 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', | |
| 617 'third_party', 'compiler-tsan')) | 612 'third_party', 'compiler-tsan')) |
| 618 | 613 |
| 619 tsan_gcc_bin = os.path.abspath(os.path.join( | 614 tsan_gcc_bin = os.path.abspath(os.path.join( |
| 620 tsan_base, 'gcc-tsan', 'scripts')) | 615 tsan_base, 'gcc-tsan', 'scripts')) |
| 621 gcctsan_gcc_dir = os.path.abspath(os.path.join( | 616 gcctsan_gcc_dir = os.path.abspath(os.path.join( |
| 622 tsan_base, 'gcc-current')) | 617 tsan_base, 'gcc-current')) |
| 623 | 618 |
| 624 if not os.path.isdir(gcctsan_gcc_dir): | 619 if not os.path.isdir(gcctsan_gcc_dir): |
| 625 # Extract gcc from the tarball. | 620 # Extract gcc from the tarball. |
| 626 extract_gcc_sh = os.path.abspath(os.path.join( | 621 extract_gcc_sh = os.path.abspath(os.path.join( |
| 627 tsan_base, 'extract_gcc.sh')) | 622 tsan_base, 'extract_gcc.sh')) |
| 628 assert(os.path.exists(extract_gcc_sh)) | 623 assert(os.path.exists(extract_gcc_sh)) |
| 629 chromium_utils.RunCommand([extract_gcc_sh]) | 624 chromium_utils.RunCommand([extract_gcc_sh]) |
| 630 assert(os.path.isdir(gcctsan_gcc_dir)) | 625 assert(os.path.isdir(gcctsan_gcc_dir)) |
| 631 | 626 |
| 632 env['CC'] = os.path.join(tsan_gcc_bin, 'gcc') | 627 env['CC'] = os.path.join(tsan_gcc_bin, 'gcc') |
| 633 env['CXX'] = os.path.join(tsan_gcc_bin, 'g++') | 628 env['CXX'] = os.path.join(tsan_gcc_bin, 'g++') |
| 634 env['LD'] = os.path.join(tsan_gcc_bin, 'ld') | 629 env['LD'] = os.path.join(tsan_gcc_bin, 'ld') |
| 635 # GCCTSAN_GCC_DIR and GCCTSAN_GCC_VER point to the symlinks to the current | 630 # GCCTSAN_GCC_DIR and GCCTSAN_GCC_VER point to the symlinks to the current |
| 636 # versions of the compiler and the instrumentation plugin created by | 631 # versions of the compiler and the instrumentation plugin created by |
| 637 # extract_gcc.sh | 632 # extract_gcc.sh |
| 638 env['GCCTSAN_GCC_DIR'] = gcctsan_gcc_dir | 633 env['GCCTSAN_GCC_DIR'] = gcctsan_gcc_dir |
| 639 env['GCCTSAN_GCC_VER'] = 'current' | 634 env['GCCTSAN_GCC_VER'] = 'current' |
| 640 env['GCCTSAN_IGNORE'] = os.path.abspath(os.path.join( | 635 env['GCCTSAN_IGNORE'] = os.path.abspath(os.path.join( |
| 641 slave_utils.SlaveBaseDir(options.build_dir), | 636 options.src_dir, 'tools', 'valgrind', 'tsan', 'ignores.txt')) |
| 642 'build', 'src', 'tools', 'valgrind', 'tsan', 'ignores.txt')) | |
| 643 env['GCCTSAN_ARGS'] = ( | 637 env['GCCTSAN_ARGS'] = ( |
| 644 '-DADDRESS_SANITIZER -DWTF_USE_DYNAMIC_ANNOTATIONS=1 ' | 638 '-DADDRESS_SANITIZER -DWTF_USE_DYNAMIC_ANNOTATIONS=1 ' |
| 645 '-DWTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1' ) | 639 '-DWTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1' ) |
| 646 command.append('CC=' + env['CC']) | 640 command.append('CC=' + env['CC']) |
| 647 command.append('CXX=' + env['CXX']) | 641 command.append('CXX=' + env['CXX']) |
| 648 command.append('LD=' + env['LD']) | 642 command.append('LD=' + env['LD']) |
| 649 command.append('-r') | 643 command.append('-r') |
| 650 | 644 |
| 651 command.append('-j%d' % jobs) | 645 command.append('-j%d' % jobs) |
| 652 | 646 |
| 653 | 647 |
| 654 def main_make(options, args): | 648 def main_make(options, args): |
| 655 """Interprets options, clobbers object files, and calls make. | 649 """Interprets options, clobbers object files, and calls make. |
| 656 """ | 650 """ |
| 657 | 651 |
| 658 env = EchoDict(os.environ) | 652 env = EchoDict(os.environ) |
| 659 goma_ready = goma_setup(options, env) | 653 goma_ready = goma_setup(options, env) |
| 660 if not goma_ready: | 654 if not goma_ready: |
| 661 assert options.compiler not in ('goma', 'goma-clang') | 655 assert options.compiler not in ('goma', 'goma-clang') |
| 662 assert options.goma_dir is None | 656 assert options.goma_dir is None |
| 663 | 657 |
| 664 options.build_dir = os.path.abspath(options.build_dir) | 658 options.build_dir = os.path.abspath(options.build_dir) |
| 665 src_dir = os.path.join(slave_utils.SlaveBaseDir(options.build_dir), 'build', | |
| 666 'src') | |
| 667 # TODO(mmoss) Temporary hack to ignore the Windows --solution flag that is | 659 # TODO(mmoss) Temporary hack to ignore the Windows --solution flag that is |
| 668 # passed to all builders. This can be taken out once the master scripts are | 660 # passed to all builders. This can be taken out once the master scripts are |
| 669 # updated to only pass platform-appropriate --solution values. | 661 # updated to only pass platform-appropriate --solution values. |
| 670 if options.solution and os.path.splitext(options.solution)[1] != '.Makefile': | 662 if options.solution and os.path.splitext(options.solution)[1] != '.Makefile': |
| 671 options.solution = None | 663 options.solution = None |
| 672 | 664 |
| 673 command = ['make'] | 665 command = ['make'] |
| 674 if options.solution: | 666 if options.solution: |
| 675 command.extend(['-f', options.solution]) | 667 command.extend(['-f', options.solution]) |
| 676 working_dir = options.build_dir | 668 working_dir = options.build_dir |
| 677 else: | 669 else: |
| 678 # If no solution file (i.e. sub-project *.Makefile) is specified, try to | 670 # If no solution file (i.e. sub-project *.Makefile) is specified, try to |
| 679 # build from <build_dir>/Makefile, or if that doesn't exist, from | 671 # build from <build_dir>/Makefile, or if that doesn't exist, from |
| 680 # the top-level Makefile. | 672 # the top-level Makefile. |
| 681 if os.path.isfile(os.path.join(options.build_dir, 'Makefile')): | 673 if os.path.isfile(os.path.join(options.build_dir, 'Makefile')): |
| 682 working_dir = options.build_dir | 674 working_dir = options.build_dir |
| 683 else: | 675 else: |
| 684 working_dir = src_dir | 676 working_dir = options.src_dir |
| 685 | 677 |
| 686 # Lots of test-execution scripts hard-code 'sconsbuild' as the output | 678 # Lots of test-execution scripts hard-code 'sconsbuild' as the output |
| 687 # directory. Accomodate them. | 679 # directory. Accomodate them. |
| 688 # TODO: remove when build_dir is properly parameterized in tests. | 680 # TODO: remove when build_dir is properly parameterized in tests. |
| 689 sconsbuild = os.path.join(working_dir, 'sconsbuild') | 681 sconsbuild = os.path.join(working_dir, 'sconsbuild') |
| 690 if os.path.islink(sconsbuild): | 682 if os.path.islink(sconsbuild): |
| 691 if os.readlink(sconsbuild) != 'out': | 683 if os.readlink(sconsbuild) != 'out': |
| 692 os.remove(sconsbuild) | 684 os.remove(sconsbuild) |
| 693 elif os.path.exists(sconsbuild): | 685 elif os.path.exists(sconsbuild): |
| 694 dead = sconsbuild + '.dead' | 686 dead = sconsbuild + '.dead' |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 706 | 698 |
| 707 # V=1 prints the actual executed command | 699 # V=1 prints the actual executed command |
| 708 if options.verbose: | 700 if options.verbose: |
| 709 command.extend(['V=1']) | 701 command.extend(['V=1']) |
| 710 command.extend(options.build_args + args) | 702 command.extend(options.build_args + args) |
| 711 | 703 |
| 712 # Run the build. | 704 # Run the build. |
| 713 env.print_overrides() | 705 env.print_overrides() |
| 714 result = 0 | 706 result = 0 |
| 715 | 707 |
| 716 def clobber(target): | 708 def clobber(): |
| 717 build_output_dir = os.path.join(working_dir, 'out', target) | 709 print('Removing %s' % options.target_output_dir) |
| 718 print('Removing %s' % build_output_dir) | 710 chromium_utils.RemoveDirectory(options.target_output_dir) |
| 719 chromium_utils.RemoveDirectory(build_output_dir) | |
| 720 | 711 |
| 721 for target in options.target.split(','): | 712 assert ',' not in options.target, ( |
| 722 if options.clobber: | 713 'Used to allow multiple comma-separated targets for make. This should not be' |
| 723 clobber(target) | 714 ' in use any more. Asserting from orbit. It\'s the only way to be sure') |
| 724 | 715 |
| 725 target_command = command + ['BUILDTYPE=' + target] | 716 if options.clobber: |
| 726 this_result = chromium_utils.RunCommand(target_command, env=env) | 717 clobber() |
| 727 if this_result and not options.clobber: | 718 |
| 728 clobber(target) | 719 target_command = command + ['BUILDTYPE=' + options.target] |
| 729 # Keep the first non-zero return code as overall result. | 720 result = chromium_utils.RunCommand(target_command, env=env) |
| 730 if this_result and not result: | 721 if result and not options.clobber: |
| 731 result = this_result | 722 clobber() |
| 732 | 723 |
| 733 goma_teardown(options, env) | 724 goma_teardown(options, env) |
| 734 | 725 |
| 735 return result | 726 return result |
| 736 | 727 |
| 737 | 728 |
| 738 def main_ninja(options, args): | 729 def main_ninja(options, args): |
| 739 """Interprets options, clobbers object files, and calls ninja.""" | 730 """Interprets options, clobbers object files, and calls ninja.""" |
| 740 | 731 |
| 741 # Prepare environment. | 732 # Prepare environment. |
| 742 env = EchoDict(os.environ) | 733 env = EchoDict(os.environ) |
| 743 orig_compiler = options.compiler | 734 orig_compiler = options.compiler |
| 744 goma_ready = goma_setup(options, env) | 735 goma_ready = goma_setup(options, env) |
| 745 if not goma_ready: | 736 if not goma_ready: |
| 746 assert options.compiler not in ('goma', 'goma-clang') | 737 assert options.compiler not in ('goma', 'goma-clang') |
| 747 assert options.goma_dir is None | 738 assert options.goma_dir is None |
| 748 | 739 |
| 749 # ninja is different from all the other build systems in that it requires | 740 # ninja is different from all the other build systems in that it requires |
| 750 # most configuration to be done at gyp time. This is why this function does | 741 # most configuration to be done at gyp time. This is why this function does |
| 751 # less than the other comparable functions in this file. | 742 # less than the other comparable functions in this file. |
| 752 src_dir = os.path.join( | 743 print 'chdir to %s' % options.src_dir |
| 753 slave_utils.SlaveBaseDir(os.path.abspath(options.build_dir)), | 744 os.chdir(options.src_dir) |
| 754 'build', | |
| 755 'src') | |
| 756 print 'chdir to %s' % src_dir | |
| 757 os.chdir(src_dir) | |
| 758 | 745 |
| 759 output_dir = os.path.join('out', options.target) | 746 command = ['ninja', '-C', options.target_output_dir] |
| 760 command = ['ninja', '-C', output_dir] | |
| 761 | 747 |
| 762 if options.clobber: | 748 if options.clobber: |
| 763 print('Removing %s' % output_dir) | 749 print('Removing %s' % options.target_output_dir) |
| 764 # Deleting output_dir would also delete all the .ninja files necessary to | 750 # Deleting output_dir would also delete all the .ninja files necessary to |
| 765 # build. Clobbering should run before runhooks (which creates .ninja files). | 751 # build. Clobbering should run before runhooks (which creates .ninja files). |
| 766 # For now, only delete all non-.ninja files. TODO(thakis): Make "clobber" a | 752 # For now, only delete all non-.ninja files. TODO(thakis): Make "clobber" a |
| 767 # step that runs before "runhooks". Once the master has been restarted, | 753 # step that runs before "runhooks". Once the master has been restarted, |
| 768 # remove all clobber handling from compile.py. | 754 # remove all clobber handling from compile.py. |
| 769 ninja_clobber(output_dir) | 755 ninja_clobber(options.target_output_dir) |
| 770 | 756 |
| 771 if options.verbose: | 757 if options.verbose: |
| 772 command.append('-v') | 758 command.append('-v') |
| 773 command.extend(options.build_args) | 759 command.extend(options.build_args) |
| 774 command.extend(args) | 760 command.extend(args) |
| 775 | 761 |
| 776 if chromium_utils.IsMac() and options.disable_aslr: | 762 if chromium_utils.IsMac() and options.disable_aslr: |
| 777 # Disallow dyld to randomize the load addresses of executables. | 763 # Disallow dyld to randomize the load addresses of executables. |
| 778 # If any of them is compiled with ASan it will hang otherwise. | 764 # If any of them is compiled with ASan it will hang otherwise. |
| 779 env['DYLD_NO_PIE'] = '1' | 765 env['DYLD_NO_PIE'] = '1' |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 792 # under ninja -t msvc. (PATH is just ignored. Note PATH set/used | 778 # under ninja -t msvc. (PATH is just ignored. Note PATH set/used |
| 793 # in compile.py doesn't include MSVC's path). | 779 # in compile.py doesn't include MSVC's path). |
| 794 # Hence, we'll got | 780 # Hence, we'll got |
| 795 # "CreateProcess failed: The system cannot find the file specified." | 781 # "CreateProcess failed: The system cannot find the file specified." |
| 796 # | 782 # |
| 797 # So, rewrite cc, cxx line to "$goma_dir/gomacc cl". | 783 # So, rewrite cc, cxx line to "$goma_dir/gomacc cl". |
| 798 # | 784 # |
| 799 # Note that, on other platform, ninja doesn't use ninja -t msvc | 785 # Note that, on other platform, ninja doesn't use ninja -t msvc |
| 800 # (it just simply run $cc/$cxx), so modifying PATH can work to run | 786 # (it just simply run $cc/$cxx), so modifying PATH can work to run |
| 801 # gomacc without this hack. | 787 # gomacc without this hack. |
| 802 orig_build = open(os.path.join(output_dir, 'build.ninja')) | 788 manifest = os.path.join(options.target_output_dir, 'build.ninja') |
| 803 new_build = open(os.path.join(output_dir, 'build.ninja.goma'), 'w') | 789 orig_build = open(manifest) |
| 790 new_build = open(manifest+'.goma', 'w') | |
|
M-A Ruel
2012/11/06 15:20:01
spacing
iannucci
2012/11/13 20:09:51
Done.
| |
| 804 for line in orig_build: | 791 for line in orig_build: |
| 805 if line.startswith('cc '): | 792 if line.startswith('cc '): |
| 806 new_build.write('cc = %s cl\n' % ( | 793 new_build.write('cc = %s cl\n' % ( |
| 807 os.path.join(options.goma_dir, 'gomacc.exe'))) | 794 os.path.join(options.goma_dir, 'gomacc.exe'))) |
| 808 elif line.startswith('cxx '): | 795 elif line.startswith('cxx '): |
| 809 new_build.write('cxx = %s cl\n' % ( | 796 new_build.write('cxx = %s cl\n' % ( |
| 810 os.path.join(options.goma_dir, 'gomacc.exe'))) | 797 os.path.join(options.goma_dir, 'gomacc.exe'))) |
| 811 else: | 798 else: |
| 812 new_build.write(line) | 799 new_build.write(line) |
| 813 orig_build.close() | 800 orig_build.close() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 | 839 |
| 853 goma_teardown(options, env) | 840 goma_teardown(options, env) |
| 854 return result | 841 return result |
| 855 | 842 |
| 856 | 843 |
| 857 def main_scons(options, args): | 844 def main_scons(options, args): |
| 858 """Interprets options, clobbers object files, and calls scons. | 845 """Interprets options, clobbers object files, and calls scons. |
| 859 """ | 846 """ |
| 860 options.build_dir = os.path.abspath(options.build_dir) | 847 options.build_dir = os.path.abspath(options.build_dir) |
| 861 if options.clobber: | 848 if options.clobber: |
| 862 build_output_dir = os.path.join(os.path.dirname(options.build_dir), | 849 print('Removing %s' % options.target_output_dir) |
| 863 'sconsbuild', options.target) | 850 chromium_utils.RemoveDirectory(options.target_output_dir) |
| 864 print('Removing %s' % build_output_dir) | |
| 865 chromium_utils.RemoveDirectory(build_output_dir) | |
| 866 | 851 |
| 867 os.chdir(options.build_dir) | 852 os.chdir(options.build_dir) |
| 868 | 853 |
| 869 if sys.platform == 'win32': | 854 if sys.platform == 'win32': |
| 870 command = ['hammer.bat'] | 855 command = ['hammer.bat'] |
| 871 else: | 856 else: |
| 872 command = ['hammer'] | 857 command = ['hammer'] |
| 873 | 858 |
| 874 env = EchoDict(os.environ) | 859 env = EchoDict(os.environ) |
| 875 if sys.platform == 'linux2': | 860 if sys.platform == 'linux2': |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 else: | 929 else: |
| 945 tool = devenv | 930 tool = devenv |
| 946 if options.arch == 'x64': | 931 if options.arch == 'x64': |
| 947 tool_options = ['/Build', '%s|x64' % options.target] | 932 tool_options = ['/Build', '%s|x64' % options.target] |
| 948 else: | 933 else: |
| 949 tool_options = ['/Build', options.target] | 934 tool_options = ['/Build', options.target] |
| 950 if options.project: | 935 if options.project: |
| 951 tool_options.extend(['/Project', options.project]) | 936 tool_options.extend(['/Project', options.project]) |
| 952 | 937 |
| 953 options.build_dir = os.path.abspath(options.build_dir) | 938 options.build_dir = os.path.abspath(options.build_dir) |
| 954 build_output_dir = os.path.join(options.build_dir, options.target) | |
| 955 | 939 |
| 956 def clobber(): | 940 def clobber(): |
| 957 print('Removing %s' % build_output_dir) | 941 print('Removing %s' % options.target_output_dir) |
| 958 chromium_utils.RemoveDirectory(build_output_dir) | 942 chromium_utils.RemoveDirectory(options.target_output_dir) |
| 959 | 943 |
| 960 if options.clobber: | 944 if options.clobber: |
| 961 clobber() | 945 clobber() |
| 962 else: | 946 else: |
| 963 # Remove the log file so it doesn't grow without limit, | 947 # Remove the log file so it doesn't grow without limit, |
| 964 chromium_utils.RemoveFile(build_output_dir, 'debug.log') | 948 chromium_utils.RemoveFile(options.target_output_dir, 'debug.log') |
| 965 # Remove the chrome.dll version resource so it picks up the new svn | 949 # Remove the chrome.dll version resource so it picks up the new svn |
| 966 # revision, unless user explicitly asked not to remove it. See | 950 # revision, unless user explicitly asked not to remove it. See |
| 967 # Bug 1064677 for more details. | 951 # Bug 1064677 for more details. |
| 968 if not options.keep_version_file: | 952 if not options.keep_version_file: |
| 969 chromium_utils.RemoveFile(build_output_dir, 'obj', 'chrome_dll', | 953 chromium_utils.RemoveFile(options.target_output_dir, 'obj', 'chrome_dll', |
| 970 'chrome_dll_version.rc') | 954 'chrome_dll_version.rc') |
| 971 | 955 |
| 972 env = EchoDict(os.environ) | 956 env = EchoDict(os.environ) |
| 973 | 957 |
| 974 # no goma support yet for this build tool. | 958 # no goma support yet for this build tool. |
| 975 assert options.compiler != 'goma' | 959 assert options.compiler != 'goma' |
| 976 | 960 |
| 977 if options.mode == 'google_chrome' or options.mode == 'official': | 961 if options.mode == 'google_chrome' or options.mode == 'official': |
| 978 env['CHROMIUM_BUILD'] = '_google_chrome' | 962 env['CHROMIUM_BUILD'] = '_google_chrome' |
| 979 | 963 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1060 if known_line in line: | 1044 if known_line in line: |
| 1061 errors.append(line) | 1045 errors.append(line) |
| 1062 break | 1046 break |
| 1063 | 1047 |
| 1064 env.print_overrides() | 1048 env.print_overrides() |
| 1065 result = chromium_utils.RunCommand( | 1049 result = chromium_utils.RunCommand( |
| 1066 command, parser_func=scan, env=env, universal_newlines=True) | 1050 command, parser_func=scan, env=env, universal_newlines=True) |
| 1067 if errors: | 1051 if errors: |
| 1068 print('\n\nRetrying a clobber build because of:') | 1052 print('\n\nRetrying a clobber build because of:') |
| 1069 print('\n'.join((' ' + l for l in errors))) | 1053 print('\n'.join((' ' + l for l in errors))) |
| 1070 print('Removing %s' % build_output_dir) | 1054 print('Removing %s' % options.target_output_dir) |
| 1071 for _ in range(3): | 1055 for _ in range(3): |
| 1072 try: | 1056 try: |
| 1073 chromium_utils.RemoveDirectory(build_output_dir) | 1057 chromium_utils.RemoveDirectory(options.target_output_dir) |
| 1074 break | 1058 break |
| 1075 except OSError, e: | 1059 except OSError, e: |
| 1076 print(e) | 1060 print(e) |
| 1077 print('\nSleeping 15 seconds. Lovely windows file locks.') | 1061 print('\nSleeping 15 seconds. Lovely windows file locks.') |
| 1078 time.sleep(15) | 1062 time.sleep(15) |
| 1079 else: | 1063 else: |
| 1080 print('Failed to delete a file 3 times in a row, aborting.') | 1064 print('Failed to delete a file 3 times in a row, aborting.') |
| 1081 return 1 | 1065 return 1 |
| 1082 result = chromium_utils.RunCommand(command, env=env) | 1066 result = chromium_utils.RunCommand(command, env=env) |
| 1083 | 1067 |
| 1084 # TODO(maruel): As soon as the try server is restarted, replace with: | 1068 # TODO(maruel): As soon as the try server is restarted, replace with: |
| 1085 # if result and not options.clobber and options.clobber_post_fail: | 1069 # if result and not options.clobber and options.clobber_post_fail: |
| 1086 if result and not options.clobber: | 1070 if result and not options.clobber: |
| 1087 clobber() | 1071 clobber() |
| 1088 | 1072 |
| 1089 return result | 1073 return result |
| 1090 | 1074 |
|
M-A Ruel
2012/11/06 15:20:01
2 lines between file-level symbols
iannucci
2012/11/13 20:09:51
Done.
| |
| 1075 def landmines_triggered(build_dir): | |
| 1076 trigger_file = os.path.join(build_dir, '.landmines_triggered') | |
| 1077 if os.path.exists(trigger_file): | |
| 1078 print "Setting clobber due to triggered landmines:" | |
|
M-A Ruel
2012/11/06 15:20:01
The file use single-quotes
iannucci
2012/11/13 20:09:51
Done.
| |
| 1079 with open(trigger_file) as f: | |
| 1080 sys.stdout.writelines(f.readlines()) | |
|
M-A Ruel
2012/11/06 15:20:01
You are doing that because you want to strip CR, r
iannucci
2012/11/13 20:09:51
Doing this to print the file as-is (and it's more
| |
| 1081 return True | |
| 1082 return False | |
| 1083 | |
| 1084 def get_target_build_dir(build_tool, src_dir, target, is_iphone=False): | |
|
M-A Ruel
2012/11/06 15:20:01
"""Keep in sync with foo_bar.py"""
iannucci
2012/11/13 20:09:51
Done. I also updated the other function to refer t
| |
| 1085 ret = None | |
| 1086 if build_tool == 'xcode': | |
| 1087 ret = os.path.join(src_dir, 'xcodebuild', | |
| 1088 target + ('-iphoneos' if is_iphone else '')) | |
| 1089 elif build_tool == 'make': | |
| 1090 ret = os.path.join(src_dir, 'out', target) | |
| 1091 elif build_tool == 'ninja': | |
| 1092 ret = os.path.join(src_dir, 'out', target) | |
| 1093 elif build_tool == 'msvs': | |
| 1094 ret = os.path.join(src_dir, 'build', target) | |
| 1095 elif build_tool == 'scons': | |
| 1096 ret = os.path.join(src_dir, 'sconsbuild', target) | |
| 1097 else: | |
| 1098 raise NotImplementedError() | |
| 1099 return os.path.abspath(ret) | |
| 1100 | |
| 1091 | 1101 |
| 1092 def real_main(): | 1102 def real_main(): |
| 1093 option_parser = optparse.OptionParser() | 1103 option_parser = optparse.OptionParser() |
| 1094 option_parser.add_option('', '--clobber', action='store_true', default=False, | 1104 option_parser.add_option('', '--clobber', action='store_true', default=False, |
| 1095 help='delete the output directory before compiling') | 1105 help='delete the output directory before compiling') |
| 1096 option_parser.add_option('', '--clobber-post-fail', action='store_true', | 1106 option_parser.add_option('', '--clobber-post-fail', action='store_true', |
| 1097 default=False, | 1107 default=False, |
| 1098 help='delete the output directory after compiling ' | 1108 help='delete the output directory after compiling ' |
| 1099 'only if it failed. Do not affect ninja.') | 1109 'only if it failed. Do not affect ninja.') |
| 1100 option_parser.add_option('', '--keep-version-file', action='store_true', | 1110 option_parser.add_option('', '--keep-version-file', action='store_true', |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1140 option_parser.add_option('', '--goma-dir', | 1150 option_parser.add_option('', '--goma-dir', |
| 1141 default=os.path.join(BUILD_DIR, 'goma'), | 1151 default=os.path.join(BUILD_DIR, 'goma'), |
| 1142 help='specify goma directory') | 1152 help='specify goma directory') |
| 1143 option_parser.add_option('--verbose', action='store_true') | 1153 option_parser.add_option('--verbose', action='store_true') |
| 1144 | 1154 |
| 1145 options, args = option_parser.parse_args() | 1155 options, args = option_parser.parse_args() |
| 1146 | 1156 |
| 1147 if options.build_tool is None: | 1157 if options.build_tool is None: |
| 1148 if chromium_utils.IsWindows(): | 1158 if chromium_utils.IsWindows(): |
| 1149 main = main_win | 1159 main = main_win |
| 1160 options.build_tool = 'msvs' | |
| 1150 elif chromium_utils.IsMac(): | 1161 elif chromium_utils.IsMac(): |
| 1151 main = main_xcode | 1162 main = main_xcode |
| 1163 options.build_tool = 'xcode' | |
| 1152 elif chromium_utils.IsLinux(): | 1164 elif chromium_utils.IsLinux(): |
| 1153 main = main_make | 1165 main = main_make |
| 1166 options.build_tool = 'make' | |
| 1154 else: | 1167 else: |
| 1155 print('Please specify --build-tool.') | 1168 print('Please specify --build-tool.') |
| 1156 return 1 | 1169 return 1 |
| 1157 else: | 1170 else: |
| 1158 build_tool_map = { | 1171 build_tool_map = { |
| 1159 'ib' : main_win, | 1172 'ib' : main_win, |
| 1160 'vs' : main_win, | 1173 'vs' : main_win, |
| 1161 'make' : main_make, | 1174 'make' : main_make, |
| 1162 'ninja' : main_ninja, | 1175 'ninja' : main_ninja, |
| 1163 'scons' : main_scons, | 1176 'scons' : main_scons, |
| 1164 'xcode' : main_xcode, | 1177 'xcode' : main_xcode, |
| 1165 } | 1178 } |
| 1166 main = build_tool_map.get(options.build_tool) | 1179 main = build_tool_map.get(options.build_tool) |
| 1167 if not main: | 1180 if not main: |
| 1168 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) | 1181 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) |
| 1169 return 2 | 1182 return 2 |
| 1170 | 1183 |
|
M-A Ruel
2012/11/06 15:20:01
options.build_dir = os.path.abspath(options.build_
iannucci
2012/11/13 20:09:51
Sure, why not! :D
Would be useful for optparse to
| |
| 1184 options.src_dir = os.path.join(slave_utils.SlaveBaseDir( | |
| 1185 os.path.abspath(options.build_dir)), 'build', 'src') | |
| 1186 options.target_output_dir = get_target_build_dir(options.build_tool, | |
|
M-A Ruel
2012/11/06 15:20:01
This alignment hurts. Please everything at +4 or a
iannucci
2012/11/13 20:09:51
Done.
| |
| 1187 options.src_dir, options.target, 'iphoneos' in args) | |
| 1188 options.clobber = (options.clobber or | |
| 1189 landmines_triggered(options.target_output_dir)) | |
| 1190 | |
| 1171 return main(options, args) | 1191 return main(options, args) |
| 1172 | 1192 |
| 1173 | 1193 |
| 1174 if '__main__' == __name__: | 1194 if '__main__' == __name__: |
| 1175 sys.exit(real_main()) | 1195 sys.exit(real_main()) |
| OLD | NEW |