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 """Extracts a Windows VS2013 toolchain from various downloadable pieces.""" | 6 """Extracts a Windows VS2013 toolchain from various downloadable pieces.""" |
7 | 7 |
8 | 8 |
9 import ctypes | 9 import ctypes |
10 import json | 10 import json |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 class SourceImages(object): | 242 class SourceImages(object): |
243 """Local paths for components. |wdk_path| may be None if it's unnecessary for | 243 """Local paths for components. |wdk_path| may be None if it's unnecessary for |
244 the given configuration.""" | 244 the given configuration.""" |
245 def __init__(self, vs_path, sdk8_path, wdk_path): | 245 def __init__(self, vs_path, sdk8_path, wdk_path): |
246 self.vs_path = vs_path | 246 self.vs_path = vs_path |
247 self.sdk8_path = sdk8_path | 247 self.sdk8_path = sdk8_path |
248 self.wdk_path = wdk_path | 248 self.wdk_path = wdk_path |
249 | 249 |
250 | 250 |
251 def GetSourceImages(local_dir, pro, bot_mode): | 251 def GetSourceImages(local_dir, pro): |
252 """Downloads the various sources that we need. | 252 """Downloads the various sources that we need. |
253 | 253 |
254 Of note: Because Express does not include ATL, there's an additional download | 254 Of note: Because Express does not include ATL, there's an additional download |
255 of the 7.1 WDK which is the latest publically accessible source for ATL. When | 255 of the 7.1 WDK which is the latest publically accessible source for ATL. When |
256 |pro| this is not necessary (and CHROME_HEADLESS always implies Pro). | 256 |pro| this is not necessary (and CHROME_HEADLESS always implies Pro). |
257 """ | 257 """ |
258 url = GetMainIsoUrl(pro) | 258 url = GetMainIsoUrl(pro) |
259 if bot_mode: | 259 if local_dir: |
260 return SourceImages(GetVSInternal(), GetSDKInternal(), wdk_path=None) | |
261 elif local_dir: | |
262 wdk_path = (os.path.join(local_dir, os.path.basename(WDK_ISO_URL)) | 260 wdk_path = (os.path.join(local_dir, os.path.basename(WDK_ISO_URL)) |
263 if not pro else None) | 261 if not pro else None) |
264 return SourceImages(os.path.join(local_dir, os.path.basename(url)), | 262 return SourceImages(os.path.join(local_dir, os.path.basename(url)), |
265 os.path.join(local_dir, 'Standalone'), | 263 os.path.join(local_dir, 'Standalone'), |
266 wdk_path=wdk_path) | 264 wdk_path=wdk_path) |
267 else: | 265 else: |
268 # Note that we do the SDK first, as it might cause an elevation prompt. | 266 # Note that we do the SDK first, as it might cause an elevation prompt. |
269 sdk8_path = DownloadSDK8() | 267 sdk8_path = DownloadSDK8() |
270 vs_path = DownloadMainIso(url) | 268 vs_path = DownloadMainIso(url) |
271 wdk_path = DownloadWDKIso() if not pro else None | 269 wdk_path = DownloadWDKIso() if not pro else None |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 # x64 native. | 416 # x64 native. |
419 f.write(':x64\n' | 417 f.write(':x64\n' |
420 'set PATH=%~dp0..\\..\\win8sdk\\bin\\x64;' | 418 'set PATH=%~dp0..\\..\\win8sdk\\bin\\x64;' |
421 '%~dp0..\\..\\VC\\bin\\amd64;' | 419 '%~dp0..\\..\\VC\\bin\\amd64;' |
422 '%PATH%\n') | 420 '%PATH%\n') |
423 f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;' | 421 f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;' |
424 '%~dp0..\\..\\win8sdk\\Lib\\win8\\um\\x64;' | 422 '%~dp0..\\..\\win8sdk\\Lib\\win8\\um\\x64;' |
425 '%~dp0..\\..\\VC\\atlmfc\\lib\\amd64\n') | 423 '%~dp0..\\..\\VC\\atlmfc\\lib\\amd64\n') |
426 | 424 |
427 | 425 |
| 426 def DoTreeMirror(target_dir, tree_sha1): |
| 427 """In order to save temporary space on bots that do not have enough space to |
| 428 download ISOs, unpack them, and copy to the target location, the whole tree |
| 429 is uploaded as a zip to internal storage, and then mirrored here.""" |
| 430 local_zip = DownloadUsingGsutil(tree_sha1 + '.zip') |
| 431 sys.stdout.write('Extracting %s...\n' % local_zip) |
| 432 sys.stdout.flush() |
| 433 RunOrDie('7z x "%s" -y "-o%s" >nul' % (local_zip, target_dir)) |
| 434 |
| 435 |
428 def main(): | 436 def main(): |
429 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 437 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
430 parser.add_option('--targetdir', metavar='DIR', | 438 parser.add_option('--targetdir', metavar='DIR', |
431 help='put toolchain into DIR', | 439 help='put toolchain into DIR', |
432 default=os.path.join(BASEDIR, 'win_toolchain_2013')) | 440 default=os.path.join(BASEDIR, 'win_toolchain_2013')) |
433 parser.add_option('--noclean', action='store_false', dest='clean', | 441 parser.add_option('--noclean', action='store_false', dest='clean', |
434 help='do not remove temp files', | 442 help='do not remove temp files', |
435 default=True) | 443 default=True) |
436 parser.add_option('--local', metavar='DIR', | 444 parser.add_option('--local', metavar='DIR', |
437 help='use downloaded files from DIR') | 445 help='use downloaded files from DIR') |
438 parser.add_option('--express', | 446 parser.add_option('--express', |
439 help='use VS Express instead of Pro', action='store_true') | 447 help='use VS Express instead of Pro', action='store_true') |
| 448 parser.add_option('--sha1', |
| 449 help='tree sha1 that can be used to mirror an internal ' |
| 450 'copy (used if --bot-mode)') |
440 parser.add_option('--bot-mode', | 451 parser.add_option('--bot-mode', |
441 help='Use internal servers to pull isos', | 452 help='Use internal servers to pull isos', |
442 default=bool(int(os.environ.get('CHROME_HEADLESS', 0))), | 453 default=bool(int(os.environ.get('CHROME_HEADLESS', 0))), |
443 action='store_true') | 454 action='store_true') |
444 options, _ = parser.parse_args() | 455 options, _ = parser.parse_args() |
445 try: | 456 try: |
446 target_dir = os.path.abspath(options.targetdir) | 457 target_dir = os.path.abspath(options.targetdir) |
447 if os.path.exists(target_dir): | 458 if os.path.exists(target_dir): |
448 parser.error('%s already exists. Please [re]move it or use ' | 459 parser.error('%s already exists. Please [re]move it or use ' |
449 '--targetdir to select a different target.\n' % | 460 '--targetdir to select a different target.\n' % |
450 target_dir) | 461 target_dir) |
451 # Set the working directory to 7z subdirectory. 7-zip doesn't find its | 462 # Set the working directory to 7z subdirectory. 7-zip doesn't find its |
452 # codec dll very well, so this is the simplest way to make sure it runs | 463 # codec dll very well, so this is the simplest way to make sure it runs |
453 # correctly, as we don't otherwise care about working directory. | 464 # correctly, as we don't otherwise care about working directory. |
454 os.chdir(os.path.join(BASEDIR, '7z')) | 465 os.chdir(os.path.join(BASEDIR, '7z')) |
455 images = GetSourceImages( | 466 if options.bot_mode and options.sha1: |
456 options.local, not options.express, options.bot_mode) | 467 DoTreeMirror(target_dir, options.sha1) |
457 extracted = ExtractComponents(images) | 468 else: |
458 CopyToFinalLocation(extracted, target_dir) | 469 images = GetSourceImages(options.local, not options.express) |
| 470 extracted = ExtractComponents(images) |
| 471 CopyToFinalLocation(extracted, target_dir) |
| 472 GenerateSetEnvCmd(target_dir, not options.express) |
459 | 473 |
460 GenerateSetEnvCmd(target_dir, not options.express) | |
461 data = { | 474 data = { |
462 'path': target_dir, | 475 'path': target_dir, |
463 'version': '2013e' if options.express else '2013', | 476 'version': '2013e' if options.express else '2013', |
464 'win8sdk': os.path.join(target_dir, 'win8sdk'), | 477 'win8sdk': os.path.join(target_dir, 'win8sdk'), |
465 'wdk': os.path.join(target_dir, 'wdk'), | 478 'wdk': os.path.join(target_dir, 'wdk'), |
466 'runtime_dirs': [ | 479 'runtime_dirs': [ |
467 os.path.join(target_dir, 'sys64'), | 480 os.path.join(target_dir, 'sys64'), |
468 os.path.join(target_dir, 'sys32'), | 481 os.path.join(target_dir, 'sys32'), |
469 ], | 482 ], |
470 } | 483 } |
471 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: | 484 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: |
472 json.dump(data, f) | 485 json.dump(data, f) |
473 finally: | 486 finally: |
474 if options.clean: | 487 if options.clean: |
475 DeleteAllTempDirs() | 488 DeleteAllTempDirs() |
476 | 489 |
477 | 490 |
478 if __name__ == '__main__': | 491 if __name__ == '__main__': |
479 sys.exit(main()) | 492 sys.exit(main()) |
OLD | NEW |