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

Side by Side Diff: win_toolchain/toolchain2013.py

Issue 148613003: Pull toolchain isos from gs:// when on bots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: fix return of call Created 6 years, 11 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 | no next file » | 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 """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
11 import os 11 import os
12 import shutil 12 import shutil
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 import tempfile 15 import tempfile
16 import urllib2 16 import urllib2
17 17
18 18
19 BASEDIR = os.path.dirname(os.path.abspath(__file__)) 19 BASEDIR = os.path.dirname(os.path.abspath(__file__))
20 g_temp_dirs = [] 20 g_temp_dirs = []
21 21
22 22
23 sys.path.append(os.path.join(BASEDIR, '..'))
iannucci 2014/01/28 16:38:33 ARGH! THE PAIN! (no there's not a better alternat
scottmg 2014/01/28 17:36:35 Our 'environment' could use "some work". :(
24 import download_from_google_storage
25
26
23 def GetLongPathName(path): 27 def GetLongPathName(path):
24 """Converts any 8dot3 names in the path to the full name.""" 28 """Converts any 8dot3 names in the path to the full name."""
25 buf = ctypes.create_unicode_buffer(260) 29 buf = ctypes.create_unicode_buffer(260)
26 size = ctypes.windll.kernel32.GetLongPathNameW(unicode(path), buf, 260) 30 size = ctypes.windll.kernel32.GetLongPathNameW(unicode(path), buf, 260)
27 if (size > 260): 31 if (size > 260):
28 sys.exit('Long form of path longer than 260 chars: %s' % path) 32 sys.exit('Long form of path longer than 260 chars: %s' % path)
29 return buf.value 33 return buf.value
30 34
31 35
32 def RunOrDie(command): 36 def RunOrDie(command):
(...skipping 16 matching lines...) Expand all
49 sys.stdout.write('Cleaning up temporaries...\n') 53 sys.stdout.write('Cleaning up temporaries...\n')
50 for temp in g_temp_dirs: 54 for temp in g_temp_dirs:
51 # shutil.rmtree errors out on read only attributes. 55 # shutil.rmtree errors out on read only attributes.
52 RunOrDie('rmdir /s/q "%s"' % temp) 56 RunOrDie('rmdir /s/q "%s"' % temp)
53 g_temp_dirs = [] 57 g_temp_dirs = []
54 58
55 59
56 def GetIsoUrl(pro): 60 def GetIsoUrl(pro):
57 """Gets the .iso URL. 61 """Gets the .iso URL.
58 62
59 If |pro| is False, downloads the Express edition. 63 If |pro| is False, downloads the Express edition. If |CHROME_HEADLESS| is
64 set in the environment, then we assume we're on an internal bot, and download
65 from internal google storage instead.
60 """ 66 """
61 prefix = 'http://download.microsoft.com/download/' 67 prefix = 'http://download.microsoft.com/download/'
62 if pro: 68 if pro:
63 return (prefix + 69 return (prefix +
64 'A/F/1/AF128362-A6A8-4DB3-A39A-C348086472CC/VS2013_RTM_PRO_ENU.iso') 70 'A/F/1/AF128362-A6A8-4DB3-A39A-C348086472CC/VS2013_RTM_PRO_ENU.iso')
65 else: 71 else:
66 return (prefix + 72 return (prefix +
67 '7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/VS2013_RTM_DskExp_ENU.iso') 73 '7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/VS2013_RTM_DskExp_ENU.iso')
68 74
69 75
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 rc = os.system(target_path + ' /quiet ' 152 rc = os.system(target_path + ' /quiet '
147 '/features OptionId.WindowsDesktopDebuggers ' 153 '/features OptionId.WindowsDesktopDebuggers '
148 '/layout ' + standalone_path) 154 '/layout ' + standalone_path)
149 if rc == 0: 155 if rc == 0:
150 return standalone_path 156 return standalone_path
151 count += 1 157 count += 1
152 sys.stdout.write('Windows 8 SDK failed to download, retrying.\n') 158 sys.stdout.write('Windows 8 SDK failed to download, retrying.\n')
153 raise SystemExit("After multiple retries, couldn't download Win8 SDK") 159 raise SystemExit("After multiple retries, couldn't download Win8 SDK")
154 160
155 161
162 def DownloadUsingGsutil(filename):
163 """Downloads the given file from Google Storage chrome-wintoolchain bucket."""
164 temp_dir = TempDir()
iannucci 2014/01/28 16:38:33 I really wish that TempDir was a contextlib.contex
scottmg 2014/01/28 17:36:35 Could you explain why it will leak? Any finally bl
165 assert os.path.basename(filename) == filename
166 target_path = os.path.join(temp_dir, filename)
167 gsutil = download_from_google_storage.Gsutil(
168 download_from_google_storage.GSUTIL_DEFAULT_PATH, boto_path=None)
169 code = gsutil.call('cp', 'gs://chrome-wintoolchain/' + filename, target_path)
170 if code != 0:
171 raise SystemExit('gsutil failed')
iannucci 2014/01/28 16:38:33 sys.exit('gsutil failed')
scottmg 2014/01/28 17:36:35 I guess? https://codereview.chromium.org/148523009
172 return target_path
173
174
175 def GetVSInternal():
176 """Uses gsutil to pull the toolchain from internal Google Storage bucket."""
177 return DownloadUsingGsutil('VS2013_RTM_PRO_ENU.iso')
178
179
180 def GetSDKInternal():
181 """Downloads a zipped copy of the SDK from internal Google Storage bucket,
182 and extracts it."""
183 zip_file = DownloadUsingGsutil('Standalone.zip')
184 return ExtractIso(zip_file)
185
186
156 class SourceImages(object): 187 class SourceImages(object):
157 def __init__(self, vs_path, sdk8_path): 188 def __init__(self, vs_path, sdk8_path):
158 self.vs_path = vs_path 189 self.vs_path = vs_path
159 self.sdk8_path = sdk8_path 190 self.sdk8_path = sdk8_path
160 191
161 192
162 def GetSourceImages(local_dir, pro): 193 def GetSourceImages(local_dir, pro):
163 url = GetIsoUrl(pro) 194 url = GetIsoUrl(pro)
164 if local_dir: 195 if os.environ.get('CHROME_HEADLESS'):
196 return SourceImages(GetVSInternal(), GetSDKInternal())
197 elif local_dir:
165 return SourceImages(os.path.join(local_dir, os.path.basename(url)), 198 return SourceImages(os.path.join(local_dir, os.path.basename(url)),
166 os.path.join(local_dir, 'Standalone')) 199 os.path.join(local_dir, 'Standalone'))
167 else: 200 else:
168 # Note that we do the SDK first, as it might cause an elevation prompt. 201 # Note that we do the SDK first, as it might cause an elevation prompt.
169 sdk8_path = DownloadSDK8() 202 sdk8_path = DownloadSDK8()
170 vs_path = DownloadMainIso(url) 203 vs_path = DownloadMainIso(url)
171 return SourceImages(vs_path, sdk8_path) 204 return SourceImages(vs_path, sdk8_path)
172 205
173 206
174 def ExtractMsiList(root_dir, packages): 207 def ExtractMsiList(root_dir, packages):
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 CopyToFinalLocation(extracted, target_dir) 367 CopyToFinalLocation(extracted, target_dir)
335 368
336 GenerateSetEnvCmd(target_dir, not options.express) 369 GenerateSetEnvCmd(target_dir, not options.express)
337 finally: 370 finally:
338 if options.clean: 371 if options.clean:
339 DeleteAllTempDirs() 372 DeleteAllTempDirs()
340 373
341 374
342 if __name__ == '__main__': 375 if __name__ == '__main__':
343 sys.exit(main()) 376 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698