| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 # The Android.mk build system handles deps differently than the 'regular' |
| 726 # Chromium makefiles which can lead to targets not being rebuilt properly. |
| 727 # Fixing this is actually quite hard so we make this bot always clobber. |
| 728 clobber() |
| 729 |
| 730 result = chromium_utils.RunCommand(command, env=env) |
| 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 Loading... |
| 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 Loading... |
| 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 the root of the source tree') |
| 1137 option_parser.add_option('', '--target-output-dir', default=None, |
| 1138 help='path to the output folder') |
| 1089 option_parser.add_option('', '--mode', default='dev', | 1139 option_parser.add_option('', '--mode', default='dev', |
| 1090 help='build mode (dev or official) controlling ' | 1140 help='build mode (dev or official) controlling ' |
| 1091 'environment variables set during build') | 1141 'environment variables set during build') |
| 1092 option_parser.add_option('', '--build-tool', default=None, | 1142 option_parser.add_option('', '--build-tool', default=None, |
| 1093 help='specify build tool (ib, vs, scons, xcode)') | 1143 help='specify build tool (ib, vs, scons, xcode)') |
| 1094 option_parser.add_option('', '--build-args', action='append', default=[], | 1144 option_parser.add_option('', '--build-args', action='append', default=[], |
| 1095 help='arguments to pass to the build tool') | 1145 help='arguments to pass to the build tool') |
| 1096 option_parser.add_option('', '--compiler', default=None, | 1146 option_parser.add_option('', '--compiler', default=None, |
| 1097 help='specify alternative compiler (e.g. clang)') | 1147 help='specify alternative compiler (e.g. clang)') |
| 1098 if chromium_utils.IsWindows(): | 1148 if chromium_utils.IsWindows(): |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1114 option_parser.add_option('', '--disable-aslr', action='store_true', | 1164 option_parser.add_option('', '--disable-aslr', action='store_true', |
| 1115 default=False, help='disable ASLR on OS X 10.6') | 1165 default=False, help='disable ASLR on OS X 10.6') |
| 1116 option_parser.add_option('', '--goma-dir', | 1166 option_parser.add_option('', '--goma-dir', |
| 1117 default=os.path.join(BUILD_DIR, 'goma'), | 1167 default=os.path.join(BUILD_DIR, 'goma'), |
| 1118 help='specify goma directory') | 1168 help='specify goma directory') |
| 1119 option_parser.add_option('--verbose', action='store_true') | 1169 option_parser.add_option('--verbose', action='store_true') |
| 1120 | 1170 |
| 1121 options, args = option_parser.parse_args() | 1171 options, args = option_parser.parse_args() |
| 1122 | 1172 |
| 1123 options.build_dir = os.path.abspath(options.build_dir) | 1173 options.build_dir = os.path.abspath(options.build_dir) |
| 1124 options.src_dir = os.path.join(slave_utils.SlaveBaseDir( | 1174 if not options.src_dir: |
| 1125 os.path.abspath(options.build_dir)), 'build', 'src') | 1175 options.src_dir = os.path.join(slave_utils.SlaveBaseDir( |
| 1176 os.path.abspath(options.build_dir)), 'build', 'src') |
| 1126 | 1177 |
| 1127 if options.build_tool is None: | 1178 if options.build_tool is None: |
| 1128 if chromium_utils.IsWindows(): | 1179 if chromium_utils.IsWindows(): |
| 1129 main = main_win | 1180 main = main_win |
| 1130 options.build_tool = 'msvs' | 1181 options.build_tool = 'msvs' |
| 1131 elif chromium_utils.IsMac(): | 1182 elif chromium_utils.IsMac(): |
| 1132 main = main_xcode | 1183 main = main_xcode |
| 1133 options.build_tool = 'xcode' | 1184 options.build_tool = 'xcode' |
| 1134 elif chromium_utils.IsLinux(): | 1185 elif chromium_utils.IsLinux(): |
| 1135 # We're in the process of moving to ninja by default on Linux, see | 1186 # We're in the process of moving to ninja by default on Linux, see |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1160 main = main_make | 1211 main = main_make |
| 1161 options.build_tool = 'make' | 1212 options.build_tool = 'make' |
| 1162 else: | 1213 else: |
| 1163 print('Please specify --build-tool.') | 1214 print('Please specify --build-tool.') |
| 1164 return 1 | 1215 return 1 |
| 1165 else: | 1216 else: |
| 1166 build_tool_map = { | 1217 build_tool_map = { |
| 1167 'ib' : main_win, | 1218 'ib' : main_win, |
| 1168 'vs' : main_win, | 1219 'vs' : main_win, |
| 1169 'make' : main_make, | 1220 'make' : main_make, |
| 1221 'make-android' : main_make_android, |
| 1170 'ninja' : main_ninja, | 1222 'ninja' : main_ninja, |
| 1171 'scons' : main_scons, | 1223 'scons' : main_scons, |
| 1172 'xcode' : main_xcode, | 1224 'xcode' : main_xcode, |
| 1173 } | 1225 } |
| 1174 main = build_tool_map.get(options.build_tool) | 1226 main = build_tool_map.get(options.build_tool) |
| 1175 if not main: | 1227 if not main: |
| 1176 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) | 1228 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) |
| 1177 return 2 | 1229 return 2 |
| 1178 | 1230 |
| 1179 options.target_output_dir = get_target_build_dir(options.build_tool, | 1231 options.target_output_dir = get_target_build_dir(options.build_tool, |
| 1180 options.src_dir, options.target, 'iphoneos' in args) | 1232 options.src_dir, options.target, 'iphoneos' in args) |
| 1181 options.clobber = (options.clobber or | 1233 options.clobber = (options.clobber or |
| 1182 landmines_triggered(options.target_output_dir)) | 1234 landmines_triggered(options.target_output_dir)) |
| 1183 | 1235 |
| 1184 return main(options, args) | 1236 return main(options, args) |
| 1185 | 1237 |
| 1186 | 1238 |
| 1187 if '__main__' == __name__: | 1239 if '__main__' == __name__: |
| 1188 sys.exit(real_main()) | 1240 sys.exit(real_main()) |
| OLD | NEW |