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

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

Issue 2201203003: Unified the code to upload goma-related information. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
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):
ukai 2016/08/03 05:21:16 doc comment?
Yoshisato Yanagisawa 2016/08/03 05:50:25 Done.
76 goma_ctl_cmd = [sys.executable,
77 os.path.join(options.goma_dir, 'goma_ctl.py')]
78
79 if options.goma_jsonstatus:
80 chromium_utils.RunCommand(
81 goma_ctl_cmd + ['jsonstatus', options.goma_jsonstatus], env=env)
82 goma_utils.SendGomaTsMon(options.goma_jsonstatus, exit_status)
83
84 # If goma compiler_proxy crashes, there could be crash dump.
85 if options.build_data_dir:
86 env['GOMACTL_CRASH_REPORT_ID_FILE'] = os.path.join(options.build_data_dir,
87 'crash_report_id_file')
88 # We must stop the proxy to dump GomaStats.
89 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env)
90 override_gsutil = None
91 if options.gsutil_py_path:
92 override_gsutil = options.gsutil_py_path
93 goma_utils.UploadGomaCompilerProxyInfo(override_gsutil=override_gsutil)
94
95 # Upload GomaStats to make it monitored.
96 if env.get('GOMA_DUMP_STATS_FILE'):
97 goma_utils.SendGomaStats(env['GOMA_DUMP_STATS_FILE'],
98 env.get('GOMACTL_CRASH_REPORT_ID_FILE'),
99 options.build_data_dir)
100
75 # TODO(tikuta): move to goma_utils.py 101 # TODO(tikuta): move to goma_utils.py
76 def goma_setup(options, env): 102 def goma_setup(options, env):
77 """Sets up goma if necessary. 103 """Sets up goma if necessary.
78 104
79 If using the Goma compiler, first call goma_ctl to ensure the proxy is 105 If using the Goma compiler, first call goma_ctl to ensure the proxy is
80 available, and returns (True, instance of cloudtail subprocess). 106 available, and returns (True, instance of cloudtail subprocess).
81 If it failed to start up compiler_proxy, modify options.compiler 107 If it failed to start up compiler_proxy, modify options.compiler
82 and options.goma_dir, modify env to GOMA_DISABLED=true, 108 and options.goma_dir, modify env to GOMA_DISABLED=true,
83 and returns (False, None). 109 and returns (False, None).
84 """ 110 """
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 cloudtail_path = 'C:\\infra-tools\\cloudtail' 173 cloudtail_path = 'C:\\infra-tools\\cloudtail'
148 try: 174 try:
149 cloudtail_proc = subprocess.Popen( 175 cloudtail_proc = subprocess.Popen(
150 [cloudtail_path, 'tail', '--log-id', 'goma_compiler_proxy', '--path', 176 [cloudtail_path, 'tail', '--log-id', 'goma_compiler_proxy', '--path',
151 goma_utils.GetLatestGomaCompilerProxyInfo()]) 177 goma_utils.GetLatestGomaCompilerProxyInfo()])
152 except Exception as e: 178 except Exception as e:
153 print 'failed to invoke cloudtail: %s' % e 179 print 'failed to invoke cloudtail: %s' % e
154 return True, None 180 return True, None
155 return True, cloudtail_proc 181 return True, cloudtail_proc
156 182
157 if options.goma_jsonstatus: 183 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 184
182 if options.goma_disable_local_fallback: 185 if options.goma_disable_local_fallback:
183 print 'error: failed to start goma; fallback has been disabled' 186 print 'error: failed to start goma; fallback has been disabled'
184 raise Exception('failed to start goma') 187 raise Exception('failed to start goma')
185 188
186 print 'warning: failed to start goma. falling back to non-goma' 189 print 'warning: failed to start goma. falling back to non-goma'
187 # Drop goma from options.compiler 190 # Drop goma from options.compiler
188 options.compiler = options.compiler.replace('goma-', '') 191 options.compiler = options.compiler.replace('goma-', '')
189 if options.compiler == 'goma': 192 if options.compiler == 'goma':
190 options.compiler = None 193 options.compiler = None
191 # Reset options.goma_dir. 194 # Reset options.goma_dir.
192 options.goma_dir = None 195 options.goma_dir = None
193 env['GOMA_DISABLED'] = '1' 196 env['GOMA_DISABLED'] = '1'
194 return False, None 197 return False, None
195 198
196 199
197 # TODO(tikuta): move to goma_utils.py 200 # TODO(tikuta): move to goma_utils.py
198 def goma_teardown(options, env, exit_status, cloudtail_proc): 201 def goma_teardown(options, env, exit_status, cloudtail_proc):
199 """Tears down goma if necessary. """ 202 """Tears down goma if necessary. """
200 if options.goma_dir: 203 if options.goma_dir:
201 override_gsutil = None 204 StopGomaClientAndUploadInfo(options, env, exit_status)
202 if options.gsutil_py_path:
203 override_gsutil = [sys.executable, options.gsutil_py_path]
204 205
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: 206 if cloudtail_proc:
224 cloudtail_proc.terminate() 207 cloudtail_proc.terminate()
225 cloudtail_proc.wait() 208 cloudtail_proc.wait()
226 209
227 210
228 def maybe_set_official_build_envvars(options, env): 211 def maybe_set_official_build_envvars(options, env):
229 if options.mode == 'google_chrome' or options.mode == 'official': 212 if options.mode == 'google_chrome' or options.mode == 'official':
230 env['CHROMIUM_BUILD'] = '_google_chrome' 213 env['CHROMIUM_BUILD'] = '_google_chrome'
231 214
232 if options.mode == 'official': 215 if options.mode == 'official':
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 exit_status = main_ninja(options, args, env) 524 exit_status = main_ninja(options, args, env)
542 525
543 # stop goma 526 # stop goma
544 goma_teardown(options, env, exit_status, goma_cloudtail) 527 goma_teardown(options, env, exit_status, goma_cloudtail)
545 528
546 return exit_status 529 return exit_status
547 530
548 531
549 if '__main__' == __name__: 532 if '__main__' == __name__:
550 sys.exit(real_main()) 533 sys.exit(real_main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698