Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 print("buildtools git cl land failed: %d" % ret) | 295 print("buildtools git cl land failed: %d" % ret) |
| 296 if out: | 296 if out: |
| 297 print(out) | 297 print(out) |
| 298 if err: | 298 if err: |
| 299 print(err) | 299 print(err) |
| 300 return ret | 300 return ret |
| 301 | 301 |
| 302 # 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. |
| 303 self.Call('git fetch', cwd=self.buildtools_dir) | 303 self.Call('git fetch', cwd=self.buildtools_dir) |
| 304 | 304 |
| 305 # Reset buildtools to the new commit so that we're not still on the | |
| 306 # merged branch. | |
| 307 self.Call('git checkout origin/master', cwd=self.buildtools_dir) | |
| 308 | |
| 305 return 0 | 309 return 0 |
| 306 | 310 |
| 307 def RollDEPS(self): | 311 def RollDEPS(self): |
| 308 ret, _, _ = self.Call('git new-branch roll_gn_%s' % self.new_gn_version) | 312 ret, _, _ = self.Call('git new-branch roll_gn_%s' % self.new_gn_version) |
| 309 if ret: | 313 if ret: |
| 310 print('Failed to create a new branch for roll_gn_%s' % | 314 print('Failed to create a new branch for roll_gn_%s' % |
| 311 self.new_gn_version) | 315 self.new_gn_version) |
| 312 return 1 | 316 return 1 |
| 313 | 317 |
| 314 _, out, _ = self.Call('git rev-parse origin/master', | 318 _, out, _ = self.Call('git rev-parse origin/master', |
| 315 cwd=self.buildtools_dir) | 319 cwd=self.buildtools_dir) |
| 316 new_buildtools_commitish = out.strip() | 320 new_buildtools_commitish = out.strip() |
| 317 | 321 |
| 318 new_deps_lines = [] | 322 new_deps_lines = [] |
| 319 old_buildtools_commitish = '' | 323 old_buildtools_commitish = '' |
| 320 with open(os.path.join(self.chromium_src_dir, 'DEPS')) as fp: | 324 with open(os.path.join(self.chromium_src_dir, 'DEPS')) as fp: |
| 321 for l in fp.readlines(): | 325 for l in fp.readlines(): |
| 322 m = re.match(".*'buildtools_revision':.*'(.+)',", l) | 326 m = re.match(".*'buildtools_revision':.*'(.+)',", l) |
| 323 if m: | 327 if m: |
| 324 old_buildtools_commitish = m.group(1) | 328 old_buildtools_commitish = m.group(1) |
| 325 new_deps_lines.append(" 'buildtools_revision': '%s'," % | 329 new_deps_lines.append(" 'buildtools_revision': '%s',\n" % |
| 326 new_buildtools_commitish) | 330 new_buildtools_commitish) |
| 327 else: | 331 else: |
| 328 new_deps_lines.append(l) | 332 new_deps_lines.append(l) |
| 329 | 333 |
| 330 if not old_buildtools_commitish: | 334 if not old_buildtools_commitish: |
| 331 print('Could not update DEPS properly, exiting') | 335 print('Could not update DEPS properly, exiting') |
| 332 return 1 | 336 return 1 |
| 333 | 337 |
| 334 with open('DEPS', 'w') as fp: | 338 with open('DEPS', 'w') as fp: |
| 335 fp.write(''.join(new_deps_lines) + '\n') | 339 fp.write(''.join(new_deps_lines) + '\n') |
| 336 | 340 |
| 337 desc = self.GetDEPSRollDesc(old_buildtools_commitish, | 341 desc = self.GetDEPSRollDesc(old_buildtools_commitish, |
| 338 new_buildtools_commitish) | 342 new_buildtools_commitish) |
| 339 desc_file = tempfile.NamedTemporaryFile(delete=False) | 343 desc_file = tempfile.NamedTemporaryFile(delete=False) |
| 340 try: | 344 try: |
| 341 desc_file.write(desc) | 345 desc_file.write(desc) |
| 342 desc_file.close() | 346 desc_file.close() |
| 343 self.Call('git commit -a -F %s' % desc_file.name) | 347 self.Call('git commit -a -F %s' % desc_file.name) |
| 344 self.Call('git-cl upload -f --send-mail --use-commit-queue') | 348 self.Call('git-cl upload -f --send-mail --use-commit-queue') |
| 345 finally: | 349 finally: |
| 346 os.remove(desc_file.name) | 350 os.remove(desc_file.name) |
| 351 | |
| 352 # Intentionally leave the src checkout on the new branch w/ the roll | |
|
Nico
2015/08/17 21:38:15
s:w/:with
| |
| 353 # since we're not auto-committing it. | |
| 354 | |
| 347 return 0 | 355 return 0 |
| 348 | 356 |
| 349 def GetBuildtoolsDesc(self): | 357 def GetBuildtoolsDesc(self): |
| 350 gn_changes = self.GetGNChanges() | 358 gn_changes = self.GetGNChanges() |
| 351 return ( | 359 return ( |
| 352 'Roll gn %s..%s (r%s:r%s)\n' | 360 'Roll gn %s..%s (r%s:r%s)\n' |
| 353 '\n' | 361 '\n' |
| 354 '%s' | 362 '%s' |
| 355 '\n' | 363 '\n' |
| 356 'TBR=%s\n' % ( | 364 'TBR=%s\n' % ( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 def Call(self, cmd, cwd=None): | 405 def Call(self, cmd, cwd=None): |
| 398 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, | 406 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, |
| 399 cwd=(cwd or self.chromium_src_dir)) | 407 cwd=(cwd or self.chromium_src_dir)) |
| 400 out, err = proc.communicate() | 408 out, err = proc.communicate() |
| 401 return proc.returncode, out, err | 409 return proc.returncode, out, err |
| 402 | 410 |
| 403 | 411 |
| 404 if __name__ == '__main__': | 412 if __name__ == '__main__': |
| 405 roller = GNRoller() | 413 roller = GNRoller() |
| 406 sys.exit(roller.Roll()) | 414 sys.exit(roller.Roll()) |
| OLD | NEW |