OLD | NEW |
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 # based on timestamps to make that case fast. | 223 # based on timestamps to make that case fast. |
224 current_hash = CalculateHash(target_dir) | 224 current_hash = CalculateHash(target_dir) |
225 if current_hash not in desired_hashes: | 225 if current_hash not in desired_hashes: |
226 should_use_gs = False | 226 should_use_gs = False |
227 if (HaveSrcInternalAccess() or | 227 if (HaveSrcInternalAccess() or |
228 LooksLikeGoogler() or | 228 LooksLikeGoogler() or |
229 CanAccessToolchainBucket()): | 229 CanAccessToolchainBucket()): |
230 should_use_gs = True | 230 should_use_gs = True |
231 if not CanAccessToolchainBucket(): | 231 if not CanAccessToolchainBucket(): |
232 RequestGsAuthentication() | 232 RequestGsAuthentication() |
233 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' % | 233 if not should_use_gs: |
234 ('Pro' if should_use_gs else 'Express')) | 234 print('Please follow the instructions at ' |
| 235 'http://www.chromium.org/developers/how-tos/' |
| 236 'build-instructions-windows') |
| 237 return 1 |
| 238 print('Windows toolchain out of date or doesn\'t exist, updating (Pro)...') |
235 print(' current_hash: %s' % current_hash) | 239 print(' current_hash: %s' % current_hash) |
236 print(' desired_hashes: %s' % ', '.join(desired_hashes)) | 240 print(' desired_hashes: %s' % ', '.join(desired_hashes)) |
237 sys.stdout.flush() | 241 sys.stdout.flush() |
238 DelayBeforeRemoving(target_dir) | 242 DelayBeforeRemoving(target_dir) |
239 # This stays resident and will make the rmdir below fail. | 243 # This stays resident and will make the rmdir below fail. |
240 with open(os.devnull, 'wb') as nul: | 244 with open(os.devnull, 'wb') as nul: |
241 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'], | 245 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'], |
242 stdin=nul, stdout=nul, stderr=nul) | 246 stdin=nul, stdout=nul, stderr=nul) |
243 if os.path.isdir(target_dir): | 247 if os.path.isdir(target_dir): |
244 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True) | 248 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True) |
245 args = [sys.executable, | 249 args = [sys.executable, |
246 'toolchain2013.py', | 250 'toolchain2013.py', |
247 '--targetdir', target_dir, | 251 '--targetdir', target_dir, |
248 '--sha1', desired_hashes[0]] | 252 '--sha1', desired_hashes[0], |
249 if should_use_gs: | 253 '--use-gs'] |
250 args.append('--use-gs') | |
251 else: | |
252 args.append('--express') | |
253 subprocess.check_call(args) | 254 subprocess.check_call(args) |
254 current_hash = CalculateHash(target_dir) | 255 current_hash = CalculateHash(target_dir) |
255 if current_hash not in desired_hashes: | 256 if current_hash not in desired_hashes: |
256 print >> sys.stderr, ( | 257 print >> sys.stderr, ( |
257 'Got wrong hash after pulling a new toolchain. ' | 258 'Got wrong hash after pulling a new toolchain. ' |
258 'Wanted one of \'%s\', got \'%s\'.' % ( | 259 'Wanted one of \'%s\', got \'%s\'.' % ( |
259 ', '.join(desired_hashes), current_hash)) | 260 ', '.join(desired_hashes), current_hash)) |
260 return 1 | 261 return 1 |
261 SaveTimestampsAndHash(target_dir, current_hash) | 262 SaveTimestampsAndHash(target_dir, current_hash) |
262 | 263 |
263 if options.output_json: | 264 if options.output_json: |
264 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 265 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
265 options.output_json) | 266 options.output_json) |
266 | 267 |
267 return 0 | 268 return 0 |
268 | 269 |
269 | 270 |
270 if __name__ == '__main__': | 271 if __name__ == '__main__': |
271 sys.exit(main()) | 272 sys.exit(main()) |
OLD | NEW |