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 |
11 you're trying to build an historical version of Chromium from before the | 11 you're trying to build an historical version of Chromium from before the |
12 toolchain upgrade, this will cause you to build with a newer toolchain than | 12 toolchain upgrade, this will cause you to build with a newer toolchain than |
13 was available when that code was committed. This is done for a two main | 13 was available when that code was committed. This is done for a two main |
14 reasons: 1) it would likely be annoying to have the up-to-date toolchain | 14 reasons: 1) it would likely be annoying to have the up-to-date toolchain |
15 removed and replaced by one without a service pack applied); 2) it would | 15 removed and replaced by one without a service pack applied); 2) it would |
16 require maintaining scripts that can build older not-up-to-date revisions of | 16 require maintaining scripts that can build older not-up-to-date revisions of |
17 the toolchain. This is likely to be a poorly tested code path that probably | 17 the toolchain. This is likely to be a poorly tested code path that probably |
18 won't be properly maintained. See http://crbug.com/323300. | 18 won't be properly maintained. See http://crbug.com/323300. |
19 | 19 |
20 This does not extend to major versions of the toolchain however, on the | 20 This does not extend to major versions of the toolchain however, on the |
21 assumption that there are more likely to be source incompatibilities between | 21 assumption that there are more likely to be source incompatibilities between |
22 major revisions. This script calls a subscript (currently, toolchain2013.py) | 22 major revisions. This script calls a subscript (currently, toolchain2013.py) |
23 to do the main work. It is expected that toolchain2013.py will always be able | 23 to do the main work. It is expected that toolchain2013.py will always be able |
24 to acquire/build the most current revision of a VS2013-based toolchain. In the | 24 to acquire/build the most current revision of a VS2013-based toolchain. In the |
25 future when a hypothetical VS2015 is released, the 2013 script will be | 25 future when a hypothetical VS2015 is released, the 2013 script will be |
26 maintained, and a new 2015 script would be added. | 26 maintained, and a new 2015 script would be added. |
27 """ | 27 """ |
28 | 28 |
29 import _winreg | |
30 import hashlib | 29 import hashlib |
31 import json | 30 import json |
32 import optparse | 31 import optparse |
33 import os | 32 import os |
34 import platform | 33 import platform |
35 import shutil | 34 import shutil |
36 import subprocess | 35 import subprocess |
37 import sys | 36 import sys |
38 import tempfile | 37 import tempfile |
39 import time | 38 import time |
40 import zipfile | 39 import zipfile |
41 | 40 |
41 # winreg isn't natively available under CygWin | |
42 if sys.platform == "win32": | |
43 try: | |
44 import winreg | |
brucedawson
2016/01/21 21:03:22
Why are you importing winreg? Why not just "import
| |
45 except ImportError: | |
46 import _winreg as winreg | |
47 elif sys.platform == "cygwin": | |
48 try: | |
49 import cygwinreg as winreg | |
50 except ImportError: | |
51 print '' | |
52 print 'CygWin does not natively support winreg but a replacement exists.' | |
53 print 'https://pypi.python.org/pypi/cygwinreg/' | |
54 print '' | |
55 print 'Try: easy_install cygwinreg' | |
56 print '' | |
57 raise | |
42 | 58 |
43 BASEDIR = os.path.dirname(os.path.abspath(__file__)) | 59 BASEDIR = os.path.dirname(os.path.abspath(__file__)) |
44 DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..') | 60 DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..') |
45 sys.path.append(DEPOT_TOOLS_PATH) | 61 sys.path.append(DEPOT_TOOLS_PATH) |
46 try: | 62 try: |
47 import download_from_google_storage | 63 import download_from_google_storage |
48 except ImportError: | 64 except ImportError: |
49 # Allow use of utility functions in this script from package_from_installed | 65 # Allow use of utility functions in this script from package_from_installed |
50 # on bare VM that doesn't have a full depot_tools. | 66 # on bare VM that doesn't have a full depot_tools. |
51 pass | 67 pass |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 | 236 |
221 | 237 |
222 def GetInstallerName(): | 238 def GetInstallerName(): |
223 """Return the name of the Windows 10 Universal C Runtime installer for the | 239 """Return the name of the Windows 10 Universal C Runtime installer for the |
224 current platform, or None if installer is not needed or not applicable. | 240 current platform, or None if installer is not needed or not applicable. |
225 The registry has to be used instead of sys.getwindowsversion() because | 241 The registry has to be used instead of sys.getwindowsversion() because |
226 Python 2.7 is only manifested as being compatible up to Windows 8, so the | 242 Python 2.7 is only manifested as being compatible up to Windows 8, so the |
227 version APIs helpfully return a maximum of 6.2 (Windows 8). | 243 version APIs helpfully return a maximum of 6.2 (Windows 8). |
228 """ | 244 """ |
229 key_name = r'Software\Microsoft\Windows NT\CurrentVersion' | 245 key_name = r'Software\Microsoft\Windows NT\CurrentVersion' |
230 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name) | 246 key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_name) |
231 value, keytype = _winreg.QueryValueEx(key, "CurrentVersion") | 247 value, keytype = winreg.QueryValueEx(key, "CurrentVersion") |
232 key.Close() | 248 key.Close() |
233 if keytype != _winreg.REG_SZ: | 249 if keytype != winreg.REG_SZ: |
234 raise Exception("Unexpected type in registry") | 250 raise Exception("Unexpected type in registry") |
235 if value == '6.1': | 251 if value == '6.1': |
236 # Windows 7 and Windows Server 2008 R2 | 252 # Windows 7 and Windows Server 2008 R2 |
237 return 'Windows6.1-KB2999226-x64.msu' | 253 return 'Windows6.1-KB2999226-x64.msu' |
238 elif value == '6.2': | 254 elif value == '6.2': |
239 # Windows 8 and Windows Server 2012 | 255 # Windows 8 and Windows Server 2012 |
240 return 'Windows8-RT-KB2999226-x64.msu' | 256 return 'Windows8-RT-KB2999226-x64.msu' |
241 elif value == '6.3': | 257 elif value == '6.3': |
242 # Windows 8.1, Windows Server 2012 R2, and Windows 10. | 258 # Windows 8.1, Windows Server 2012 R2, and Windows 10. |
243 # The Windows 8.1 installer doesn't work on Windows 10, but it will never | 259 # The Windows 8.1 installer doesn't work on Windows 10, but it will never |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 options.output_json) | 424 options.output_json) |
409 | 425 |
410 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 426 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
411 InstallUniversalCRTIfNeeded(abs_target_dir) | 427 InstallUniversalCRTIfNeeded(abs_target_dir) |
412 | 428 |
413 return 0 | 429 return 0 |
414 | 430 |
415 | 431 |
416 if __name__ == '__main__': | 432 if __name__ == '__main__': |
417 sys.exit(main()) | 433 sys.exit(main()) |
OLD | NEW |