| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) | 192 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) |
| 193 goma_utils.SendGomaTsMon(options.goma_jsonstatus, -1) | 193 goma_utils.SendGomaTsMon(options.goma_jsonstatus, -1) |
| 194 | 194 |
| 195 # Try to stop compiler_proxy so that it flushes logs and stores | 195 # Try to stop compiler_proxy so that it flushes logs and stores |
| 196 # GomaStats. | 196 # GomaStats. |
| 197 if options.build_data_dir: | 197 if options.build_data_dir: |
| 198 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, | 198 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, |
| 199 'crash_report_id_file') | 199 'crash_report_id_file') |
| 200 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) | 200 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) |
| 201 | 201 |
| 202 override_gsutil = None |
| 203 if options.gsutil_py_path: |
| 204 override_gsutil = [sys.executable, options.gsutil_py_path] |
| 205 |
| 202 # Upload compiler_proxy.INFO to investigate the reason of compiler_proxy | 206 # Upload compiler_proxy.INFO to investigate the reason of compiler_proxy |
| 203 # start-up failure. | 207 # start-up failure. |
| 204 goma_utils.UploadGomaCompilerProxyInfo() | 208 goma_utils.UploadGomaCompilerProxyInfo(override_gsutil=override_gsutil) |
| 205 # Upload GomaStats to make it monitored. | 209 # Upload GomaStats to make it monitored. |
| 206 if env.get('GOMA_DUMP_STATS_FILE'): | 210 if env.get('GOMA_DUMP_STATS_FILE'): |
| 207 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], | 211 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], |
| 208 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), | 212 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), |
| 209 options.build_data_dir) | 213 options.build_data_dir) |
| 210 | 214 |
| 211 if options.goma_disable_local_fallback: | 215 if options.goma_disable_local_fallback: |
| 212 print 'error: failed to start goma; fallback has been disabled' | 216 print 'error: failed to start goma; fallback has been disabled' |
| 213 raise Exception('failed to start goma') | 217 raise Exception('failed to start goma') |
| 214 | 218 |
| 215 print 'warning: failed to start goma. falling back to non-goma' | 219 print 'warning: failed to start goma. falling back to non-goma' |
| 216 # Drop goma from options.compiler | 220 # Drop goma from options.compiler |
| 217 options.compiler = options.compiler.replace('goma-', '') | 221 options.compiler = options.compiler.replace('goma-', '') |
| 218 if options.compiler == 'goma': | 222 if options.compiler == 'goma': |
| 219 options.compiler = None | 223 options.compiler = None |
| 220 # Reset options.goma_dir. | 224 # Reset options.goma_dir. |
| 221 options.goma_dir = None | 225 options.goma_dir = None |
| 222 env['GOMA_DISABLED'] = '1' | 226 env['GOMA_DISABLED'] = '1' |
| 223 return False | 227 return False |
| 224 | 228 |
| 225 | 229 |
| 226 def goma_teardown(options, env, exit_status): | 230 def goma_teardown(options, env, exit_status): |
| 227 """Tears down goma if necessary. """ | 231 """Tears down goma if necessary. """ |
| 228 if (options.compiler in ('goma', 'goma-clang') and | 232 if (options.compiler in ('goma', 'goma-clang') and |
| 229 options.goma_dir): | 233 options.goma_dir): |
| 234 override_gsutil = None |
| 235 if options.gsutil_py_path: |
| 236 override_gsutil = [sys.executable, options.gsutil_py_path] |
| 237 |
| 230 # If goma compiler_proxy crashes during the build, there could be crash | 238 # If goma compiler_proxy crashes during the build, there could be crash |
| 231 # dump. | 239 # dump. |
| 232 if options.build_data_dir: | 240 if options.build_data_dir: |
| 233 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, | 241 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, |
| 234 'crash_report_id_file') | 242 'crash_report_id_file') |
| 235 goma_ctl_cmd = [sys.executable, | 243 goma_ctl_cmd = [sys.executable, |
| 236 os.path.join(options.goma_dir, 'goma_ctl.py')] | 244 os.path.join(options.goma_dir, 'goma_ctl.py')] |
| 237 if options.goma_jsonstatus: | 245 if options.goma_jsonstatus: |
| 238 chromium_utils.RunCommand( | 246 chromium_utils.RunCommand( |
| 239 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) | 247 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) |
| 240 goma_utils.SendGomaTsMon(options.goma_jsonstatus, exit_status) | 248 goma_utils.SendGomaTsMon(options.goma_jsonstatus, exit_status) |
| 241 # Always stop the proxy for now to allow in-place update. | 249 # Always stop the proxy for now to allow in-place update. |
| 242 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) | 250 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) |
| 243 goma_utils.UploadGomaCompilerProxyInfo() | 251 goma_utils.UploadGomaCompilerProxyInfo(override_gsutil=override_gsutil) |
| 244 if env.get('GOMA_DUMP_STATS_FILE'): | 252 if env.get('GOMA_DUMP_STATS_FILE'): |
| 245 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], | 253 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], |
| 246 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), | 254 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), |
| 247 options.build_data_dir) | 255 options.build_data_dir) |
| 248 | 256 |
| 249 | 257 |
| 250 def common_xcode_settings(command, options, env, compiler=None): | 258 def common_xcode_settings(command, options, env, compiler=None): |
| 251 """ | 259 """ |
| 252 Sets desirable Mac environment variables and command-line options | 260 Sets desirable Mac environment variables and command-line options |
| 253 that are common to the Xcode builds. | 261 that are common to the Xcode builds. |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 if not filter_obj.was_up_to_date: | 960 if not filter_obj.was_up_to_date: |
| 953 print 'Failing build because ninja reported work to do.' | 961 print 'Failing build because ninja reported work to do.' |
| 954 print 'This means that after completing a compile, another was run and' | 962 print 'This means that after completing a compile, another was run and' |
| 955 print 'it resulted in still having work to do (that is, a no-op build' | 963 print 'it resulted in still having work to do (that is, a no-op build' |
| 956 print 'wasn\'t a no-op). Consult the first "ninja explain:" line for a' | 964 print 'wasn\'t a no-op). Consult the first "ninja explain:" line for a' |
| 957 print 'likely culprit.' | 965 print 'likely culprit.' |
| 958 return 1 | 966 return 1 |
| 959 return exit_status | 967 return exit_status |
| 960 finally: | 968 finally: |
| 961 goma_teardown(options, env, exit_status) | 969 goma_teardown(options, env, exit_status) |
| 970 |
| 971 override_gsutil = None |
| 972 if options.gsutil_py_path: |
| 973 override_gsutil = [sys.executable, options.gsutil_py_path] |
| 974 |
| 962 goma_utils.UploadNinjaLog( | 975 goma_utils.UploadNinjaLog( |
| 963 options.target_output_dir, options.compiler, command, exit_status) | 976 options.target_output_dir, options.compiler, command, exit_status, |
| 977 override_gsutil=override_gsutil) |
| 964 | 978 |
| 965 | 979 |
| 966 def main_win(options, args): | 980 def main_win(options, args): |
| 967 """Interprets options, clobbers object files, and calls the build tool. | 981 """Interprets options, clobbers object files, and calls the build tool. |
| 968 """ | 982 """ |
| 969 if not options.solution: | 983 if not options.solution: |
| 970 options.solution = 'all.sln' | 984 options.solution = 'all.sln' |
| 971 solution = os.path.join(options.build_dir, options.solution) | 985 solution = os.path.join(options.build_dir, options.solution) |
| 972 | 986 |
| 973 # Prefer the version specified in the .sln. When devenv.com is used at the | 987 # Prefer the version specified in the .sln. When devenv.com is used at the |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 option_parser.add_option('--goma-enable-compiler-info-cache', | 1259 option_parser.add_option('--goma-enable-compiler-info-cache', |
| 1246 action='store_true', | 1260 action='store_true', |
| 1247 help='Enable goma CompilerInfo cache') | 1261 help='Enable goma CompilerInfo cache') |
| 1248 option_parser.add_option('--goma-store-local-run-output', default=None, | 1262 option_parser.add_option('--goma-store-local-run-output', default=None, |
| 1249 help='Store local run output to goma servers.') | 1263 help='Store local run output to goma servers.') |
| 1250 option_parser.add_option('--goma-fail-fast', action='store_true') | 1264 option_parser.add_option('--goma-fail-fast', action='store_true') |
| 1251 option_parser.add_option('--goma-disable-local-fallback', action='store_true') | 1265 option_parser.add_option('--goma-disable-local-fallback', action='store_true') |
| 1252 option_parser.add_option('--goma-jsonstatus', | 1266 option_parser.add_option('--goma-jsonstatus', |
| 1253 help='Specify a file to dump goma_ctl jsonstatus.') | 1267 help='Specify a file to dump goma_ctl jsonstatus.') |
| 1254 option_parser.add_option('--verbose', action='store_true') | 1268 option_parser.add_option('--verbose', action='store_true') |
| 1269 option_parser.add_option('--gsutil-py-path', |
| 1270 help='Specify path to gsutil.py script.') |
| 1255 option_parser.add_option('--ninja-path', default='ninja', | 1271 option_parser.add_option('--ninja-path', default='ninja', |
| 1256 help='Specify path to the ninja tool.') | 1272 help='Specify path to the ninja tool.') |
| 1257 option_parser.add_option('--ninja-ensure-up-to-date', action='store_true', | 1273 option_parser.add_option('--ninja-ensure-up-to-date', action='store_true', |
| 1258 help='Checks the output of the ninja builder to ' | 1274 help='Checks the output of the ninja builder to ' |
| 1259 'confirm that a second compile immediately ' | 1275 'confirm that a second compile immediately ' |
| 1260 'the first is a no-op.') | 1276 'the first is a no-op.') |
| 1261 | 1277 |
| 1262 options, args = option_parser.parse_args() | 1278 options, args = option_parser.parse_args() |
| 1263 | 1279 |
| 1264 if not options.src_dir: | 1280 if not options.src_dir: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) | 1345 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) |
| 1330 return 2 | 1346 return 2 |
| 1331 | 1347 |
| 1332 options.target_output_dir = get_target_build_dir(args, options) | 1348 options.target_output_dir = get_target_build_dir(args, options) |
| 1333 | 1349 |
| 1334 return main(options, args) | 1350 return main(options, args) |
| 1335 | 1351 |
| 1336 | 1352 |
| 1337 if '__main__' == __name__: | 1353 if '__main__' == __name__: |
| 1338 sys.exit(real_main()) | 1354 sys.exit(real_main()) |
| OLD | NEW |