Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 the V8 project authors. All rights reserved. | 2 # Copyright 2015 the V8 project authors. All rights reserved. |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import glob | |
| 7 import json | 8 import json |
| 8 import os | 9 import os |
| 9 import pipes | 10 import pipes |
| 10 import shutil | 11 import shutil |
| 11 import subprocess | 12 import subprocess |
| 12 import sys | 13 import sys |
| 13 import vs_toolchain | |
| 14 | 14 |
| 15 | 15 |
| 16 script_dir = os.path.dirname(os.path.realpath(__file__)) | 16 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 17 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 17 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| 18 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 18 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 19 sys.path.insert(1, os.path.join(chrome_src, 'tools')) | 19 sys.path.insert(1, os.path.join(chrome_src, 'tools')) |
|
Michael Achenbach
2016/04/13 15:10:18
Adjusted some v8-specific paths.
| |
| 20 sys.path.insert(0, os.path.join(chrome_src, 'build', 'gyp', 'pylib')) | 20 sys.path.insert(0, os.path.join(chrome_src, 'build', 'gyp', 'pylib')) |
| 21 json_data_file = os.path.join(script_dir, 'win_toolchain.json') | 21 json_data_file = os.path.join(script_dir, 'win_toolchain.json') |
| 22 | 22 |
| 23 | 23 |
| 24 import gyp | 24 import gyp |
| 25 | 25 |
| 26 | 26 |
| 27 # Use MSVS2013 as the default toolchain. | |
|
Michael Achenbach
2016/04/13 15:10:18
Keeping the 2013 default for now.
| |
| 28 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2013' | |
| 29 | |
| 30 | |
| 27 def SetEnvironmentAndGetRuntimeDllDirs(): | 31 def SetEnvironmentAndGetRuntimeDllDirs(): |
| 28 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and | 32 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and |
| 29 returns the location of the VS runtime DLLs so they can be copied into | 33 returns the location of the VS runtime DLLs so they can be copied into |
| 30 the output directory after gyp generation. | 34 the output directory after gyp generation. |
| 31 """ | 35 """ |
| 32 vs2013_runtime_dll_dirs = None | 36 vs_runtime_dll_dirs = None |
| 33 depot_tools_win_toolchain = \ | 37 depot_tools_win_toolchain = \ |
| 34 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) | 38 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
| 35 # When running on a non-Windows host, only do this if the SDK has explicitly | 39 # When running on a non-Windows host, only do this if the SDK has explicitly |
| 36 # been downloaded before (in which case json_data_file will exist). | 40 # been downloaded before (in which case json_data_file will exist). |
| 37 if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file)) | 41 if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file)) |
| 38 and depot_tools_win_toolchain): | 42 and depot_tools_win_toolchain): |
| 39 if not os.path.exists(json_data_file): | 43 if ShouldUpdateToolchain(): |
| 40 Update() | 44 Update() |
| 41 with open(json_data_file, 'r') as tempf: | 45 with open(json_data_file, 'r') as tempf: |
| 42 toolchain_data = json.load(tempf) | 46 toolchain_data = json.load(tempf) |
| 43 | 47 |
| 44 toolchain = toolchain_data['path'] | 48 toolchain = toolchain_data['path'] |
| 45 version = toolchain_data['version'] | 49 version = toolchain_data['version'] |
| 46 win_sdk = toolchain_data.get('win_sdk') | 50 win_sdk = toolchain_data.get('win_sdk') |
| 47 if not win_sdk: | 51 if not win_sdk: |
| 48 win_sdk = toolchain_data['win8sdk'] | 52 win_sdk = toolchain_data['win8sdk'] |
| 49 wdk = toolchain_data['wdk'] | 53 wdk = toolchain_data['wdk'] |
| 50 # TODO(scottmg): The order unfortunately matters in these. They should be | 54 # TODO(scottmg): The order unfortunately matters in these. They should be |
| 51 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call | 55 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call |
| 52 # below). http://crbug.com/345992 | 56 # below). http://crbug.com/345992 |
| 53 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs'] | 57 vs_runtime_dll_dirs = toolchain_data['runtime_dirs'] |
| 54 | 58 |
| 55 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain | 59 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain |
| 56 os.environ['GYP_MSVS_VERSION'] = version | 60 os.environ['GYP_MSVS_VERSION'] = version |
| 57 # We need to make sure windows_sdk_path is set to the automated | 61 # We need to make sure windows_sdk_path is set to the automated |
| 58 # toolchain values in GYP_DEFINES, but don't want to override any | 62 # toolchain values in GYP_DEFINES, but don't want to override any |
| 59 # otheroptions.express | 63 # otheroptions.express |
| 60 # values there. | 64 # values there. |
| 61 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) | 65 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) |
| 62 gyp_defines_dict['windows_sdk_path'] = win_sdk | 66 gyp_defines_dict['windows_sdk_path'] = win_sdk |
| 63 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) | 67 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) |
| 64 for k, v in gyp_defines_dict.iteritems()) | 68 for k, v in gyp_defines_dict.iteritems()) |
| 65 os.environ['WINDOWSSDKDIR'] = win_sdk | 69 os.environ['WINDOWSSDKDIR'] = win_sdk |
| 66 os.environ['WDK_DIR'] = wdk | 70 os.environ['WDK_DIR'] = wdk |
| 67 # Include the VS runtime in the PATH in case it's not machine-installed. | 71 # Include the VS runtime in the PATH in case it's not machine-installed. |
| 68 runtime_path = ';'.join(vs2013_runtime_dll_dirs) | 72 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs) |
| 69 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH'] | 73 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH'] |
| 70 return vs2013_runtime_dll_dirs | 74 elif sys.platform == 'win32' and not depot_tools_win_toolchain: |
| 75 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ: | |
| 76 os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath() | |
| 77 if not 'GYP_MSVS_VERSION' in os.environ: | |
| 78 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion() | |
| 79 | |
| 80 return vs_runtime_dll_dirs | |
| 81 | |
| 82 | |
| 83 def _RegistryGetValueUsingWinReg(key, value): | |
| 84 """Use the _winreg module to obtain the value of a registry key. | |
| 85 | |
| 86 Args: | |
| 87 key: The registry key. | |
| 88 value: The particular registry value to read. | |
| 89 Return: | |
| 90 contents of the registry key's value, or None on failure. Throws | |
| 91 ImportError if _winreg is unavailable. | |
| 92 """ | |
| 93 import _winreg | |
| 94 try: | |
| 95 root, subkey = key.split('\\', 1) | |
| 96 assert root == 'HKLM' # Only need HKLM for now. | |
| 97 with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey: | |
| 98 return _winreg.QueryValueEx(hkey, value)[0] | |
| 99 except WindowsError: | |
| 100 return None | |
| 101 | |
| 102 | |
| 103 def _RegistryGetValue(key, value): | |
| 104 try: | |
| 105 return _RegistryGetValueUsingWinReg(key, value) | |
| 106 except ImportError: | |
| 107 raise Exception('The python library _winreg not found.') | |
| 108 | |
| 109 | |
| 110 def GetVisualStudioVersion(): | |
| 111 """Return GYP_MSVS_VERSION of Visual Studio. | |
| 112 """ | |
| 113 return os.environ.get('GYP_MSVS_VERSION', CURRENT_DEFAULT_TOOLCHAIN_VERSION) | |
| 114 | |
| 115 | |
| 116 def DetectVisualStudioPath(): | |
| 117 """Return path to the GYP_MSVS_VERSION of Visual Studio. | |
| 118 """ | |
| 119 | |
| 120 # Note that this code is used from | |
| 121 # build/toolchain/win/setup_toolchain.py as well. | |
| 122 version_as_year = GetVisualStudioVersion() | |
| 123 year_to_version = { | |
| 124 '2013': '12.0', | |
| 125 '2015': '14.0', | |
| 126 } | |
| 127 if version_as_year not in year_to_version: | |
| 128 raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)' | |
| 129 ' not supported. Supported versions are: %s') % ( | |
| 130 version_as_year, ', '.join(year_to_version.keys()))) | |
| 131 version = year_to_version[version_as_year] | |
| 132 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version, | |
| 133 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version] | |
| 134 for key in keys: | |
| 135 path = _RegistryGetValue(key, 'InstallDir') | |
| 136 if not path: | |
| 137 continue | |
| 138 path = os.path.normpath(os.path.join(path, '..', '..')) | |
| 139 return path | |
| 140 | |
| 141 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)' | |
| 142 ' not found.') % (version_as_year)) | |
| 71 | 143 |
| 72 | 144 |
| 73 def _VersionNumber(): | 145 def _VersionNumber(): |
| 74 """Gets the standard version number ('120', '140', etc.) based on | 146 """Gets the standard version number ('120', '140', etc.) based on |
| 75 GYP_MSVS_VERSION.""" | 147 GYP_MSVS_VERSION.""" |
| 76 if os.environ['GYP_MSVS_VERSION'] == '2013': | 148 vs_version = GetVisualStudioVersion() |
| 149 if vs_version == '2013': | |
| 77 return '120' | 150 return '120' |
| 78 elif os.environ['GYP_MSVS_VERSION'] == '2015': | 151 elif vs_version == '2015': |
| 79 return '140' | 152 return '140' |
| 80 else: | 153 else: |
| 81 raise ValueError('Unexpected GYP_MSVS_VERSION') | 154 raise ValueError('Unexpected GYP_MSVS_VERSION') |
| 82 | 155 |
| 83 | 156 |
| 84 def _CopyRuntimeImpl(target, source): | 157 def _CopyRuntimeImpl(target, source, verbose=True): |
| 85 """Copy |source| to |target| if it doesn't already exist or if it | 158 """Copy |source| to |target| if it doesn't already exist or if it |
| 86 needs to be updated. | 159 needs to be updated. |
| 87 """ | 160 """ |
| 88 if (os.path.isdir(os.path.dirname(target)) and | 161 if (os.path.isdir(os.path.dirname(target)) and |
| 89 (not os.path.isfile(target) or | 162 (not os.path.isfile(target) or |
| 90 os.stat(target).st_mtime != os.stat(source).st_mtime)): | 163 os.stat(target).st_mtime != os.stat(source).st_mtime)): |
| 91 print 'Copying %s to %s...' % (source, target) | 164 if verbose: |
| 165 print 'Copying %s to %s...' % (source, target) | |
| 92 if os.path.exists(target): | 166 if os.path.exists(target): |
| 93 os.unlink(target) | 167 os.unlink(target) |
| 94 shutil.copy2(source, target) | 168 shutil.copy2(source, target) |
| 95 | 169 |
| 96 | 170 |
| 97 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): | 171 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): |
| 98 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't | 172 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't |
| 99 exist, but the target directory does exist.""" | 173 exist, but the target directory does exist.""" |
| 100 for file_part in ('p', 'r'): | 174 for file_part in ('p', 'r'): |
| 101 dll = dll_pattern % file_part | 175 dll = dll_pattern % file_part |
| 102 target = os.path.join(target_dir, dll) | 176 target = os.path.join(target_dir, dll) |
| 103 source = os.path.join(source_dir, dll) | 177 source = os.path.join(source_dir, dll) |
| 104 _CopyRuntimeImpl(target, source) | 178 _CopyRuntimeImpl(target, source) |
| 105 | 179 |
| 106 | 180 |
| 107 def _CopyRuntime2015(target_dir, source_dir, dll_pattern): | 181 def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix): |
| 108 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't | 182 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't |
| 109 exist, but the target directory does exist.""" | 183 exist, but the target directory does exist.""" |
| 110 for file_part in ('msvcp', 'vccorlib'): | 184 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): |
| 111 dll = dll_pattern % file_part | 185 dll = dll_pattern % file_part |
| 112 target = os.path.join(target_dir, dll) | 186 target = os.path.join(target_dir, dll) |
| 113 source = os.path.join(source_dir, dll) | 187 source = os.path.join(source_dir, dll) |
| 114 _CopyRuntimeImpl(target, source) | 188 _CopyRuntimeImpl(target, source) |
| 189 ucrt_src_dir = os.path.join(source_dir, 'api-ms-win-*.dll') | |
| 190 print 'Copying %s to %s...' % (ucrt_src_dir, target_dir) | |
| 191 for ucrt_src_file in glob.glob(ucrt_src_dir): | |
| 192 file_part = os.path.basename(ucrt_src_file) | |
| 193 ucrt_dst_file = os.path.join(target_dir, file_part) | |
| 194 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) | |
| 195 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), | |
| 196 os.path.join(source_dir, 'ucrtbase' + suffix)) | |
| 197 | |
| 198 | |
| 199 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): | |
| 200 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target | |
| 201 directory does exist. Handles VS 2013 and VS 2015.""" | |
| 202 suffix = "d.dll" if debug else ".dll" | |
| 203 if GetVisualStudioVersion() == '2015': | |
| 204 _CopyRuntime2015(target_dir, source_dir, '%s140' + suffix, suffix) | |
| 205 else: | |
| 206 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix) | |
| 207 | |
| 208 # Copy the PGO runtime library to the release directories. | |
| 209 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'): | |
| 210 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), | |
| 211 'VC', 'bin') | |
| 212 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') | |
| 213 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' | |
| 214 if target_cpu == "x86": | |
| 215 source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll) | |
| 216 if os.path.exists(source_x86): | |
| 217 _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll), source_x86) | |
| 218 elif target_cpu == "x64": | |
| 219 source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll) | |
| 220 if os.path.exists(source_x64): | |
| 221 _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll), | |
| 222 source_x64) | |
| 223 else: | |
| 224 raise NotImplementedError("Unexpected target_cpu value:" + target_cpu) | |
| 115 | 225 |
| 116 | 226 |
| 117 def CopyVsRuntimeDlls(output_dir, runtime_dirs): | 227 def CopyVsRuntimeDlls(output_dir, runtime_dirs): |
| 118 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output | 228 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output |
| 119 directory so that even if not system-installed, built binaries are likely to | 229 directory so that even if not system-installed, built binaries are likely to |
| 120 be able to run. | 230 be able to run. |
| 121 | 231 |
| 122 This needs to be run after gyp has been run so that the expected target | 232 This needs to be run after gyp has been run so that the expected target |
| 123 output directories are already created. | 233 output directories are already created. |
| 234 | |
| 235 This is used for the GYP build and gclient runhooks. | |
| 124 """ | 236 """ |
| 125 x86, x64 = runtime_dirs | 237 x86, x64 = runtime_dirs |
| 126 out_debug = os.path.join(output_dir, 'Debug') | 238 out_debug = os.path.join(output_dir, 'Debug') |
| 127 out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64') | 239 out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64') |
| 128 out_release = os.path.join(output_dir, 'Release') | 240 out_release = os.path.join(output_dir, 'Release') |
| 129 out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64') | 241 out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64') |
| 130 out_debug_x64 = os.path.join(output_dir, 'Debug_x64') | 242 out_debug_x64 = os.path.join(output_dir, 'Debug_x64') |
| 131 out_release_x64 = os.path.join(output_dir, 'Release_x64') | 243 out_release_x64 = os.path.join(output_dir, 'Release_x64') |
| 132 | 244 |
| 133 if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64): | 245 if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64): |
| 134 os.makedirs(out_debug_nacl64) | 246 os.makedirs(out_debug_nacl64) |
| 135 if os.path.exists(out_release) and not os.path.exists(out_release_nacl64): | 247 if os.path.exists(out_release) and not os.path.exists(out_release_nacl64): |
| 136 os.makedirs(out_release_nacl64) | 248 os.makedirs(out_release_nacl64) |
| 137 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 249 _CopyRuntime(out_debug, x86, "x86", debug=True) |
| 138 _CopyRuntime2015(out_debug, x86, '%s140d.dll') | 250 _CopyRuntime(out_release, x86, "x86", debug=False) |
| 139 _CopyRuntime2015(out_release, x86, '%s140.dll') | 251 _CopyRuntime(out_debug_x64, x64, "x64", debug=True) |
| 140 _CopyRuntime2015(out_debug_x64, x64, '%s140d.dll') | 252 _CopyRuntime(out_release_x64, x64, "x64", debug=False) |
| 141 _CopyRuntime2015(out_release_x64, x64, '%s140.dll') | 253 _CopyRuntime(out_debug_nacl64, x64, "x64", debug=True) |
| 142 _CopyRuntime2015(out_debug_nacl64, x64, '%s140d.dll') | 254 _CopyRuntime(out_release_nacl64, x64, "x64", debug=False) |
| 143 _CopyRuntime2015(out_release_nacl64, x64, '%s140.dll') | |
| 144 else: | |
| 145 # VS2013 is the default. | |
| 146 _CopyRuntime2013(out_debug, x86, 'msvc%s120d.dll') | |
| 147 _CopyRuntime2013(out_release, x86, 'msvc%s120.dll') | |
| 148 _CopyRuntime2013(out_debug_x64, x64, 'msvc%s120d.dll') | |
| 149 _CopyRuntime2013(out_release_x64, x64, 'msvc%s120.dll') | |
| 150 _CopyRuntime2013(out_debug_nacl64, x64, 'msvc%s120d.dll') | |
| 151 _CopyRuntime2013(out_release_nacl64, x64, 'msvc%s120.dll') | |
| 152 | |
| 153 # Copy the PGO runtime library to the release directories. | |
| 154 if os.environ.get('GYP_MSVS_OVERRIDE_PATH'): | |
| 155 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), | |
| 156 'VC', 'bin') | |
| 157 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') | |
| 158 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' | |
| 159 source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll) | |
| 160 if os.path.exists(source_x86): | |
| 161 _CopyRuntimeImpl(os.path.join(out_release, pgo_runtime_dll), source_x86) | |
| 162 source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll) | |
| 163 if os.path.exists(source_x64): | |
| 164 _CopyRuntimeImpl(os.path.join(out_release_x64, pgo_runtime_dll), | |
| 165 source_x64) | |
| 166 | 255 |
| 167 | 256 |
| 168 def CopyDlls(target_dir, configuration, target_cpu): | 257 def CopyDlls(target_dir, configuration, target_cpu): |
| 169 """Copy the VS runtime DLLs into the requested directory as needed. | 258 """Copy the VS runtime DLLs into the requested directory as needed. |
| 170 | 259 |
| 171 configuration is one of 'Debug' or 'Release'. | 260 configuration is one of 'Debug' or 'Release'. |
| 172 target_cpu is one of 'x86' or 'x64'. | 261 target_cpu is one of 'x86' or 'x64'. |
| 173 | 262 |
| 174 The debug configuration gets both the debug and release DLLs; the | 263 The debug configuration gets both the debug and release DLLs; the |
| 175 release config only the latter. | 264 release config only the latter. |
| 265 | |
| 266 This is used for the GN build. | |
| 176 """ | 267 """ |
| 177 vs2013_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() | 268 vs_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() |
| 178 if not vs2013_runtime_dll_dirs: | 269 if not vs_runtime_dll_dirs: |
| 179 return | 270 return |
| 180 | 271 |
| 181 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | 272 x64_runtime, x86_runtime = vs_runtime_dll_dirs |
| 182 runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime | 273 runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime |
| 183 _CopyRuntime2013( | 274 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False) |
| 184 target_dir, runtime_dir, 'msvc%s' + _VersionNumber() + '.dll') | |
| 185 if configuration == 'Debug': | 275 if configuration == 'Debug': |
| 186 _CopyRuntime2013( | 276 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) |
| 187 target_dir, runtime_dir, 'msvc%s' + _VersionNumber() + 'd.dll') | |
| 188 | 277 |
| 189 | 278 |
| 190 def _GetDesiredVsToolchainHashes(): | 279 def _GetDesiredVsToolchainHashes(): |
| 191 """Load a list of SHA1s corresponding to the toolchains that we want installed | 280 """Load a list of SHA1s corresponding to the toolchains that we want installed |
| 192 to build with.""" | 281 to build with.""" |
| 193 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 282 if GetVisualStudioVersion() == '2015': |
| 194 return ['5a85cf1ce842f7cc96b9d17039a445a9dc9cf0dd'] | 283 # Update 2. |
| 284 return ['95ddda401ec5678f15eeed01d2bee08fcbc5ee97'] | |
| 195 else: | 285 else: |
| 196 # Default to VS2013. | 286 return ['4087e065abebdca6dbd0caca2910c6718d2ec67f'] |
| 197 return ['9ff97c632ae1fee0c98bcd53e71770eb3a0d8deb'] | 287 |
| 288 | |
| 289 def ShouldUpdateToolchain(): | |
| 290 """Check if the toolchain should be upgraded.""" | |
| 291 if not os.path.exists(json_data_file): | |
| 292 return True | |
| 293 with open(json_data_file, 'r') as tempf: | |
| 294 toolchain_data = json.load(tempf) | |
| 295 version = toolchain_data['version'] | |
| 296 env_version = GetVisualStudioVersion() | |
| 297 # If there's a mismatch between the version set in the environment and the one | |
| 298 # in the json file then the toolchain should be updated. | |
| 299 return version != env_version | |
| 198 | 300 |
| 199 | 301 |
| 200 def Update(force=False): | 302 def Update(force=False): |
| 201 """Requests an update of the toolchain to the specific hashes we have at | 303 """Requests an update of the toolchain to the specific hashes we have at |
| 202 this revision. The update outputs a .json of the various configuration | 304 this revision. The update outputs a .json of the various configuration |
| 203 information required to pass to gyp which we use in |GetToolchainDir()|. | 305 information required to pass to gyp which we use in |GetToolchainDir()|. |
| 204 """ | 306 """ |
| 205 if force != False and force != '--force': | 307 if force != False and force != '--force': |
| 206 print >>sys.stderr, 'Unknown parameter "%s"' % force | 308 print >>sys.stderr, 'Unknown parameter "%s"' % force |
| 207 return 1 | 309 return 1 |
| 208 if force == '--force' or os.path.exists(json_data_file): | 310 if force == '--force' or os.path.exists(json_data_file): |
| 209 force = True | 311 force = True |
| 210 | 312 |
| 211 depot_tools_win_toolchain = \ | 313 depot_tools_win_toolchain = \ |
| 212 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) | 314 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
| 213 if ((sys.platform in ('win32', 'cygwin') or force) and | 315 if ((sys.platform in ('win32', 'cygwin') or force) and |
| 214 depot_tools_win_toolchain): | 316 depot_tools_win_toolchain): |
| 215 import find_depot_tools | 317 import find_depot_tools |
| 216 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 318 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| 319 # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit | |
| 320 # in the correct directory. | |
| 321 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion() | |
| 217 get_toolchain_args = [ | 322 get_toolchain_args = [ |
| 218 sys.executable, | 323 sys.executable, |
| 219 os.path.join(depot_tools_path, | 324 os.path.join(depot_tools_path, |
| 220 'win_toolchain', | 325 'win_toolchain', |
| 221 'get_toolchain_if_necessary.py'), | 326 'get_toolchain_if_necessary.py'), |
| 222 '--output-json', json_data_file, | 327 '--output-json', json_data_file, |
| 223 ] + _GetDesiredVsToolchainHashes() | 328 ] + _GetDesiredVsToolchainHashes() |
| 224 if force: | 329 if force: |
| 225 get_toolchain_args.append('--force') | 330 get_toolchain_args.append('--force') |
| 226 subprocess.check_call(get_toolchain_args) | 331 subprocess.check_call(get_toolchain_args) |
| 227 | 332 |
| 228 return 0 | 333 return 0 |
| 229 | 334 |
| 230 | 335 |
| 336 def NormalizePath(path): | |
| 337 while path.endswith("\\"): | |
| 338 path = path[:-1] | |
| 339 return path | |
| 340 | |
| 341 | |
| 231 def GetToolchainDir(): | 342 def GetToolchainDir(): |
| 232 """Gets location information about the current toolchain (must have been | 343 """Gets location information about the current toolchain (must have been |
| 233 previously updated by 'update'). This is used for the GN build.""" | 344 previously updated by 'update'). This is used for the GN build.""" |
| 234 runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() | 345 runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() |
| 235 | 346 |
| 236 # If WINDOWSSDKDIR is not set, search the default SDK path and set it. | 347 # If WINDOWSSDKDIR is not set, search the default SDK path and set it. |
| 237 if not 'WINDOWSSDKDIR' in os.environ: | 348 if not 'WINDOWSSDKDIR' in os.environ: |
| 238 default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\8.1' | 349 default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10' |
| 239 if os.path.isdir(default_sdk_path): | 350 if os.path.isdir(default_sdk_path): |
| 240 os.environ['WINDOWSSDKDIR'] = default_sdk_path | 351 os.environ['WINDOWSSDKDIR'] = default_sdk_path |
| 241 | 352 |
| 242 print '''vs_path = "%s" | 353 print '''vs_path = "%s" |
| 243 sdk_path = "%s" | 354 sdk_path = "%s" |
| 244 vs_version = "%s" | 355 vs_version = "%s" |
| 245 wdk_dir = "%s" | 356 wdk_dir = "%s" |
| 246 runtime_dirs = "%s" | 357 runtime_dirs = "%s" |
| 247 ''' % ( | 358 ''' % ( |
| 248 os.environ['GYP_MSVS_OVERRIDE_PATH'], | 359 NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH']), |
| 249 os.environ['WINDOWSSDKDIR'], | 360 NormalizePath(os.environ['WINDOWSSDKDIR']), |
| 250 os.environ['GYP_MSVS_VERSION'], | 361 GetVisualStudioVersion(), |
| 251 os.environ.get('WDK_DIR', ''), | 362 NormalizePath(os.environ.get('WDK_DIR', '')), |
| 252 ';'.join(runtime_dll_dirs or ['None'])) | 363 os.path.pathsep.join(runtime_dll_dirs or ['None'])) |
| 253 | 364 |
| 254 | 365 |
| 255 def main(): | 366 def main(): |
| 256 commands = { | 367 commands = { |
| 257 'update': Update, | 368 'update': Update, |
| 258 'get_toolchain_dir': GetToolchainDir, | 369 'get_toolchain_dir': GetToolchainDir, |
| 259 'copy_dlls': CopyDlls, | 370 'copy_dlls': CopyDlls, |
| 260 } | 371 } |
| 261 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 372 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
| 262 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 373 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
| 263 return 1 | 374 return 1 |
| 264 return commands[sys.argv[1]](*sys.argv[2:]) | 375 return commands[sys.argv[1]](*sys.argv[2:]) |
| 265 | 376 |
| 266 | 377 |
| 267 if __name__ == '__main__': | 378 if __name__ == '__main__': |
| 268 sys.exit(main()) | 379 sys.exit(main()) |
| OLD | NEW |