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

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

Issue 26672003: Remove references to sconsbuild. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 2 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 | « build/scripts/slave/build_directory.py ('k') | build/scripts/slave/runtest.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 # 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 filter_obj=xcodebuild_filter) 499 filter_obj=xcodebuild_filter)
500 500
501 goma_teardown(options, env) 501 goma_teardown(options, env)
502 502
503 return result 503 return result
504 504
505 505
506 def common_make_settings( 506 def common_make_settings(
507 command, options, env, crosstool=None, compiler=None): 507 command, options, env, crosstool=None, compiler=None):
508 """ 508 """
509 Sets desirable environment variables and command-line options 509 Sets desirable environment variables and command-line options that are used
510 that are common to the Make and SCons builds. Used on Linux 510 in the Make build.
511 and for the mac make build.
512 """ 511 """
513 assert compiler in (None, 'clang', 'goma', 'goma-clang', 'jsonclang') 512 assert compiler in (None, 'clang', 'goma', 'goma-clang', 'jsonclang')
514 maybe_set_official_build_envvars(options, env) 513 maybe_set_official_build_envvars(options, env)
515 514
516 # Don't stop at the first error. 515 # Don't stop at the first error.
517 command.append('-k') 516 command.append('-k')
518 517
519 # Set jobs parallelization based on number of cores. 518 # Set jobs parallelization based on number of cores.
520 jobs = os.sysconf('SC_NPROCESSORS_ONLN') 519 jobs = os.sysconf('SC_NPROCESSORS_ONLN')
521 520
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 clang_dir = os.path.join(options.src_dir, 569 clang_dir = os.path.join(options.src_dir,
571 'third_party', 'llvm-build', 'Release+Asserts', 'bin') 570 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
572 if options.goma_dir: 571 if options.goma_dir:
573 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']]) 572 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']])
574 else: 573 else:
575 env['PATH'] = ':'.join([clang_dir, env['PATH']]) 574 env['PATH'] = ':'.join([clang_dir, env['PATH']])
576 575
577 command.append('CC.host=' + env['CC']) 576 command.append('CC.host=' + env['CC'])
578 command.append('CXX.host=' + env['CXX']) 577 command.append('CXX.host=' + env['CXX'])
579 578
580 if chromium_utils.IsMac(): 579 goma_jobs = 50
581 # The default process limit on 10.6 is 266 (`sysctl kern.maxprocperuid`),
Lei Zhang 2013/10/09 18:56:37 This seems useful to know. Keep it?
Nico 2013/10/09 19:21:35 This is only true on mac, and this function doesn'
Lei Zhang 2013/10/09 19:33:40 Ah, right.
582 # and about 100 processes are used by the system. The webkit bindings
583 # generation scripts open a preprocessor child process, so building at
584 # -j100 runs into the process limit. For now, just build with -j50.
585 goma_jobs = 50
586 if options.clobber:
587 # Disable compiles on local machine. When the goma server-side object
588 # file cache is warm, this can speed up clobber builds by up to 30%.
589 env['GOMA_USE_LOCAL'] = '0'
590 # Temproary hack to try failing fast when the server looks unhealthy.
591 # 30 seconds is chosen because a local compile is almost certainly
592 # faster.
593 # crbug.com/257467
594 env['GOMA_RETRY'] = '0'
595 env['GOMA_COMPILER_PROXY_RPC_TIMEOUT_SECS'] = '30'
596 else:
597 goma_jobs = 50
598 if jobs < goma_jobs: 580 if jobs < goma_jobs:
599 jobs = goma_jobs 581 jobs = goma_jobs
600 command.append('-j%d' % jobs) 582 command.append('-j%d' % jobs)
601 return 583 return
602 584
603 if compiler == 'clang': 585 if compiler == 'clang':
604 clang_dir = os.path.join(options.src_dir, 586 clang_dir = os.path.join(options.src_dir,
605 'third_party', 'llvm-build', 'Release+Asserts', 'bin') 587 'third_party', 'llvm-build', 'Release+Asserts', 'bin')
606 env['CC'] = os.path.join(clang_dir, 'clang') 588 env['CC'] = os.path.join(clang_dir, 'clang')
607 env['CXX'] = os.path.join(clang_dir, 'clang++') 589 env['CXX'] = os.path.join(clang_dir, 'clang++')
(...skipping 27 matching lines...) Expand all
635 working_dir = options.build_dir 617 working_dir = options.build_dir
636 else: 618 else:
637 # If no solution file (i.e. sub-project *.Makefile) is specified, try to 619 # If no solution file (i.e. sub-project *.Makefile) is specified, try to
638 # build from <build_dir>/Makefile, or if that doesn't exist, from 620 # build from <build_dir>/Makefile, or if that doesn't exist, from
639 # the top-level Makefile. 621 # the top-level Makefile.
640 if os.path.isfile(os.path.join(options.build_dir, 'Makefile')): 622 if os.path.isfile(os.path.join(options.build_dir, 'Makefile')):
641 working_dir = options.build_dir 623 working_dir = options.build_dir
642 else: 624 else:
643 working_dir = options.src_dir 625 working_dir = options.src_dir
644 626
645 # Lots of test-execution scripts hard-code 'sconsbuild' as the output
646 # directory. Accomodate them.
647 # TODO: remove when build_dir is properly parameterized in tests.
648 sconsbuild = os.path.join(working_dir, 'sconsbuild')
649 if os.path.islink(sconsbuild):
650 if os.readlink(sconsbuild) != 'out':
651 os.remove(sconsbuild)
652 elif os.path.exists(sconsbuild):
653 dead = sconsbuild + '.dead'
654 if os.path.isdir(dead):
655 shutil.rmtree(dead)
656 elif os.path.isfile(dead):
657 os.remove(dead)
658 os.rename(sconsbuild, sconsbuild+'.dead')
659 if not os.path.lexists(sconsbuild):
660 os.symlink('out', sconsbuild)
661
662 os.chdir(working_dir) 627 os.chdir(working_dir)
663 common_make_settings(command, options, env, options.crosstool, 628 common_make_settings(command, options, env, options.crosstool,
664 options.compiler) 629 options.compiler)
665 630
666 # V=1 prints the actual executed command 631 # V=1 prints the actual executed command
667 if options.verbose: 632 if options.verbose:
668 command.extend(['V=1']) 633 command.extend(['V=1'])
669 command.extend(options.build_args + args) 634 command.extend(options.build_args + args)
670 635
671 # Run the build. 636 # Run the build.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 # TODO(maruel): Remove the shell argument as soon as ninja.exe is in PATH. 843 # TODO(maruel): Remove the shell argument as soon as ninja.exe is in PATH.
879 # At the moment of writing, ninja.bat in depot_tools wraps 844 # At the moment of writing, ninja.bat in depot_tools wraps
880 # third_party\ninja.exe, which requires shell=True so it is found correctly. 845 # third_party\ninja.exe, which requires shell=True so it is found correctly.
881 result = chromium_utils.RunCommand( 846 result = chromium_utils.RunCommand(
882 command, env=env, shell=sys.platform=='win32') 847 command, env=env, shell=sys.platform=='win32')
883 848
884 goma_teardown(options, env) 849 goma_teardown(options, env)
885 return result 850 return result
886 851
887 852
888 def main_scons(options, args):
889 """Interprets options, clobbers object files, and calls scons.
890 """
891 options.build_dir = os.path.abspath(options.build_dir)
892 if options.clobber:
893 print('Removing %s' % options.target_output_dir)
894 chromium_utils.RemoveDirectory(options.target_output_dir)
895
896 os.chdir(options.build_dir)
897
898 if sys.platform == 'win32':
899 command = ['hammer.bat']
900 else:
901 command = ['hammer']
902
903 env = EchoDict(os.environ)
904 if sys.platform == 'linux2':
905 common_make_settings(command, options, env)
906 else:
907 command.extend(['-k'])
908
909 command.extend([
910 # Force scons to always check for dependency changes.
911 '--implicit-deps-changed',
912 '--mode=' + options.target,
913 ])
914
915 # Here's what you can uncomment if you need to see more info
916 # about what the build is doing on a slave:
917 #
918 # VERBOSE=1 (a setting in our local SCons config) replaces
919 # the "Compiling ..." and "Linking ..." lines with the
920 # actual executed command line(s)
921 #
922 # --debug=explain (a SCons option) will tell you why SCons
923 # is deciding to rebuild thing (the target doesn't exist,
924 # which .h file(s) changed, etc.)
925 #
926 #command.extend(['--debug=explain', 'VERBOSE=1'])
927 command.extend(options.build_args + args)
928 env.print_overrides()
929 return chromium_utils.RunCommand(command, env=env)
930
931
932 def main_win(options, args): 853 def main_win(options, args):
933 """Interprets options, clobbers object files, and calls the build tool. 854 """Interprets options, clobbers object files, and calls the build tool.
934 """ 855 """
935 # Prefer the version specified in the .sln. When devenv.com is used at the 856 # Prefer the version specified in the .sln. When devenv.com is used at the
936 # command line to start a build, it doesn't accept sln file from a different 857 # command line to start a build, it doesn't accept sln file from a different
937 # version. 858 # version.
938 if not options.msvs_version: 859 if not options.msvs_version:
939 sln = open(os.path.join(options.build_dir, options.solution), 'rU') 860 sln = open(os.path.join(options.build_dir, options.solution), 'rU')
940 header = sln.readline().strip() 861 header = sln.readline().strip()
941 sln.close() 862 sln.close()
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 ret = None 1047 ret = None
1127 if build_tool == 'xcode': 1048 if build_tool == 'xcode':
1128 ret = os.path.join(src_dir, 'xcodebuild', 1049 ret = os.path.join(src_dir, 'xcodebuild',
1129 target + ('-iphoneos' if is_iphone else '')) 1050 target + ('-iphoneos' if is_iphone else ''))
1130 elif build_tool in ['make', 'ninja']: 1051 elif build_tool in ['make', 'ninja']:
1131 ret = os.path.join(src_dir, 'out', target) 1052 ret = os.path.join(src_dir, 'out', target)
1132 elif build_tool == 'make-android': 1053 elif build_tool == 'make-android':
1133 ret = os.path.join(src_dir, 'out') 1054 ret = os.path.join(src_dir, 'out')
1134 elif build_tool in ['msvs', 'vs', 'ib']: 1055 elif build_tool in ['msvs', 'vs', 'ib']:
1135 ret = os.path.join(src_dir, 'build', target) 1056 ret = os.path.join(src_dir, 'build', target)
1136 elif build_tool == 'scons':
1137 ret = os.path.join(src_dir, 'sconsbuild', target)
1138 else: 1057 else:
1139 raise NotImplementedError() 1058 raise NotImplementedError()
1140 return os.path.abspath(ret) 1059 return os.path.abspath(ret)
1141 1060
1142 1061
1143 def real_main(): 1062 def real_main():
1144 option_parser = optparse.OptionParser() 1063 option_parser = optparse.OptionParser()
1145 option_parser.add_option('', '--clobber', action='store_true', default=False, 1064 option_parser.add_option('', '--clobber', action='store_true', default=False,
1146 help='delete the output directory before compiling') 1065 help='delete the output directory before compiling')
1147 option_parser.add_option('', '--clobber-post-fail', action='store_true', 1066 option_parser.add_option('', '--clobber-post-fail', action='store_true',
(...skipping 15 matching lines...) Expand all
1163 help='name of project to build') 1082 help='name of project to build')
1164 option_parser.add_option('', '--build-dir', default='build', 1083 option_parser.add_option('', '--build-dir', default='build',
1165 help='path to directory containing solution and in ' 1084 help='path to directory containing solution and in '
1166 'which the build output will be placed') 1085 'which the build output will be placed')
1167 option_parser.add_option('', '--src-dir', default=None, 1086 option_parser.add_option('', '--src-dir', default=None,
1168 help='path to the root of the source tree') 1087 help='path to the root of the source tree')
1169 option_parser.add_option('', '--mode', default='dev', 1088 option_parser.add_option('', '--mode', default='dev',
1170 help='build mode (dev or official) controlling ' 1089 help='build mode (dev or official) controlling '
1171 'environment variables set during build') 1090 'environment variables set during build')
1172 option_parser.add_option('', '--build-tool', default=None, 1091 option_parser.add_option('', '--build-tool', default=None,
1173 help='specify build tool (ib, vs, scons, xcode)') 1092 help='specify build tool (ib, vs, xcode)')
1174 option_parser.add_option('', '--build-args', action='append', default=[], 1093 option_parser.add_option('', '--build-args', action='append', default=[],
1175 help='arguments to pass to the build tool') 1094 help='arguments to pass to the build tool')
1176 option_parser.add_option('', '--compiler', default=None, 1095 option_parser.add_option('', '--compiler', default=None,
1177 help='specify alternative compiler (e.g. clang)') 1096 help='specify alternative compiler (e.g. clang)')
1178 if chromium_utils.IsWindows(): 1097 if chromium_utils.IsWindows():
1179 # Windows only. 1098 # Windows only.
1180 option_parser.add_option('', '--no-ib', action='store_true', default=False, 1099 option_parser.add_option('', '--no-ib', action='store_true', default=False,
1181 help='use Visual Studio instead of IncrediBuild') 1100 help='use Visual Studio instead of IncrediBuild')
1182 option_parser.add_option('', '--msvs_version', 1101 option_parser.add_option('', '--msvs_version',
1183 help='VisualStudio version to use') 1102 help='VisualStudio version to use')
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 else: 1148 else:
1230 print('Please specify --build-tool.') 1149 print('Please specify --build-tool.')
1231 return 1 1150 return 1
1232 else: 1151 else:
1233 build_tool_map = { 1152 build_tool_map = {
1234 'ib' : main_win, 1153 'ib' : main_win,
1235 'vs' : main_win, 1154 'vs' : main_win,
1236 'make' : main_make, 1155 'make' : main_make,
1237 'make-android' : main_make_android, 1156 'make-android' : main_make_android,
1238 'ninja' : main_ninja, 1157 'ninja' : main_ninja,
1239 'scons' : main_scons,
1240 'xcode' : main_xcode, 1158 'xcode' : main_xcode,
1241 } 1159 }
1242 main = build_tool_map.get(options.build_tool) 1160 main = build_tool_map.get(options.build_tool)
1243 if not main: 1161 if not main:
1244 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) 1162 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool))
1245 return 2 1163 return 2
1246 1164
1247 options.target_output_dir = get_target_build_dir(options.build_tool, 1165 options.target_output_dir = get_target_build_dir(options.build_tool,
1248 options.src_dir, options.target, 'iphoneos' in args) 1166 options.src_dir, options.target, 'iphoneos' in args)
1249 options.clobber = (options.clobber or 1167 options.clobber = (options.clobber or
1250 landmines_triggered(options.target_output_dir)) 1168 landmines_triggered(options.target_output_dir))
1251 1169
1252 return main(options, args) 1170 return main(options, args)
1253 1171
1254 1172
1255 if '__main__' == __name__: 1173 if '__main__' == __name__:
1256 sys.exit(real_main()) 1174 sys.exit(real_main())
OLDNEW
« no previous file with comments | « build/scripts/slave/build_directory.py ('k') | build/scripts/slave/runtest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698