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

Side by Side Diff: win_toolchain/get_toolchain_if_necessary.py

Issue 185423004: Add toolchain simple mirror option used for bots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: abspath for target Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | win_toolchain/toolchain2013.py » ('j') | 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Downloads and unpacks a toolchain for building on Windows. The contents are 6 """Downloads and unpacks a toolchain for building on Windows. The contents are
7 matched by sha1 which will be updated when the toolchain is updated. 7 matched by sha1 which will be updated when the toolchain is updated.
8 8
9 Having a toolchain script in depot_tools means that it's not versioned 9 Having a toolchain script in depot_tools means that it's not versioned
10 directly with the source code. That is, if the toolchain is upgraded, but 10 directly with the source code. That is, if the toolchain is upgraded, but
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 def main(): 146 def main():
147 if not sys.platform.startswith(('cygwin', 'win32')): 147 if not sys.platform.startswith(('cygwin', 'win32')):
148 return 0 148 return 0
149 149
150 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) 150 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
151 parser.add_option('--output-json', metavar='FILE', 151 parser.add_option('--output-json', metavar='FILE',
152 help='write information about toolchain to FILE') 152 help='write information about toolchain to FILE')
153 options, args = parser.parse_args() 153 options, args = parser.parse_args()
154 154
155 desired_hashes = set(args) 155 # We assume that the Pro hash is the first one.
156 desired_hashes = args
156 157
157 # Move to depot_tools\win_toolchain where we'll store our files, and where 158 # Move to depot_tools\win_toolchain where we'll store our files, and where
158 # the downloader script is. 159 # the downloader script is.
159 os.chdir(os.path.normpath(os.path.join(BASEDIR))) 160 os.chdir(os.path.normpath(os.path.join(BASEDIR)))
160 toolchain_dir = '.' 161 toolchain_dir = '.'
161 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files')) 162 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files'))
162 163
163 # If the current hash doesn't match what we want in the file, nuke and pave. 164 # If the current hash doesn't match what we want in the file, nuke and pave.
164 # Typically this script is only run when the .sha1 one file is updated, but 165 # Typically this script is only run when the .sha1 one file is updated, but
165 # directly calling "gclient runhooks" will also run it, so we cache 166 # directly calling "gclient runhooks" will also run it, so we cache
166 # based on timestamps to make that case fast. 167 # based on timestamps to make that case fast.
167 current_hash = CalculateHash(target_dir) 168 current_hash = CalculateHash(target_dir)
168 if current_hash not in desired_hashes: 169 if current_hash not in desired_hashes:
169 should_get_pro = (os.path.isfile(os.path.join(BASEDIR, '.vspro')) or 170 should_get_pro = (os.path.isfile(os.path.join(BASEDIR, '.vspro')) or
170 HaveSrcInternalAccess()) 171 HaveSrcInternalAccess())
171 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' % 172 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' %
172 ('Pro' if should_get_pro else 'Express')) 173 ('Pro' if should_get_pro else 'Express'))
173 print(' current_hash: %s' % current_hash) 174 print(' current_hash: %s' % current_hash)
174 print(' desired_hashes: %s' % desired_hashes) 175 print(' desired_hashes: %s' % ', '.join(desired_hashes))
175 DelayBeforeRemoving(target_dir) 176 DelayBeforeRemoving(target_dir)
176 # This stays resident and will make the rmdir below fail. 177 # This stays resident and will make the rmdir below fail.
177 with open(os.devnull, 'wb') as nul: 178 with open(os.devnull, 'wb') as nul:
178 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'], 179 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'],
179 stdin=nul, stdout=nul, stderr=nul) 180 stdin=nul, stdout=nul, stderr=nul)
180 if os.path.isdir(target_dir): 181 if os.path.isdir(target_dir):
181 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True) 182 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True)
182 args = [sys.executable, 183 args = [sys.executable,
183 'toolchain2013.py', 184 'toolchain2013.py',
184 '--targetdir', target_dir] 185 '--targetdir', target_dir,
186 '--sha1', desired_hashes[0]]
185 if not should_get_pro: 187 if not should_get_pro:
186 args.append('--express') 188 args.append('--express')
187 subprocess.check_call(args) 189 subprocess.check_call(args)
188 current_hash = CalculateHash(target_dir) 190 current_hash = CalculateHash(target_dir)
189 if current_hash not in desired_hashes: 191 if current_hash not in desired_hashes:
190 print >> sys.stderr, ( 192 print >> sys.stderr, (
191 'Got wrong hash after pulling a new toolchain. ' 193 'Got wrong hash after pulling a new toolchain. '
192 'Wanted one of \'%s\', got \'%s\'.' % ( 194 'Wanted one of \'%s\', got \'%s\'.' % (
193 desired_hashes, current_hash)) 195 ', '.join(desired_hashes), current_hash))
194 return 1 196 return 1
195 SaveTimestampsAndHash(target_dir, current_hash) 197 SaveTimestampsAndHash(target_dir, current_hash)
196 198
197 if options.output_json: 199 if options.output_json:
198 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), 200 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'),
199 options.output_json) 201 options.output_json)
200 202
201 return 0 203 return 0
202 204
203 205
204 if __name__ == '__main__': 206 if __name__ == '__main__':
205 sys.exit(main()) 207 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | win_toolchain/toolchain2013.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698