| 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 optparse | 10 import optparse |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 while True: | 86 while True: |
| 87 chunk = req.read(1024 * 1024) | 87 chunk = req.read(1024 * 1024) |
| 88 if not chunk: | 88 if not chunk: |
| 89 break | 89 break |
| 90 bytes_read += len(chunk) | 90 bytes_read += len(chunk) |
| 91 file_handle.write(chunk) | 91 file_handle.write(chunk) |
| 92 sys.stdout.write('... %d/%d%s' % (bytes_read, content_length, terminator)) | 92 sys.stdout.write('... %d/%d%s' % (bytes_read, content_length, terminator)) |
| 93 sys.stdout.flush() | 93 sys.stdout.flush() |
| 94 sys.stdout.write('\n') | 94 sys.stdout.write('\n') |
| 95 if content_length and content_length != bytes_read: | 95 if content_length and content_length != bytes_read: |
| 96 raise SystemExit('Got incorrect number of bytes downloading %s' % url) | 96 sys.exit('Got incorrect number of bytes downloading %s' % url) |
| 97 | 97 |
| 98 | 98 |
| 99 def ExtractIso(iso_path): | 99 def ExtractIso(iso_path): |
| 100 """Uses 7zip to extract the contents of the given .iso (or self-extracting | 100 """Uses 7zip to extract the contents of the given .iso (or self-extracting |
| 101 .exe). | 101 .exe). |
| 102 """ | 102 """ |
| 103 target_path = TempDir() | 103 target_path = TempDir() |
| 104 sys.stdout.write('Extracting %s...\n' % iso_path) | 104 sys.stdout.write('Extracting %s...\n' % iso_path) |
| 105 sys.stdout.flush() | 105 sys.stdout.flush() |
| 106 # TODO(scottmg): Do this (and exe) manually with python code. | 106 # TODO(scottmg): Do this (and exe) manually with python code. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 'Running sdksetup.exe to download Win8 SDK (may request elevation)...\n') | 149 'Running sdksetup.exe to download Win8 SDK (may request elevation)...\n') |
| 150 count = 0 | 150 count = 0 |
| 151 while count < 5: | 151 while count < 5: |
| 152 rc = os.system(target_path + ' /quiet ' | 152 rc = os.system(target_path + ' /quiet ' |
| 153 '/features OptionId.WindowsDesktopDebuggers ' | 153 '/features OptionId.WindowsDesktopDebuggers ' |
| 154 '/layout ' + standalone_path) | 154 '/layout ' + standalone_path) |
| 155 if rc == 0: | 155 if rc == 0: |
| 156 return standalone_path | 156 return standalone_path |
| 157 count += 1 | 157 count += 1 |
| 158 sys.stdout.write('Windows 8 SDK failed to download, retrying.\n') | 158 sys.stdout.write('Windows 8 SDK failed to download, retrying.\n') |
| 159 raise SystemExit("After multiple retries, couldn't download Win8 SDK") | 159 sys.exit('After multiple retries, couldn\'t download Win8 SDK') |
| 160 | 160 |
| 161 | 161 |
| 162 def DownloadUsingGsutil(filename): | 162 def DownloadUsingGsutil(filename): |
| 163 """Downloads the given file from Google Storage chrome-wintoolchain bucket.""" | 163 """Downloads the given file from Google Storage chrome-wintoolchain bucket.""" |
| 164 temp_dir = TempDir() | 164 temp_dir = TempDir() |
| 165 assert os.path.basename(filename) == filename | 165 assert os.path.basename(filename) == filename |
| 166 target_path = os.path.join(temp_dir, filename) | 166 target_path = os.path.join(temp_dir, filename) |
| 167 gsutil = download_from_google_storage.Gsutil( | 167 gsutil = download_from_google_storage.Gsutil( |
| 168 download_from_google_storage.GSUTIL_DEFAULT_PATH, boto_path=None) | 168 download_from_google_storage.GSUTIL_DEFAULT_PATH, boto_path=None) |
| 169 code = gsutil.call('cp', 'gs://chrome-wintoolchain/' + filename, target_path) | 169 code = gsutil.call('cp', 'gs://chrome-wintoolchain/' + filename, target_path) |
| 170 if code != 0: | 170 if code != 0: |
| 171 raise SystemExit('gsutil failed') | 171 sys.exit('gsutil failed') |
| 172 return target_path | 172 return target_path |
| 173 | 173 |
| 174 | 174 |
| 175 def GetVSInternal(): | 175 def GetVSInternal(): |
| 176 """Uses gsutil to pull the toolchain from internal Google Storage bucket.""" | 176 """Uses gsutil to pull the toolchain from internal Google Storage bucket.""" |
| 177 return DownloadUsingGsutil('VS2013_RTM_PRO_ENU.iso') | 177 return DownloadUsingGsutil('VS2013_RTM_PRO_ENU.iso') |
| 178 | 178 |
| 179 | 179 |
| 180 def GetSDKInternal(): | 180 def GetSDKInternal(): |
| 181 """Downloads a zipped copy of the SDK from internal Google Storage bucket, | 181 """Downloads a zipped copy of the SDK from internal Google Storage bucket, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 CopyToFinalLocation(extracted, target_dir) | 367 CopyToFinalLocation(extracted, target_dir) |
| 368 | 368 |
| 369 GenerateSetEnvCmd(target_dir, not options.express) | 369 GenerateSetEnvCmd(target_dir, not options.express) |
| 370 finally: | 370 finally: |
| 371 if options.clean: | 371 if options.clean: |
| 372 DeleteAllTempDirs() | 372 DeleteAllTempDirs() |
| 373 | 373 |
| 374 | 374 |
| 375 if __name__ == '__main__': | 375 if __name__ == '__main__': |
| 376 sys.exit(main()) | 376 sys.exit(main()) |
| OLD | NEW |