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

Side by Side Diff: tools/blink_rename_merge_helper/run.py

Issue 2798293003: blink_rename_merge_helper: roll clang tool binaries in COMPONENTS (Closed)
Patch Set: Add Darwin too. Created 3 years, 8 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 | « tools/blink_rename_merge_helper/pylib/blink_rename_merge_helper/driver.py ('k') | 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 2017 The Chromium Authors. All rights reserved. 2 # Copyright 2017 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 """Tool to help developers rebase branches across the Blink rename.""" 5 """Tool to help developers rebase branches across the Blink rename."""
6 6
7 import argparse
7 import json 8 import json
8 import os 9 import os
9 import subprocess 10 import subprocess
10 import shutil 11 import shutil
11 import sys 12 import sys
12 import tempfile 13 import tempfile
13 14
14 15
15 class _DepotToolsNotFoundException(Exception): 16 class _DepotToolsNotFoundException(Exception):
16 pass 17 pass
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 % (path, path2)) 72 % (path, path2))
72 73
73 return DepotToolsWrapper(path) 74 return DepotToolsWrapper(path)
74 75
75 76
76 class Bootstrapper(object): 77 class Bootstrapper(object):
77 """Helper class for bootstrapping startup of the rebase helper. 78 """Helper class for bootstrapping startup of the rebase helper.
78 79
79 Performs update checks and stages any required binaries.""" 80 Performs update checks and stages any required binaries."""
80 81
81 def __init__(self, depot_tools): 82 def __init__(self, depot_tools, components_path_override):
82 """Bootstrapper constructor. 83 """Bootstrapper constructor.
83 84
84 Args: 85 Args:
85 depot_tools: a wrapper for invoking depot_tools. 86 depot_tools: a wrapper for invoking depot_tools.
87 components_path_override: If set, used as the path for the COMPONENTS file
88 rather than using the copy in the Google Storage bucket.
86 """ 89 """
87 self.__depot_tools = depot_tools 90 self.__depot_tools = depot_tools
91 self.__components_path_override = components_path_override
88 self.__tmpdir = None 92 self.__tmpdir = None
89 93
90 def __enter__(self): 94 def __enter__(self):
91 self.__tmpdir = tempfile.mkdtemp() 95 self.__tmpdir = tempfile.mkdtemp()
92 return self 96 return self
93 97
94 def __exit__(self, exc_type, exc_value, traceback): 98 def __exit__(self, exc_type, exc_value, traceback):
95 shutil.rmtree(self.__tmpdir, ignore_errors=True) 99 shutil.rmtree(self.__tmpdir, ignore_errors=True)
96 100
97 def update(self): 101 def update(self):
98 """Performs an update check for various components.""" 102 """Performs an update check for various components."""
99 components = self._get_latest_components() 103 components = self._get_latest_components()
100 for name, sha1_hash in components.iteritems(): 104 for name, sha1_hash in components.iteritems():
101 args = [ 105 args = [
102 '--no_auth', '--no_resume', '-b', 'chromium-blink-rename', 106 '--no_auth', '--no_resume', '-b', 'chromium-blink-rename',
103 '--extract', sha1_hash 107 '--extract', sha1_hash
104 ] 108 ]
105 if '-' in name: 109 if '-' in name:
106 name, platform = name.split('-', 1) 110 name, platform = name.split('-', 1)
107 args.append('-p') 111 args.append('-p')
108 args.append(platform) 112 args.append(platform)
109 args.append('-o') 113 args.append('-o')
110 args.append(os.path.join('staging', '%s.tar.gz' % name)) 114 args.append(os.path.join('staging', '%s.tar.gz' % name))
111 self.__depot_tools.call_download_from_google_storage(*args) 115 self.__depot_tools.call_download_from_google_storage(*args)
112 116
113 def _get_latest_components(self): 117 def _get_latest_components(self):
114 """Fetches info about the latest components from google storage. 118 """Fetches info about the latest components from google storage.
115 119
116 The return value should be a dict of component names to SHA1 hashes.""" 120 The return value should be a dict of component names to SHA1 hashes."""
117 hashes_path = os.path.join(self.__tmpdir, 'COMPONENTS') 121 components_path = self.__components_path_override
118 self.__depot_tools.call_gsutil( 122 if not components_path:
119 'cp', 'gs://chromium-blink-rename/COMPONENTS', hashes_path) 123 components_path = os.path.join(self.__tmpdir, 'COMPONENTS')
120 with open(hashes_path) as f: 124 self.__depot_tools.call_gsutil(
125 'cp', 'gs://chromium-blink-rename/COMPONENTS', components_path)
126 with open(components_path) as f:
121 return json.loads(f.read()) 127 return json.loads(f.read())
122 128
123 129
124 def main(): 130 def main():
131 # Intentionally suppress help. These are internal testing flags.
132 parser = argparse.ArgumentParser(add_help=False)
133 parser.add_argument('--components-file')
134 args, remaining_argv = parser.parse_known_args()
135
125 script_dir = os.path.dirname(os.path.realpath(__file__)) 136 script_dir = os.path.dirname(os.path.realpath(__file__))
126 os.chdir(script_dir) 137 os.chdir(script_dir)
127 138
128 try: 139 try:
129 depot_tools = _find_depot_tools() 140 depot_tools = _find_depot_tools()
130 except _DepotToolsNotFoundException as e: 141 except _DepotToolsNotFoundException as e:
131 print e.message 142 print e.message
132 return 1 143 return 1
133 144
134 print 'Checking for updates...' 145 print 'Checking for updates...'
135 with Bootstrapper(depot_tools) as bootstrapper: 146 with Bootstrapper(depot_tools, args.components_file) as bootstrapper:
136 bootstrapper.update() 147 bootstrapper.update()
137 148
138 # Import stage 2 and launch it. 149 # Import stage 2 and launch it.
139 tool_pylib = os.path.abspath(os.path.join(script_dir, 'staging/pylib')) 150 tool_pylib = os.path.abspath(os.path.join(script_dir, 'staging/pylib'))
140 sys.path.insert(0, tool_pylib) 151 sys.path.insert(0, tool_pylib)
141 from blink_rename_merge_helper import driver 152 from blink_rename_merge_helper import driver
153 # Note: for compatibility with older versions of run.py, set sys.argv to the
154 # unconsumed args.
155 sys.argv = sys.argv[:1] + remaining_argv
142 driver.run() 156 driver.run()
143 157
144 158
145 if __name__ == '__main__': 159 if __name__ == '__main__':
146 sys.exit(main()) 160 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/blink_rename_merge_helper/pylib/blink_rename_merge_helper/driver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698