OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2016 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 """This script takes a Clang revision as an argument, it then | 6 """This script takes a Clang revision as an argument, it then |
7 creates a feature branch, puts this revision into update.py, uploads | 7 creates a feature branch, puts this revision into update.py, uploads |
8 a CL, triggers Clang Upload try bots, and tells what to do next""" | 8 a CL, triggers Clang Upload try bots, and tells what to do next""" |
9 | 9 |
10 import argparse | 10 import argparse |
11 import fnmatch | 11 import fnmatch |
12 import itertools | 12 import itertools |
13 import os | 13 import os |
14 import re | 14 import re |
15 import shutil | 15 import shutil |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 | 18 |
19 # Path constants. | 19 # Path constants. |
20 THIS_DIR = os.path.dirname(__file__) | 20 THIS_DIR = os.path.dirname(__file__) |
21 UPDATE_PY_PATH = os.path.join(THIS_DIR, "update.py") | 21 UPDATE_PY_PATH = os.path.join(THIS_DIR, "update.py") |
22 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) | 22 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) |
23 | 23 |
24 | 24 |
25 def PatchRevision(clang_revision, clang_sub_revision): | 25 def PatchRevision(clang_revision, clang_sub_revision): |
26 with open(UPDATE_PY_PATH, 'r') as f: | 26 with open(UPDATE_PY_PATH, 'r') as f: |
scottmg
2016/09/07 22:02:29
rb here then too?
Nico
2016/09/07 22:06:58
Hm, seems to work as-is as well, but changing it h
| |
27 content = f.read() | 27 content = f.read() |
28 m = re.search("CLANG_REVISION = '([0-9]+)'", content) | 28 m = re.search("CLANG_REVISION = '([0-9]+)'", content) |
29 clang_old_revision = m.group(1) | 29 clang_old_revision = m.group(1) |
30 content = re.sub("CLANG_REVISION = '[0-9]+'", | 30 content = re.sub("CLANG_REVISION = '[0-9]+'", |
31 "CLANG_REVISION = '{}'".format(clang_revision), | 31 "CLANG_REVISION = '{}'".format(clang_revision), |
32 content, count=1) | 32 content, count=1) |
33 content = re.sub("CLANG_SUB_REVISION=[0-9]+", | 33 content = re.sub("CLANG_SUB_REVISION=[0-9]+", |
34 "CLANG_SUB_REVISION={}".format(clang_sub_revision), | 34 "CLANG_SUB_REVISION={}".format(clang_sub_revision), |
35 content, count=1) | 35 content, count=1) |
36 with open(UPDATE_PY_PATH, 'w') as f: | 36 with open(UPDATE_PY_PATH, 'wb') as f: |
37 f.write(content) | 37 f.write(content) |
38 return clang_old_revision | 38 return clang_old_revision |
39 | 39 |
40 | 40 |
41 def Git(args): | 41 def Git(args): |
42 subprocess.check_call(["git"] + args) | 42 is_win = sys.platform.startswith('win32') |
43 # Needs shell=True on Windows due to gn.bat in depot_tools. | |
44 subprocess.check_call(["git"] + args, shell=is_win) | |
43 | 45 |
44 def main(): | 46 def main(): |
45 parser = argparse.ArgumentParser(description='upload new clang revision') | 47 parser = argparse.ArgumentParser(description='upload new clang revision') |
46 parser.add_argument('clang_revision', metavar='CLANG_REVISION', | 48 parser.add_argument('clang_revision', metavar='CLANG_REVISION', |
47 type=int, nargs=1, | 49 type=int, nargs=1, |
48 help='Clang revision to build the toolchain for.') | 50 help='Clang revision to build the toolchain for.') |
49 parser.add_argument('clang_sub_revision', metavar='CLANG_SUB_REVISION', | 51 parser.add_argument('clang_sub_revision', metavar='CLANG_SUB_REVISION', |
50 type=int, nargs='?', default=1, | 52 type=int, nargs='?', default=1, |
51 help='Clang sub-revision to build the toolchain for.') | 53 help='Clang sub-revision to build the toolchain for.') |
52 | 54 |
53 args = parser.parse_args() | 55 args = parser.parse_args() |
54 | 56 |
55 clang_revision = args.clang_revision[0] | 57 clang_revision = args.clang_revision[0] |
56 clang_sub_revision = args.clang_sub_revision | 58 clang_sub_revision = args.clang_sub_revision |
59 is_win = sys.platform.startswith('win32') | |
60 # Needs shell=True on Windows due to gn.bat in depot_tools. | |
57 git_revision = subprocess.check_output( | 61 git_revision = subprocess.check_output( |
58 ["git", "rev-parse", "origin/master"]).strip() | 62 ["git", "rev-parse", "origin/master"], shell=is_win).strip() |
59 print "Making a patch for Clang revision r{}-{}".format( | 63 print "Making a patch for Clang revision r{}-{}".format( |
60 clang_revision, clang_sub_revision) | 64 clang_revision, clang_sub_revision) |
61 print "Chrome revision: {}".format(git_revision) | 65 print "Chrome revision: {}".format(git_revision) |
62 clang_old_revision = PatchRevision(clang_revision, clang_sub_revision) | 66 clang_old_revision = PatchRevision(clang_revision, clang_sub_revision) |
63 | 67 |
64 Git(["checkout", "-b", "clang-{}-{}".format( | 68 Git(["checkout", "-b", "clang-{}-{}".format( |
65 clang_revision, clang_sub_revision)]) | 69 clang_revision, clang_sub_revision)]) |
66 Git(["add", UPDATE_PY_PATH]) | 70 Git(["add", UPDATE_PY_PATH]) |
67 | 71 |
68 commit_message = 'Ran `{}`.'.format(' '.join(sys.argv)) | 72 commit_message = 'Ran `{}`.'.format(' '.join(sys.argv)) |
69 Git(["commit", "-m", "Roll clang {}:{}.\n\n{}".format( | 73 Git(["commit", "-m", "Roll clang {}:{}.\n\n{}".format( |
70 clang_old_revision, clang_revision, commit_message)]) | 74 clang_old_revision, clang_revision, commit_message)]) |
71 | 75 |
72 Git(["cl", "upload"]) | 76 Git(["cl", "upload"]) |
73 Git(["cl", "try", "-b", "linux_upload_clang", "-r", git_revision]) | 77 Git(["cl", "try", "-b", "linux_upload_clang", "-r", git_revision]) |
74 Git(["cl", "try", "-b", "mac_upload_clang", "-r", git_revision]) | 78 Git(["cl", "try", "-b", "mac_upload_clang", "-r", git_revision]) |
75 Git(["cl", "try", "-b", "win_upload_clang", "-r", git_revision]) | 79 Git(["cl", "try", "-b", "win_upload_clang", "-r", git_revision]) |
76 | 80 |
77 print ("Please, wait until the try bots succeeded " | 81 print ("Please, wait until the try bots succeeded " |
78 "and then push the binaries to goma.") | 82 "and then push the binaries to goma.") |
79 | 83 |
80 if __name__ == '__main__': | 84 if __name__ == '__main__': |
81 sys.exit(main()) | 85 sys.exit(main()) |
OLD | NEW |