| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 sys.stdout.write('Cleaning up temporaries...\n') | 99 sys.stdout.write('Cleaning up temporaries...\n') |
| 100 for temp in g_temp_dirs: | 100 for temp in g_temp_dirs: |
| 101 # shutil.rmtree errors out on read only attributes. | 101 # shutil.rmtree errors out on read only attributes. |
| 102 RunOrDie('rmdir /s/q "%s"' % temp) | 102 RunOrDie('rmdir /s/q "%s"' % temp) |
| 103 g_temp_dirs = [] | 103 g_temp_dirs = [] |
| 104 | 104 |
| 105 | 105 |
| 106 def GetMainIsoUrl(pro): | 106 def GetMainIsoUrl(pro): |
| 107 """Gets the main .iso URL. | 107 """Gets the main .iso URL. |
| 108 | 108 |
| 109 If |pro| is False, downloads the Express edition. If |CHROME_HEADLESS| is | 109 If |pro| is False, downloads the Express edition. |
| 110 set in the environment, then we assume we're on an internal bot, and download | |
| 111 from internal google storage instead. | |
| 112 """ | 110 """ |
| 113 prefix = 'http://download.microsoft.com/download/' | 111 prefix = 'http://download.microsoft.com/download/' |
| 114 if pro: | 112 if pro: |
| 115 return (prefix + | 113 return (prefix + |
| 116 'A/F/1/AF128362-A6A8-4DB3-A39A-C348086472CC/VS2013_RTM_PRO_ENU.iso') | 114 'A/F/1/AF128362-A6A8-4DB3-A39A-C348086472CC/VS2013_RTM_PRO_ENU.iso') |
| 117 else: | 115 else: |
| 118 return (prefix + | 116 return (prefix + |
| 119 '7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/VS2013_RTM_DskExp_ENU.iso') | 117 '7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/VS2013_RTM_DskExp_ENU.iso') |
| 120 | 118 |
| 121 | 119 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 self.wdk_path = wdk_path | 247 self.wdk_path = wdk_path |
| 250 | 248 |
| 251 | 249 |
| 252 def GetSourceImages(local_dir, pro): | 250 def GetSourceImages(local_dir, pro): |
| 253 """Downloads the various sources that we need. | 251 """Downloads the various sources that we need. |
| 254 | 252 |
| 255 Of note: Because Express does not include ATL, there's an additional download | 253 Of note: Because Express does not include ATL, there's an additional download |
| 256 of the 7.1 WDK which is the latest publically accessible source for ATL. When | 254 of the 7.1 WDK which is the latest publically accessible source for ATL. When |
| 257 |pro| this is not necessary (and CHROME_HEADLESS always implies Pro). | 255 |pro| this is not necessary (and CHROME_HEADLESS always implies Pro). |
| 258 """ | 256 """ |
| 257 if pro and not local_dir: |
| 258 sys.exit('Non-Express must be used with --local') |
| 259 url = GetMainIsoUrl(pro) | 259 url = GetMainIsoUrl(pro) |
| 260 if local_dir: | 260 if local_dir: |
| 261 wdk_path = (os.path.join(local_dir, os.path.basename(WDK_ISO_URL)) | 261 wdk_path = (os.path.join(local_dir, os.path.basename(WDK_ISO_URL)) |
| 262 if not pro else None) | 262 if not pro else None) |
| 263 return SourceImages(os.path.join(local_dir, os.path.basename(url)), | 263 return SourceImages(os.path.join(local_dir, os.path.basename(url)), |
| 264 os.path.join(local_dir, 'Standalone'), | 264 os.path.join(local_dir, 'Standalone'), |
| 265 wdk_path=wdk_path) | 265 wdk_path=wdk_path) |
| 266 else: | 266 else: |
| 267 # Note that we do the SDK first, as it might cause an elevation prompt. | 267 # Note that we do the SDK first, as it might cause an elevation prompt. |
| 268 sdk8_path = DownloadSDK8() | 268 sdk8_path = DownloadSDK8() |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 default=os.path.join(BASEDIR, 'win_toolchain_2013')) | 441 default=os.path.join(BASEDIR, 'win_toolchain_2013')) |
| 442 parser.add_option('--noclean', action='store_false', dest='clean', | 442 parser.add_option('--noclean', action='store_false', dest='clean', |
| 443 help='do not remove temp files', | 443 help='do not remove temp files', |
| 444 default=True) | 444 default=True) |
| 445 parser.add_option('--local', metavar='DIR', | 445 parser.add_option('--local', metavar='DIR', |
| 446 help='use downloaded files from DIR') | 446 help='use downloaded files from DIR') |
| 447 parser.add_option('--express', | 447 parser.add_option('--express', |
| 448 help='use VS Express instead of Pro', action='store_true') | 448 help='use VS Express instead of Pro', action='store_true') |
| 449 parser.add_option('--sha1', | 449 parser.add_option('--sha1', |
| 450 help='tree sha1 that can be used to mirror an internal ' | 450 help='tree sha1 that can be used to mirror an internal ' |
| 451 'copy (used if --bot-mode)') | 451 'copy (used if --use-gs)') |
| 452 parser.add_option('--bot-mode', | 452 parser.add_option('--use-gs', |
| 453 help='Use internal servers to pull isos', | 453 help='Use internal servers to pull isos', |
| 454 default=bool(int(os.environ.get('CHROME_HEADLESS', 0))), | 454 default=bool(int(os.environ.get('CHROME_HEADLESS', 0))), |
| 455 action='store_true') | 455 action='store_true') |
| 456 options, _ = parser.parse_args() | 456 options, _ = parser.parse_args() |
| 457 try: | 457 try: |
| 458 target_dir = os.path.abspath(options.targetdir) | 458 target_dir = os.path.abspath(options.targetdir) |
| 459 if os.path.exists(target_dir): | 459 if os.path.exists(target_dir): |
| 460 parser.error('%s already exists. Please [re]move it or use ' | 460 parser.error('%s already exists. Please [re]move it or use ' |
| 461 '--targetdir to select a different target.\n' % | 461 '--targetdir to select a different target.\n' % |
| 462 target_dir) | 462 target_dir) |
| 463 # Set the working directory to 7z subdirectory. 7-zip doesn't find its | 463 # Set the working directory to 7z subdirectory. 7-zip doesn't find its |
| 464 # codec dll very well, so this is the simplest way to make sure it runs | 464 # codec dll very well, so this is the simplest way to make sure it runs |
| 465 # correctly, as we don't otherwise care about working directory. | 465 # correctly, as we don't otherwise care about working directory. |
| 466 os.chdir(os.path.join(BASEDIR, '7z')) | 466 os.chdir(os.path.join(BASEDIR, '7z')) |
| 467 if options.bot_mode and options.sha1: | 467 if options.use_gs and options.sha1: |
| 468 options.express = False | 468 options.express = False |
| 469 DoTreeMirror(target_dir, options.sha1) | 469 DoTreeMirror(target_dir, options.sha1) |
| 470 else: | 470 else: |
| 471 images = GetSourceImages(options.local, not options.express) | 471 images = GetSourceImages(options.local, not options.express) |
| 472 extracted = ExtractComponents(images) | 472 extracted = ExtractComponents(images) |
| 473 CopyToFinalLocation(extracted, target_dir) | 473 CopyToFinalLocation(extracted, target_dir) |
| 474 GenerateSetEnvCmd(target_dir, not options.express) | 474 GenerateSetEnvCmd(target_dir, not options.express) |
| 475 | 475 |
| 476 data = { | 476 data = { |
| 477 'path': target_dir, | 477 'path': target_dir, |
| 478 'version': '2013e' if options.express else '2013', | 478 'version': '2013e' if options.express else '2013', |
| 479 'win8sdk': os.path.join(target_dir, 'win8sdk'), | 479 'win8sdk': os.path.join(target_dir, 'win8sdk'), |
| 480 'wdk': os.path.join(target_dir, 'wdk'), | 480 'wdk': os.path.join(target_dir, 'wdk'), |
| 481 'runtime_dirs': [ | 481 'runtime_dirs': [ |
| 482 os.path.join(target_dir, 'sys64'), | 482 os.path.join(target_dir, 'sys64'), |
| 483 os.path.join(target_dir, 'sys32'), | 483 os.path.join(target_dir, 'sys32'), |
| 484 ], | 484 ], |
| 485 } | 485 } |
| 486 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: | 486 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: |
| 487 json.dump(data, f) | 487 json.dump(data, f) |
| 488 finally: | 488 finally: |
| 489 if options.clean: | 489 if options.clean: |
| 490 DeleteAllTempDirs() | 490 DeleteAllTempDirs() |
| 491 | 491 |
| 492 | 492 |
| 493 if __name__ == '__main__': | 493 if __name__ == '__main__': |
| 494 sys.exit(main()) | 494 sys.exit(main()) |
| OLD | NEW |