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

Side by Side Diff: tools/gn/bin/roll_gn.py

Issue 1255253004: Fix various typos, error handling for GN auto-roller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """An auto-roller for GN binaries into Chromium. 5 """An auto-roller for GN binaries into Chromium.
6 6
7 This script is used to update the GN binaries that a Chromium 7 This script is used to update the GN binaries that a Chromium
8 checkout uses. In order to update the binaries, one must follow 8 checkout uses. In order to update the binaries, one must follow
9 four steps in order: 9 four steps in order:
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if not third_party_path in sys.path: 54 if not third_party_path in sys.path:
55 sys.path.insert(0, third_party_path) 55 sys.path.insert(0, third_party_path)
56 56
57 import upload 57 import upload
58 58
59 59
60 CHROMIUM_REPO = 'https://chromium.googlesource.com/chromium/src.git' 60 CHROMIUM_REPO = 'https://chromium.googlesource.com/chromium/src.git'
61 61
62 CODE_REVIEW_SERVER = 'https://codereview.chromium.org' 62 CODE_REVIEW_SERVER = 'https://codereview.chromium.org'
63 63
64 COMMITISH_DIGITS = 10
64 65
65 class GNRoller(object): 66 class GNRoller(object):
66 def __init__(self): 67 def __init__(self):
67 self.chromium_src_dir = None 68 self.chromium_src_dir = None
68 self.buildtools_dir = None 69 self.buildtools_dir = None
69 self.old_gn_commitish = None 70 self.old_gn_commitish = None
70 self.new_gn_commitish = None 71 self.new_gn_commitish = None
71 self.old_gn_version = None 72 self.old_gn_version = None
72 self.new_gn_version = None 73 self.new_gn_version = None
73 self.reviewer = 'dpranke@chromium.org' 74 self.reviewer = 'dpranke@chromium.org'
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return 1 153 return 1
153 154
154 print('Uploading CL to build GN at {#%s} - %s' % 155 print('Uploading CL to build GN at {#%s} - %s' %
155 (self.new_gn_version, self.new_gn_commitish)) 156 (self.new_gn_version, self.new_gn_commitish))
156 ret, out, err = self.Call('git cl upload -f') 157 ret, out, err = self.Call('git cl upload -f')
157 if ret: 158 if ret:
158 print('git-cl upload failed: %s' % out + err) 159 print('git-cl upload failed: %s' % out + err)
159 return 1 160 return 1
160 161
161 print('Starting try jobs') 162 print('Starting try jobs')
162 self.Call('git-cl try -b linux_chromium_gn_upload ' 163 self.Call('git-cl try -m tryserver.chromium.linux '
163 '-b mac_chromium_gn_upload ' 164 '-b linux_chromium_gn_upload -r %s' % self.new_gn_commitish)
165 self.Call('git-cl try -m tryserver.chromium.mac '
166 '-b mac_chromium_gn_upload -r %s' % self.new_gn_commitish)
167 self.Call('git-cl try -m tryserver.chromium.win '
164 '-b win8_chromium_gn_upload -r %s' % self.new_gn_commitish) 168 '-b win8_chromium_gn_upload -r %s' % self.new_gn_commitish)
165 169
166 return 0 170 return 0
167 171
168 def MakeDummyDepsChange(self): 172 def MakeDummyDepsChange(self):
169 with open('DEPS') as fp: 173 with open('DEPS') as fp:
170 deps_content = fp.read() 174 deps_content = fp.read()
171 new_deps = deps_content.replace("'buildtools_revision':", 175 new_deps = deps_content.replace("'buildtools_revision':",
172 "'buildtools_revision': ") 176 "'buildtools_revision': ")
173 177
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 try: 283 try:
280 desc_file.write(desc) 284 desc_file.write(desc)
281 desc_file.close() 285 desc_file.close()
282 self.Call('git commit -a -F %s' % desc_file.name, 286 self.Call('git commit -a -F %s' % desc_file.name,
283 cwd=self.buildtools_dir) 287 cwd=self.buildtools_dir)
284 self.Call('git-cl upload -f --send-mail', 288 self.Call('git-cl upload -f --send-mail',
285 cwd=self.buildtools_dir) 289 cwd=self.buildtools_dir)
286 finally: 290 finally:
287 os.remove(desc_file.name) 291 os.remove(desc_file.name)
288 292
289 self.Call('git cl push', cwd=self.buildtools_dir) 293 ret, out, err = self.Call('git cl land', cwd=self.buildtools_dir)
294 if ret:
295 print("buildtools git cl land failed: %d" % ret)
296 if out:
297 print(out)
298 if err:
299 print(err)
300 return ret
290 301
291 # Fetch the revision we just committed so that RollDEPS will find it. 302 # Fetch the revision we just committed so that RollDEPS will find it.
292 self.Call('git cl fetch', cwd=self.buildtools_dir) 303 self.Call('git fetch', cwd=self.buildtools_dir)
293 304
294 return 0 305 return 0
295 306
296 def RollDEPS(self): 307 def RollDEPS(self):
308 ret, _, _ = self.Call('git new-branch roll_gn_%s' % self.new_gn_version)
309 if ret:
310 print('Failed to create a new branch for roll_gn_%s' %
311 self.new_gn_version)
312 return 1
313
297 _, out, _ = self.Call('git rev-parse origin/master', 314 _, out, _ = self.Call('git rev-parse origin/master',
298 cwd=self.buildtools_dir) 315 cwd=self.buildtools_dir)
299 new_buildtools_commitish = out.strip() 316 new_buildtools_commitish = out.strip()
300 317
301 new_deps_lines = [] 318 new_deps_lines = []
302 old_buildtools_commitish = '' 319 old_buildtools_commitish = ''
303 with open(os.path.join(self.chromium_src_dir, 'DEPS')) as fp: 320 with open(os.path.join(self.chromium_src_dir, 'DEPS')) as fp:
304 for l in fp.readlines(): 321 for l in fp.readlines():
305 m = re.match(".*'buildtools_revision':.*'(.+)',", l) 322 m = re.match(".*'buildtools_revision':.*'(.+)',", l)
306 if m: 323 if m:
(...skipping 10 matching lines...) Expand all
317 with open('DEPS', 'w') as fp: 334 with open('DEPS', 'w') as fp:
318 fp.write(''.join(new_deps_lines) + '\n') 335 fp.write(''.join(new_deps_lines) + '\n')
319 336
320 desc = self.GetDEPSRollDesc(old_buildtools_commitish, 337 desc = self.GetDEPSRollDesc(old_buildtools_commitish,
321 new_buildtools_commitish) 338 new_buildtools_commitish)
322 desc_file = tempfile.NamedTemporaryFile(delete=False) 339 desc_file = tempfile.NamedTemporaryFile(delete=False)
323 try: 340 try:
324 desc_file.write(desc) 341 desc_file.write(desc)
325 desc_file.close() 342 desc_file.close()
326 self.Call('git commit -a -F %s' % desc_file.name) 343 self.Call('git commit -a -F %s' % desc_file.name)
327 self.Call('git-cl upload -f --send-mail --commit-queue') 344 self.Call('git-cl upload -f --send-mail --use-commit-queue')
328 finally: 345 finally:
329 os.remove(desc_file.name) 346 os.remove(desc_file.name)
330 return 0 347 return 0
331 348
332 def GetBuildtoolsDesc(self): 349 def GetBuildtoolsDesc(self):
333 gn_changes = self.GetGNChanges() 350 gn_changes = self.GetGNChanges()
334 return ( 351 return (
335 'Roll gn %s..%s (r%s:%s)\n' 352 'Roll gn %s..%s (r%s:r%s)\n'
336 '\n' 353 '\n'
337 '%s' 354 '%s'
338 '\n' 355 '\n'
339 'TBR=%s\n' % ( 356 'TBR=%s\n' % (
340 self.old_gn_commitish, 357 self.old_gn_commitish[:COMMITISH_DIGITS],
341 self.new_gn_commitish, 358 self.new_gn_commitish[:COMMITISH_DIGITS],
342 self.old_gn_version, 359 self.old_gn_version,
343 self.new_gn_version, 360 self.new_gn_version,
344 gn_changes, 361 gn_changes,
345 self.reviewer, 362 self.reviewer,
346 )) 363 ))
347 364
348 def GetDEPSRollDesc(self, old_buildtools_commitish, new_buildtools_commitish): 365 def GetDEPSRollDesc(self, old_buildtools_commitish, new_buildtools_commitish):
349 gn_changes = self.GetGNChanges() 366 gn_changes = self.GetGNChanges()
350 367
351 return ( 368 return (
352 'Roll DEPS %s..%s\n' 369 'Roll DEPS %s..%s\n'
353 '\n' 370 '\n'
354 ' in order to roll GN %s..%s (r%s:%s)\n' 371 ' In order to roll GN %s..%s (r%s:r%s) and pick up\n'
372 ' the following changes:\n'
355 '\n' 373 '\n'
356 '%s' 374 '%s'
357 '\n' 375 '\n'
358 'TBR=%s\n' 376 'TBR=%s\n'
359 'CQ_EXTRA_TRYBOTS=tryserver.chromium.mac:mac_chromium_gn_rel,' 377 'CQ_EXTRA_TRYBOTS=tryserver.chromium.mac:mac_chromium_gn_rel,'
360 'mac_chromium_gn_dbg;' 378 'mac_chromium_gn_dbg;'
361 'tryserver.chromium.win:win8_chromium_gn_dbg,' 379 'tryserver.chromium.win:win8_chromium_gn_dbg,'
362 'win_chromium_gn_x64_rel\n' % ( 380 'win_chromium_gn_x64_rel\n' % (
363 old_buildtools_commitish, 381 old_buildtools_commitish[:COMMITISH_DIGITS],
364 new_buildtools_commitish, 382 new_buildtools_commitish[:COMMITISH_DIGITS],
365 self.old_gn_commitish, 383 self.old_gn_commitish[:COMMITISH_DIGITS],
366 self.new_gn_commitish, 384 self.new_gn_commitish[:COMMITISH_DIGITS],
367 self.old_gn_version, 385 self.old_gn_version,
368 self.new_gn_version, 386 self.new_gn_version,
369 gn_changes, 387 gn_changes,
370 self.reviewer, 388 self.reviewer,
371 )) 389 ))
372 390
373 def GetGNChanges(self): 391 def GetGNChanges(self):
374 _, out, _ = self.Call( 392 _, out, _ = self.Call(
375 "git log --pretty=' %h %s' " + 393 "git log --pretty=' %h %s' " +
376 "%s..%s tools/gn" % (self.old_gn_commitish, self.new_gn_commitish)) 394 "%s..%s tools/gn" % (self.old_gn_commitish, self.new_gn_commitish))
377 return out 395 return out
378 396
379 def Call(self, cmd, cwd=None): 397 def Call(self, cmd, cwd=None):
380 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, 398 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
381 cwd=(cwd or self.chromium_src_dir)) 399 cwd=(cwd or self.chromium_src_dir))
382 out, err = proc.communicate() 400 out, err = proc.communicate()
383 return proc.returncode, out, err 401 return proc.returncode, out, err
384 402
385 403
386 if __name__ == '__main__': 404 if __name__ == '__main__':
387 roller = GNRoller() 405 roller = GNRoller()
388 sys.exit(roller.Roll()) 406 sys.exit(roller.Roll())
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