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

Side by Side Diff: tools/clang/scripts/upload_revision.py

Issue 2324553003: Try to get clang upload script working on Windows. (Closed)
Patch Set: tweak Created 4 years, 3 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) 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 is_win = sys.platform.startswith('win32')
24 25
25 def PatchRevision(clang_revision, clang_sub_revision): 26 def PatchRevision(clang_revision, clang_sub_revision):
26 with open(UPDATE_PY_PATH, 'r') as f: 27 with open(UPDATE_PY_PATH, 'rb') as f:
27 content = f.read() 28 content = f.read()
28 m = re.search("CLANG_REVISION = '([0-9]+)'", content) 29 m = re.search("CLANG_REVISION = '([0-9]+)'", content)
29 clang_old_revision = m.group(1) 30 clang_old_revision = m.group(1)
30 content = re.sub("CLANG_REVISION = '[0-9]+'", 31 content = re.sub("CLANG_REVISION = '[0-9]+'",
31 "CLANG_REVISION = '{}'".format(clang_revision), 32 "CLANG_REVISION = '{}'".format(clang_revision),
32 content, count=1) 33 content, count=1)
33 content = re.sub("CLANG_SUB_REVISION=[0-9]+", 34 content = re.sub("CLANG_SUB_REVISION=[0-9]+",
34 "CLANG_SUB_REVISION={}".format(clang_sub_revision), 35 "CLANG_SUB_REVISION={}".format(clang_sub_revision),
35 content, count=1) 36 content, count=1)
36 with open(UPDATE_PY_PATH, 'w') as f: 37 with open(UPDATE_PY_PATH, 'wb') as f:
37 f.write(content) 38 f.write(content)
38 return clang_old_revision 39 return clang_old_revision
39 40
40 41
41 def Git(args): 42 def Git(args):
42 subprocess.check_call(["git"] + args) 43 # Needs shell=True on Windows due to git.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 # Needs shell=True on Windows due to git.bat in depot_tools.
57 git_revision = subprocess.check_output( 60 git_revision = subprocess.check_output(
58 ["git", "rev-parse", "origin/master"]).strip() 61 ["git", "rev-parse", "origin/master"], shell=is_win).strip()
59 print "Making a patch for Clang revision r{}-{}".format( 62 print "Making a patch for Clang revision r{}-{}".format(
60 clang_revision, clang_sub_revision) 63 clang_revision, clang_sub_revision)
61 print "Chrome revision: {}".format(git_revision) 64 print "Chrome revision: {}".format(git_revision)
62 clang_old_revision = PatchRevision(clang_revision, clang_sub_revision) 65 clang_old_revision = PatchRevision(clang_revision, clang_sub_revision)
63 66
64 Git(["checkout", "-b", "clang-{}-{}".format( 67 Git(["checkout", "-b", "clang-{}-{}".format(
65 clang_revision, clang_sub_revision)]) 68 clang_revision, clang_sub_revision)])
66 Git(["add", UPDATE_PY_PATH]) 69 Git(["add", UPDATE_PY_PATH])
67 70
68 commit_message = 'Ran `{}`.'.format(' '.join(sys.argv)) 71 commit_message = 'Ran `{}`.'.format(' '.join(sys.argv))
69 Git(["commit", "-m", "Roll clang {}:{}.\n\n{}".format( 72 Git(["commit", "-m", "Roll clang {}:{}.\n\n{}".format(
70 clang_old_revision, clang_revision, commit_message)]) 73 clang_old_revision, clang_revision, commit_message)])
71 74
72 Git(["cl", "upload"]) 75 Git(["cl", "upload"])
73 Git(["cl", "try", "-b", "linux_upload_clang", "-r", git_revision]) 76 Git(["cl", "try", "-b", "linux_upload_clang", "-r", git_revision])
74 Git(["cl", "try", "-b", "mac_upload_clang", "-r", git_revision]) 77 Git(["cl", "try", "-b", "mac_upload_clang", "-r", git_revision])
75 Git(["cl", "try", "-b", "win_upload_clang", "-r", git_revision]) 78 Git(["cl", "try", "-b", "win_upload_clang", "-r", git_revision])
76 79
77 print ("Please, wait until the try bots succeeded " 80 print ("Please, wait until the try bots succeeded "
78 "and then push the binaries to goma.") 81 "and then push the binaries to goma.")
79 82
80 if __name__ == '__main__': 83 if __name__ == '__main__':
81 sys.exit(main()) 84 sys.exit(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