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

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

Issue 2206933002: Revert of 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):
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
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
108 # TODO(tikuta): move to goma_utils.py 75 # TODO(tikuta): move to goma_utils.py
109 def goma_setup(options, env): 76 def goma_setup(options, env):
110 """Sets up goma if necessary. 77 """Sets up goma if necessary.
111 78
112 If using the Goma compiler, first call goma_ctl to ensure the proxy is 79 If using the Goma compiler, first call goma_ctl to ensure the proxy is
113 available, and returns (True, instance of cloudtail subprocess). 80 available, and returns (True, instance of cloudtail subprocess).
114 If it failed to start up compiler_proxy, modify options.compiler 81 If it failed to start up compiler_proxy, modify options.compiler
115 and options.goma_dir, modify env to GOMA_DISABLED=true, 82 and options.goma_dir, modify env to GOMA_DISABLED=true,
116 and returns (False, None). 83 and returns (False, None).
117 """ 84 """
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 cloudtail_path = 'C:\\infra-tools\\cloudtail' 147 cloudtail_path = 'C:\\infra-tools\\cloudtail'
181 try: 148 try:
182 cloudtail_proc = subprocess.Popen( 149 cloudtail_proc = subprocess.Popen(
183 [cloudtail_path, 'tail', '--log-id', 'goma_compiler_proxy', '--path', 150 [cloudtail_path, 'tail', '--log-id', 'goma_compiler_proxy', '--path',
184 goma_utils.GetLatestGomaCompilerProxyInfo()]) 151 goma_utils.GetLatestGomaCompilerProxyInfo()])
185 except Exception as e: 152 except Exception as e:
186 print 'failed to invoke cloudtail: %s' % e 153 print 'failed to invoke cloudtail: %s' % e
187 return True, None 154 return True, None
188 return True, cloudtail_proc 155 return True, cloudtail_proc
189 156
190 StopGomaClientAndUploadInfo(options, env, -1) 157 if options.goma_jsonstatus:
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)
191 181
192 if options.goma_disable_local_fallback: 182 if options.goma_disable_local_fallback:
193 print 'error: failed to start goma; fallback has been disabled' 183 print 'error: failed to start goma; fallback has been disabled'
194 raise Exception('failed to start goma') 184 raise Exception('failed to start goma')
195 185
196 print 'warning: failed to start goma. falling back to non-goma' 186 print 'warning: failed to start goma. falling back to non-goma'
197 # Drop goma from options.compiler 187 # Drop goma from options.compiler
198 options.compiler = options.compiler.replace('goma-', '') 188 options.compiler = options.compiler.replace('goma-', '')
199 if options.compiler == 'goma': 189 if options.compiler == 'goma':
200 options.compiler = None 190 options.compiler = None
201 # Reset options.goma_dir. 191 # Reset options.goma_dir.
202 options.goma_dir = None 192 options.goma_dir = None
203 env['GOMA_DISABLED'] = '1' 193 env['GOMA_DISABLED'] = '1'
204 return False, None 194 return False, None
205 195
206 196
207 # TODO(tikuta): move to goma_utils.py 197 # TODO(tikuta): move to goma_utils.py
208 def goma_teardown(options, env, exit_status, cloudtail_proc): 198 def goma_teardown(options, env, exit_status, cloudtail_proc):
209 """Tears down goma if necessary. """ 199 """Tears down goma if necessary. """
210 if options.goma_dir: 200 if options.goma_dir:
211 StopGomaClientAndUploadInfo(options, env, exit_status) 201 override_gsutil = None
202 if options.gsutil_py_path:
203 override_gsutil = [sys.executable, options.gsutil_py_path]
212 204
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)
213 if cloudtail_proc: 223 if cloudtail_proc:
214 cloudtail_proc.terminate() 224 cloudtail_proc.terminate()
215 cloudtail_proc.wait() 225 cloudtail_proc.wait()
216 226
217 227
218 def maybe_set_official_build_envvars(options, env): 228 def maybe_set_official_build_envvars(options, env):
219 if options.mode == 'google_chrome' or options.mode == 'official': 229 if options.mode == 'google_chrome' or options.mode == 'official':
220 env['CHROMIUM_BUILD'] = '_google_chrome' 230 env['CHROMIUM_BUILD'] = '_google_chrome'
221 231
222 if options.mode == 'official': 232 if options.mode == 'official':
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 exit_status = main_ninja(options, args, env) 541 exit_status = main_ninja(options, args, env)
532 542
533 # stop goma 543 # stop goma
534 goma_teardown(options, env, exit_status, goma_cloudtail) 544 goma_teardown(options, env, exit_status, goma_cloudtail)
535 545
536 return exit_status 546 return exit_status
537 547
538 548
539 if '__main__' == __name__: 549 if '__main__' == __name__:
540 sys.exit(real_main()) 550 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