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

Side by Side Diff: build/scripts/slave/compile.py

Issue 367133002: Remove PATH tweaking for goma and clang from compile.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 6 years, 5 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/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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 env['CXX'] = ccache + crosstool + '-g++' 567 env['CXX'] = ccache + crosstool + '-g++'
568 env['LD'] = crosstool + '-ld' 568 env['LD'] = crosstool + '-ld'
569 env['RANLIB'] = crosstool + '-ranlib' 569 env['RANLIB'] = crosstool + '-ranlib'
570 command.append('-j%d' % jobs) 570 command.append('-j%d' % jobs)
571 # Don't use build-in rules. 571 # Don't use build-in rules.
572 command.append('-r') 572 command.append('-r')
573 return 573 return
574 574
575 if compiler in ('goma', 'goma-clang', 'jsonclang'): 575 if compiler in ('goma', 'goma-clang', 'jsonclang'):
576 print 'using', compiler 576 print 'using', compiler
577 if compiler == 'goma':
578 assert options.goma_dir
579 env['CC'] = 'gcc'
580 env['CXX'] = 'g++'
581 env['PATH'] = ':'.join([options.goma_dir, env['PATH']])
582 elif compiler == 'goma-clang':
583 assert options.goma_dir
584 env['CC'] = 'clang'
585 env['CXX'] = 'clang++'
586 clang_dir = os.path.join(options.src_dir,
587 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
588 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']])
589 else: # jsonclang
590 env['CC'] = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'jsonclang')
591 env['CXX'] = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'jsonclang++')
592 command.append('-r')
593 command.append('-k')
594 # 'jsonclang' assumes the clang binary is in the path.
595 clang_dir = os.path.join(options.src_dir,
596 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
597 if options.goma_dir:
598 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']])
599 else:
600 env['PATH'] = ':'.join([clang_dir, env['PATH']])
601
602 command.append('CC.host=' + env['CC'])
603 command.append('CXX.host=' + env['CXX'])
604
605 goma_jobs = 50 577 goma_jobs = 50
606 if jobs < goma_jobs: 578 if jobs < goma_jobs:
607 jobs = goma_jobs 579 jobs = goma_jobs
608 command.append('-j%d' % jobs) 580 command.append('-j%d' % jobs)
609 return 581 return
610 582
611 if compiler == 'clang': 583 if compiler == 'clang':
612 clang_dir = os.path.join(options.src_dir,
Michael Achenbach 2014/07/03 07:25:29 Now that it landed, I see the problem. The v8 stan
613 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
614 env['CC'] = os.path.join(clang_dir, 'clang')
615 env['CXX'] = os.path.join(clang_dir, 'clang++')
616 command.append('CC.host=' + env['CC'])
617 command.append('CXX.host=' + env['CXX'])
618 command.append('-r') 584 command.append('-r')
619 585
620 command.append('-j%d' % jobs) 586 command.append('-j%d' % jobs)
621 587
622 588
623 def main_make(options, args): 589 def main_make(options, args):
624 """Interprets options, clobbers object files, and calls make. 590 """Interprets options, clobbers object files, and calls make.
625 """ 591 """
626 592
627 env = EchoDict(os.environ) 593 env = EchoDict(os.environ)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 goma_teardown(options, env) 684 goma_teardown(options, env)
719 685
720 return result 686 return result
721 687
722 def main_ninja(options, args): 688 def main_ninja(options, args):
723 """Interprets options, clobbers object files, and calls ninja.""" 689 """Interprets options, clobbers object files, and calls ninja."""
724 690
725 # Prepare environment. 691 # Prepare environment.
726 env = EchoDict(os.environ) 692 env = EchoDict(os.environ)
727 env.setdefault('NINJA_STATUS', '[%s/%t | %e] ') 693 env.setdefault('NINJA_STATUS', '[%s/%t | %e] ')
728 orig_compiler = options.compiler
729 goma_ready = goma_setup(options, env) 694 goma_ready = goma_setup(options, env)
730 try: 695 try:
731 if not goma_ready: 696 if not goma_ready:
732 assert options.compiler not in ('goma', 'goma-clang') 697 assert options.compiler not in ('goma', 'goma-clang')
733 assert options.goma_dir is None 698 assert options.goma_dir is None
734 699
735 # ninja is different from all the other build systems in that it requires 700 # ninja is different from all the other build systems in that it requires
736 # most configuration to be done at gyp time. This is why this function does 701 # most configuration to be done at gyp time. This is why this function does
737 # less than the other comparable functions in this file. 702 # less than the other comparable functions in this file.
738 print 'chdir to %s' % options.src_dir 703 print 'chdir to %s' % options.src_dir
(...skipping 17 matching lines...) Expand all
756 command.extend(args) 721 command.extend(args)
757 722
758 maybe_set_official_build_envvars(options, env) 723 maybe_set_official_build_envvars(options, env)
759 724
760 if options.compiler: 725 if options.compiler:
761 print 'using', options.compiler 726 print 'using', options.compiler
762 727
763 if options.compiler in ('goma', 'goma-clang', 'jsonclang'): 728 if options.compiler in ('goma', 'goma-clang', 'jsonclang'):
764 assert options.goma_dir 729 assert options.goma_dir
765 if chromium_utils.IsWindows(): 730 if chromium_utils.IsWindows():
766 # rewrite cc, cxx line in output_dir\build.ninja. 731 assert options.compiler != 'jsonclang', ('jsonclang does not use '
767 # in winja, ninja -t msvc is used to run $cc/$cxx to collect 732 'CC_wrapper, so it cannot easily work on Windows.')
768 # dependency with "cl /showIncludes" and generates dependency info.
769 # ninja -t msvc uses environment in output_dir\environment.*,
770 # which is generated at gyp time (Note: gyp detect MSVC's path and set
771 # it to PATH. This PATH doesn't include goma_dir.), and ignores PATH
772 # to run $cc/$cxx at run time.
773 # So modifying PATH in compile.py doesn't afffect to run $cc/$cxx
774 # under ninja -t msvc. (PATH is just ignored. Note PATH set/used
775 # in compile.py doesn't include MSVC's path).
776 # Hence, we'll got
777 # "CreateProcess failed: The system cannot find the file specified."
778 #
779 # So, rewrite cc, cxx line to "$goma_dir/gomacc cl".
780 #
781 # Note that, on other platform, ninja doesn't use ninja -t msvc
782 # (it just simply run $cc/$cxx), so modifying PATH can work to run
783 # gomacc without this hack.
784 #
785 # Another option is to use CC_wrapper, CXX_wrapper environement
786 # variables at gyp time (and this is typical usage for chromium
787 # developers), but it would make it harder to fallback no-goma when
788 # goma is not available.
789 # TODO: Set CC / CXX at gyp time instead. This is a horrible hack.
790 manifest = os.path.join(options.target_output_dir, 'build.ninja')
791 orig_manifest = manifest + '.orig'
792 if os.path.exists(orig_manifest):
793 os.remove(orig_manifest)
794 os.rename(manifest, orig_manifest)
795 cc_line_pattern = re.compile(
796 r'(cc|cxx|cc_host|cxx_host|cl_x86|cl_x64) = (.*)')
797 gomacc = os.path.join(options.goma_dir, 'gomacc.exe')
798 modified_lines = []
799 with open(orig_manifest) as orig_build:
800 with open(manifest, 'w') as new_build:
801 for line in orig_build:
802 m = cc_line_pattern.match(line)
803 if m:
804 cc_type = m.group(1)
805 cc_cmd = m.group(2).strip()
806 # use gomacc if cc_cmd is simple command (e.g. cl.exe), or
807 # quoted full path (e.g. "c:\Program Files\...").
808 if not ' ' in cc_cmd or re.match('^"[^"]+"$', cc_cmd):
809 orig_line = line
810 line = '%s = %s %s\n' % (cc_type, gomacc, cc_cmd)
811 modified_lines.append((orig_line, line))
812 new_build.write(line)
813 if modified_lines:
814 print 'build.ninja modified in compile.py for goma:\n'
815 for (orig_line, line) in modified_lines:
816 sys.stdout.write(' ' + orig_line)
817 sys.stdout.write(' -> ' + line)
818 733
819 # CC and CXX are set at gyp time for ninja. PATH still needs to be 734 # Adjust the path for jsonclang, since it doesn't use CC_wrapper. Windows
820 # adjusted. 735 # uses -t msvc and hardcodes the compiler path in build.ninja, so this
821 if options.compiler == 'goma': 736 # doesn't have an effect there.
822 env['PATH'] = os.pathsep.join([options.goma_dir, env['PATH']]) 737 if options.compiler == 'jsonclang':
823 elif options.compiler == 'goma-clang':
824 clang_dir = os.path.abspath(os.path.join(
825 'third_party', 'llvm-build', 'Release+Asserts', 'bin'))
826 env['PATH'] = os.pathsep.join(
827 [options.goma_dir, clang_dir, env['PATH']])
828 elif options.compiler == 'jsonclang':
829 jsonclang_dir = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium') 738 jsonclang_dir = os.path.join(SLAVE_SCRIPTS_DIR, 'chromium')
830 clang_dir = os.path.join(options.src_dir, 739 clang_dir = os.path.join(options.src_dir,
831 'third_party', 'llvm-build', 'Release+Asserts', 'bin') 740 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
832 if options.goma_dir: 741 if options.goma_dir:
833 env['PATH'] = os.pathsep.join( 742 env['PATH'] = os.pathsep.join(
834 [jsonclang_dir, options.goma_dir, clang_dir, env['PATH']]) 743 [jsonclang_dir, options.goma_dir, clang_dir, env['PATH']])
835 else: 744 else:
836 env['PATH'] = os.pathsep.join([jsonclang_dir, clang_dir, env['PATH']]) 745 env['PATH'] = os.pathsep.join([jsonclang_dir, clang_dir, env['PATH']])
837 746
838 def determine_goma_jobs(): 747 def determine_goma_jobs():
(...skipping 24 matching lines...) Expand all
863 goma_jobs = determine_goma_jobs() 772 goma_jobs = determine_goma_jobs()
864 command.append('-j%d' % goma_jobs) 773 command.append('-j%d' % goma_jobs)
865 774
866 if chromium_utils.IsMac(): 775 if chromium_utils.IsMac():
867 # Work around for crbug.com/347918 776 # Work around for crbug.com/347918
868 env['GOMA_HERMETIC'] = 'fallback' 777 env['GOMA_HERMETIC'] = 'fallback'
869 if options.clobber: 778 if options.clobber:
870 # Enabling this while attempting to solve crbug.com/257467 779 # Enabling this while attempting to solve crbug.com/257467
871 env['GOMA_USE_LOCAL'] = '1' 780 env['GOMA_USE_LOCAL'] = '1'
872 781
873 if orig_compiler == 'goma-clang' and options.compiler == 'clang':
874 # goma setup failed, fallback to local clang.
875 # Note that ninja.build was generated for goma, so need to set PATH
876 # to clang dir.
877 # If orig_compiler is not goma, gyp set this path in ninja.build.
878 print 'using', options.compiler
879 clang_dir = os.path.abspath(os.path.join(
880 'third_party', 'llvm-build', 'Release+Asserts', 'bin'))
881 env['PATH'] = os.pathsep.join([clang_dir, env['PATH']])
882
883 # Run the build. 782 # Run the build.
884 env.print_overrides() 783 env.print_overrides()
885 # TODO(maruel): Remove the shell argument as soon as ninja.exe is in PATH. 784 # TODO(maruel): Remove the shell argument as soon as ninja.exe is in PATH.
886 # At the moment of writing, ninja.bat in depot_tools wraps 785 # At the moment of writing, ninja.bat in depot_tools wraps
887 # third_party\ninja.exe, which requires shell=True so it is found correctly. 786 # third_party\ninja.exe, which requires shell=True so it is found correctly.
888 return chromium_utils.RunCommand( 787 return chromium_utils.RunCommand(
889 command, env=env, shell=sys.platform=='win32') 788 command, env=env, shell=sys.platform=='win32')
890 finally: 789 finally:
891 goma_teardown(options, env) 790 goma_teardown(options, env)
892 791
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 options.target_output_dir = get_target_build_dir(options.build_tool, 1128 options.target_output_dir = get_target_build_dir(options.build_tool,
1230 options.src_dir, options.target, 'iphoneos' in args) 1129 options.src_dir, options.target, 'iphoneos' in args)
1231 options.clobber = (options.clobber or 1130 options.clobber = (options.clobber or
1232 landmines_triggered(options.target_output_dir)) 1131 landmines_triggered(options.target_output_dir))
1233 1132
1234 return main(options, args) 1133 return main(options, args)
1235 1134
1236 1135
1237 if '__main__' == __name__: 1136 if '__main__' == __name__:
1238 sys.exit(real_main()) 1137 sys.exit(real_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