Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 fh = sys.stdout | 65 fh = sys.stdout |
| 66 fh.write('Environment variables modified in compile.py:\n') | 66 fh.write('Environment variables modified in compile.py:\n') |
| 67 for k in sorted(list(self.overrides)): | 67 for k in sorted(list(self.overrides)): |
| 68 if k in self: | 68 if k in self: |
| 69 fh.write(' %s=%s\n' % (k, self[k])) | 69 fh.write(' %s=%s\n' % (k, self[k])) |
| 70 else: | 70 else: |
| 71 fh.write(' %s (removed)\n' % k) | 71 fh.write(' %s (removed)\n' % k) |
| 72 fh.write('\n') | 72 fh.write('\n') |
| 73 | 73 |
| 74 | 74 |
| 75 def StopGomaClientAndUploadInfo(options, env, exit_status): | |
| 76 """Stop goma compiler_proxy and upload goma-related information. | |
| 77 | |
| 78 Args: | |
| 79 options (Option) : options to specify where to store goma-related info. | |
| 80 env (dict) : used when goma_ctl command executes. | |
| 81 exit_status (int): exit_status sent to monitoring system. | |
| 82 """ | |
| 83 goma_ctl_cmd = [sys.executable, | |
| 84 os.path.join(options.goma_dir, 'goma_ctl.py')] | |
| 85 | |
| 86 if options.goma_jsonstatus: | |
| 87 chromium_utils.RunCommand( | |
| 88 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) | |
| 89 goma_utils.SendGomaTsMon(options.goma_jsonstatus, exit_status) | |
| 90 | |
| 91 # If goma compiler_proxy crashes, there could be crash dump. | |
| 92 if options.build_data_dir: | |
| 93 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, | |
| 94 'crash_report_id_file') | |
| 95 # We must stop the proxy to dump GomaStats. | |
| 96 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) | |
| 97 override_gsutil = None | |
| 98 if options.gsutil_py_path: | |
| 99 override_gsutil = options.gsutil_py_path | |
|
shinyak
2016/08/03 06:31:06
[sys.executable, options.gsutil_py_path] ?
| |
| 100 goma_utils.UploadGomaCompilerProxyInfo(override_gsutil=override_gsutil) | |
| 101 | |
| 102 # Upload GomaStats to make it monitored. | |
| 103 if env.get('GOMA_DUMP_STATS_FILE'): | |
| 104 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], | |
| 105 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), | |
| 106 options.build_data_dir) | |
| 107 | |
| 75 # TODO(tikuta): move to goma_utils.py | 108 # TODO(tikuta): move to goma_utils.py |
| 76 def goma_setup(options, env): | 109 def goma_setup(options, env): |
| 77 """Sets up goma if necessary. | 110 """Sets up goma if necessary. |
| 78 | 111 |
| 79 If using the Goma compiler, first call goma_ctl to ensure the proxy is | 112 If using the Goma compiler, first call goma_ctl to ensure the proxy is |
| 80 available, and returns (True, instance of cloudtail subprocess). | 113 available, and returns (True, instance of cloudtail subprocess). |
| 81 If it failed to start up compiler_proxy, modify options.compiler | 114 If it failed to start up compiler_proxy, modify options.compiler |
| 82 and options.goma_dir, modify env to GOMA_DISABLED=true, | 115 and options.goma_dir, modify env to GOMA_DISABLED=true, |
| 83 and returns (False, None). | 116 and returns (False, None). |
| 84 """ | 117 """ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 cloudtail_path = 'C:\\infra-tools\\cloudtail' | 180 cloudtail_path = 'C:\\infra-tools\\cloudtail' |
| 148 try: | 181 try: |
| 149 cloudtail_proc = subprocess.Popen( | 182 cloudtail_proc = subprocess.Popen( |
| 150 [cloudtail_path, 'tail', '--log-id', 'goma_compiler_proxy', '--path', | 183 [cloudtail_path, 'tail', '--log-id', 'goma_compiler_proxy', '--path', |
| 151 goma_utils.GetLatestGomaCompilerProxyInfo()]) | 184 goma_utils.GetLatestGomaCompilerProxyInfo()]) |
| 152 except Exception as e: | 185 except Exception as e: |
| 153 print 'failed to invoke cloudtail: %s' % e | 186 print 'failed to invoke cloudtail: %s' % e |
| 154 return True, None | 187 return True, None |
| 155 return True, cloudtail_proc | 188 return True, cloudtail_proc |
| 156 | 189 |
| 157 if options.goma_jsonstatus: | 190 StopGomaClientAndUploadInfo(options, env, -1) |
| 158 chromium_utils.RunCommand( | |
| 159 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) | |
| 160 goma_utils.SendGomaTsMon(options.goma_jsonstatus, -1) | |
| 161 | |
| 162 # Try to stop compiler_proxy so that it flushes logs and stores | |
| 163 # GomaStats. | |
| 164 if options.build_data_dir: | |
| 165 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, | |
| 166 'crash_report_id_file') | |
| 167 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) | |
| 168 | |
| 169 override_gsutil = None | |
| 170 if options.gsutil_py_path: | |
| 171 override_gsutil = [sys.executable, options.gsutil_py_path] | |
| 172 | |
| 173 # Upload compiler_proxy.INFO to investigate the reason of compiler_proxy | |
| 174 # start-up failure. | |
| 175 goma_utils.UploadGomaCompilerProxyInfo(override_gsutil=override_gsutil) | |
| 176 # Upload GomaStats to make it monitored. | |
| 177 if env.get('GOMA_DUMP_STATS_FILE'): | |
| 178 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], | |
| 179 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), | |
| 180 options.build_data_dir) | |
| 181 | 191 |
| 182 if options.goma_disable_local_fallback: | 192 if options.goma_disable_local_fallback: |
| 183 print 'error: failed to start goma; fallback has been disabled' | 193 print 'error: failed to start goma; fallback has been disabled' |
| 184 raise Exception('failed to start goma') | 194 raise Exception('failed to start goma') |
| 185 | 195 |
| 186 print 'warning: failed to start goma. falling back to non-goma' | 196 print 'warning: failed to start goma. falling back to non-goma' |
| 187 # Drop goma from options.compiler | 197 # Drop goma from options.compiler |
| 188 options.compiler = options.compiler.replace('goma-', '') | 198 options.compiler = options.compiler.replace('goma-', '') |
| 189 if options.compiler == 'goma': | 199 if options.compiler == 'goma': |
| 190 options.compiler = None | 200 options.compiler = None |
| 191 # Reset options.goma_dir. | 201 # Reset options.goma_dir. |
| 192 options.goma_dir = None | 202 options.goma_dir = None |
| 193 env['GOMA_DISABLED'] = '1' | 203 env['GOMA_DISABLED'] = '1' |
| 194 return False, None | 204 return False, None |
| 195 | 205 |
| 196 | 206 |
| 197 # TODO(tikuta): move to goma_utils.py | 207 # TODO(tikuta): move to goma_utils.py |
| 198 def goma_teardown(options, env, exit_status, cloudtail_proc): | 208 def goma_teardown(options, env, exit_status, cloudtail_proc): |
| 199 """Tears down goma if necessary. """ | 209 """Tears down goma if necessary. """ |
| 200 if options.goma_dir: | 210 if options.goma_dir: |
| 201 override_gsutil = None | 211 StopGomaClientAndUploadInfo(options, env, exit_status) |
| 202 if options.gsutil_py_path: | |
| 203 override_gsutil = [sys.executable, options.gsutil_py_path] | |
| 204 | 212 |
| 205 # If goma compiler_proxy crashes during the build, there could be crash | |
| 206 # dump. | |
| 207 if options.build_data_dir: | |
| 208 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir, | |
| 209 'crash_report_id_file') | |
| 210 goma_ctl_cmd = [sys.executable, | |
| 211 os.path.join(options.goma_dir, 'goma_ctl.py')] | |
| 212 if options.goma_jsonstatus: | |
| 213 chromium_utils.RunCommand( | |
| 214 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env) | |
| 215 goma_utils.SendGomaTsMon(options.goma_jsonstatus, exit_status) | |
| 216 # Always stop the proxy to dump GomaStats. | |
| 217 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) | |
| 218 goma_utils.UploadGomaCompilerProxyInfo(override_gsutil=override_gsutil) | |
| 219 if env.get('GOMA_DUMP_STATS_FILE'): | |
| 220 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'], | |
| 221 env.get('GOMACTL_CRASH_REPORT_ID_FILE'), | |
| 222 options.build_data_dir) | |
| 223 if cloudtail_proc: | 213 if cloudtail_proc: |
| 224 cloudtail_proc.terminate() | 214 cloudtail_proc.terminate() |
| 225 cloudtail_proc.wait() | 215 cloudtail_proc.wait() |
| 226 | 216 |
| 227 | 217 |
| 228 def maybe_set_official_build_envvars(options, env): | 218 def maybe_set_official_build_envvars(options, env): |
| 229 if options.mode == 'google_chrome' or options.mode == 'official': | 219 if options.mode == 'google_chrome' or options.mode == 'official': |
| 230 env['CHROMIUM_BUILD'] = '_google_chrome' | 220 env['CHROMIUM_BUILD'] = '_google_chrome' |
| 231 | 221 |
| 232 if options.mode == 'official': | 222 if options.mode == 'official': |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 exit_status = main_ninja(options, args, env) | 531 exit_status = main_ninja(options, args, env) |
| 542 | 532 |
| 543 # stop goma | 533 # stop goma |
| 544 goma_teardown(options, env, exit_status, goma_cloudtail) | 534 goma_teardown(options, env, exit_status, goma_cloudtail) |
| 545 | 535 |
| 546 return exit_status | 536 return exit_status |
| 547 | 537 |
| 548 | 538 |
| 549 if '__main__' == __name__: | 539 if '__main__' == __name__: |
| 550 sys.exit(real_main()) | 540 sys.exit(real_main()) |
| OLD | NEW |