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

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

Issue 14602020: Add an AOSP builder recipe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: rebase on top of CL 15270004 Created 7 years, 7 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
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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 681
682 target_command = command + ['BUILDTYPE=' + options.target] 682 target_command = command + ['BUILDTYPE=' + options.target]
683 result = chromium_utils.RunCommand(target_command, env=env) 683 result = chromium_utils.RunCommand(target_command, env=env)
684 if result and not options.clobber: 684 if result and not options.clobber:
685 clobber() 685 clobber()
686 686
687 goma_teardown(options, env) 687 goma_teardown(options, env)
688 688
689 return result 689 return result
690 690
691 def main_make_android(options, args):
692 """Interprets options, clobbers object files, and calls make.
693 """
694
695 env = EchoDict(os.environ)
696 goma_ready = goma_setup(options, env)
697 if not goma_ready:
698 assert options.compiler not in ('goma', 'goma-clang')
699 assert options.goma_dir is None
700
701 options.build_dir = os.path.abspath(options.build_dir)
702
703 if goma_ready:
704 command = [os.path.join(options.goma_dir, 'goma-android-make')]
705 else:
706 command = ['make']
707
708 working_dir = options.src_dir
709
710 os.chdir(working_dir)
711
712 # V=1 prints the actual executed command
713 if options.verbose:
714 command.extend(['V=1'])
715 command.extend(options.build_args + args)
716
717 # Run the build.
718 env.print_overrides()
719 result = 0
720
721 def clobber():
722 print('Removing %s' % options.target_output_dir)
723 chromium_utils.RemoveDirectory(options.target_output_dir)
724
725 if options.clobber:
726 clobber()
727
728 result = chromium_utils.RunCommand(command, env=env)
729 if result and not options.clobber:
730 clobber()
731
732 goma_teardown(options, env)
733
734 return result
691 735
692 def main_ninja(options, args): 736 def main_ninja(options, args):
693 """Interprets options, clobbers object files, and calls ninja.""" 737 """Interprets options, clobbers object files, and calls ninja."""
694 738
695 # Prepare environment. 739 # Prepare environment.
696 env = EchoDict(os.environ) 740 env = EchoDict(os.environ)
697 orig_compiler = options.compiler 741 orig_compiler = options.compiler
698 goma_ready = goma_setup(options, env) 742 goma_ready = goma_setup(options, env)
699 if not goma_ready: 743 if not goma_ready:
700 assert options.compiler not in ('goma', 'goma-clang') 744 assert options.compiler not in ('goma', 'goma-clang')
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 1090
1047 1091
1048 def get_target_build_dir(build_tool, src_dir, target, is_iphone=False): 1092 def get_target_build_dir(build_tool, src_dir, target, is_iphone=False):
1049 """Keep this function in sync with src/build/landmines.py""" 1093 """Keep this function in sync with src/build/landmines.py"""
1050 ret = None 1094 ret = None
1051 if build_tool == 'xcode': 1095 if build_tool == 'xcode':
1052 ret = os.path.join(src_dir, 'xcodebuild', 1096 ret = os.path.join(src_dir, 'xcodebuild',
1053 target + ('-iphoneos' if is_iphone else '')) 1097 target + ('-iphoneos' if is_iphone else ''))
1054 elif build_tool in ['make', 'ninja']: 1098 elif build_tool in ['make', 'ninja']:
1055 ret = os.path.join(src_dir, 'out', target) 1099 ret = os.path.join(src_dir, 'out', target)
1100 elif build_tool == 'make-android':
1101 ret = os.path.join(src_dir, 'out')
1056 elif build_tool in ['msvs', 'vs', 'ib']: 1102 elif build_tool in ['msvs', 'vs', 'ib']:
1057 ret = os.path.join(src_dir, 'build', target) 1103 ret = os.path.join(src_dir, 'build', target)
1058 elif build_tool == 'scons': 1104 elif build_tool == 'scons':
1059 ret = os.path.join(src_dir, 'sconsbuild', target) 1105 ret = os.path.join(src_dir, 'sconsbuild', target)
1060 else: 1106 else:
1061 raise NotImplementedError() 1107 raise NotImplementedError()
1062 return os.path.abspath(ret) 1108 return os.path.abspath(ret)
1063 1109
1064 1110
1065 def real_main(): 1111 def real_main():
(...skipping 13 matching lines...) Expand all
1079 help='build target (Debug or Release)') 1125 help='build target (Debug or Release)')
1080 option_parser.add_option('', '--arch', default=None, 1126 option_parser.add_option('', '--arch', default=None,
1081 help='target architecture (ia32, x64, ...') 1127 help='target architecture (ia32, x64, ...')
1082 option_parser.add_option('', '--solution', default=None, 1128 option_parser.add_option('', '--solution', default=None,
1083 help='name of solution/sub-project to build') 1129 help='name of solution/sub-project to build')
1084 option_parser.add_option('', '--project', default=None, 1130 option_parser.add_option('', '--project', default=None,
1085 help='name of project to build') 1131 help='name of project to build')
1086 option_parser.add_option('', '--build-dir', default='build', 1132 option_parser.add_option('', '--build-dir', default='build',
1087 help='path to directory containing solution and in ' 1133 help='path to directory containing solution and in '
1088 'which the build output will be placed') 1134 'which the build output will be placed')
1135 option_parser.add_option('', '--src-dir', default=None,
1136 help='path to directory containing the root of the '
1137 'source tree')
1138 option_parser.add_option('', '--target-output-dir', default=None,
1139 help='path to directory containing the root of the '
1140 'output folder')
1089 option_parser.add_option('', '--mode', default='dev', 1141 option_parser.add_option('', '--mode', default='dev',
1090 help='build mode (dev or official) controlling ' 1142 help='build mode (dev or official) controlling '
1091 'environment variables set during build') 1143 'environment variables set during build')
1092 option_parser.add_option('', '--build-tool', default=None, 1144 option_parser.add_option('', '--build-tool', default=None,
1093 help='specify build tool (ib, vs, scons, xcode)') 1145 help='specify build tool (ib, vs, scons, xcode)')
1094 option_parser.add_option('', '--build-args', action='append', default=[], 1146 option_parser.add_option('', '--build-args', action='append', default=[],
1095 help='arguments to pass to the build tool') 1147 help='arguments to pass to the build tool')
1096 option_parser.add_option('', '--compiler', default=None, 1148 option_parser.add_option('', '--compiler', default=None,
1097 help='specify alternative compiler (e.g. clang)') 1149 help='specify alternative compiler (e.g. clang)')
1098 if chromium_utils.IsWindows(): 1150 if chromium_utils.IsWindows():
(...skipping 15 matching lines...) Expand all
1114 option_parser.add_option('', '--disable-aslr', action='store_true', 1166 option_parser.add_option('', '--disable-aslr', action='store_true',
1115 default=False, help='disable ASLR on OS X 10.6') 1167 default=False, help='disable ASLR on OS X 10.6')
1116 option_parser.add_option('', '--goma-dir', 1168 option_parser.add_option('', '--goma-dir',
1117 default=os.path.join(BUILD_DIR, 'goma'), 1169 default=os.path.join(BUILD_DIR, 'goma'),
1118 help='specify goma directory') 1170 help='specify goma directory')
1119 option_parser.add_option('--verbose', action='store_true') 1171 option_parser.add_option('--verbose', action='store_true')
1120 1172
1121 options, args = option_parser.parse_args() 1173 options, args = option_parser.parse_args()
1122 1174
1123 options.build_dir = os.path.abspath(options.build_dir) 1175 options.build_dir = os.path.abspath(options.build_dir)
1124 options.src_dir = os.path.join(slave_utils.SlaveBaseDir( 1176 if not options.src_dir:
1125 os.path.abspath(options.build_dir)), 'build', 'src') 1177 options.src_dir = os.path.join(slave_utils.SlaveBaseDir(
1178 os.path.abspath(options.build_dir)), 'build', 'src')
1126 1179
1127 if options.build_tool is None: 1180 if options.build_tool is None:
1128 if chromium_utils.IsWindows(): 1181 if chromium_utils.IsWindows():
1129 main = main_win 1182 main = main_win
1130 options.build_tool = 'msvs' 1183 options.build_tool = 'msvs'
1131 elif chromium_utils.IsMac(): 1184 elif chromium_utils.IsMac():
1132 main = main_xcode 1185 main = main_xcode
1133 options.build_tool = 'xcode' 1186 options.build_tool = 'xcode'
1134 elif chromium_utils.IsLinux(): 1187 elif chromium_utils.IsLinux():
1135 # We're in the process of moving to ninja by default on Linux, see 1188 # We're in the process of moving to ninja by default on Linux, see
(...skipping 24 matching lines...) Expand all
1160 main = main_make 1213 main = main_make
1161 options.build_tool = 'make' 1214 options.build_tool = 'make'
1162 else: 1215 else:
1163 print('Please specify --build-tool.') 1216 print('Please specify --build-tool.')
1164 return 1 1217 return 1
1165 else: 1218 else:
1166 build_tool_map = { 1219 build_tool_map = {
1167 'ib' : main_win, 1220 'ib' : main_win,
1168 'vs' : main_win, 1221 'vs' : main_win,
1169 'make' : main_make, 1222 'make' : main_make,
1223 'make-android' : main_make_android,
1170 'ninja' : main_ninja, 1224 'ninja' : main_ninja,
1171 'scons' : main_scons, 1225 'scons' : main_scons,
1172 'xcode' : main_xcode, 1226 'xcode' : main_xcode,
1173 } 1227 }
1174 main = build_tool_map.get(options.build_tool) 1228 main = build_tool_map.get(options.build_tool)
1175 if not main: 1229 if not main:
1176 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) 1230 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool))
1177 return 2 1231 return 2
1178 1232
1179 options.target_output_dir = get_target_build_dir(options.build_tool, 1233 options.target_output_dir = get_target_build_dir(options.build_tool,
1180 options.src_dir, options.target, 'iphoneos' in args) 1234 options.src_dir, options.target, 'iphoneos' in args)
1181 options.clobber = (options.clobber or 1235 options.clobber = (options.clobber or
1182 landmines_triggered(options.target_output_dir)) 1236 landmines_triggered(options.target_output_dir))
1183 1237
1184 return main(options, args) 1238 return main(options, args)
1185 1239
1186 1240
1187 if '__main__' == __name__: 1241 if '__main__' == __name__:
1188 sys.exit(real_main()) 1242 sys.exit(real_main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698