blob: 90a562d3fb67d17be366500ef264c5a588b0f67e [file] [log] [blame]
thakis4f4b1372015-08-11 22:25:001#!/usr/bin/env python
[email protected]4e8a2472014-03-19 22:01:392# Copyright 2014 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
brucedawsond5273dd2016-02-09 04:27:526import glob
[email protected]4e8a2472014-03-19 22:01:397import json
8import os
9import pipes
brucedawsone7bd0342016-06-01 18:37:1810import platform
[email protected]4e8a2472014-03-19 22:01:3911import shutil
brucedawsone7bd0342016-06-01 18:37:1812import stat
[email protected]4e8a2472014-03-19 22:01:3913import subprocess
14import sys
[email protected]4e8a2472014-03-19 22:01:3915
16
17script_dir = os.path.dirname(os.path.realpath(__file__))
18chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
19SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
[email protected]4e8a2472014-03-19 22:01:3920sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
[email protected]c71d3282014-04-09 01:56:2021json_data_file = os.path.join(script_dir, 'win_toolchain.json')
[email protected]4e8a2472014-03-19 22:01:3922
23
brucedawson2b33e7e2016-03-11 19:55:2524# Use MSVS2015 as the default toolchain.
25CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015'
sebmarchande44b02e2016-01-15 22:29:5726
27
[email protected]c71d3282014-04-09 01:56:2028def SetEnvironmentAndGetRuntimeDllDirs():
29 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
30 returns the location of the VS runtime DLLs so they can be copied into
31 the output directory after gyp generation.
brucedawsone7bd0342016-06-01 18:37:1832
33 Return value is [x64path, x86path] or None
[email protected]4e8a2472014-03-19 22:01:3934 """
brucedawsonaaff8dc2015-11-21 02:21:5235 vs_runtime_dll_dirs = None
[email protected]4e8a2472014-03-19 22:01:3936 depot_tools_win_toolchain = \
37 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
thakis4f4b1372015-08-11 22:25:0038 # When running on a non-Windows host, only do this if the SDK has explicitly
39 # been downloaded before (in which case json_data_file will exist).
scottmg05eac9c02015-08-25 23:03:3540 if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file))
41 and depot_tools_win_toolchain):
sebmarchande44b02e2016-01-15 22:29:5742 if ShouldUpdateToolchain():
[email protected]9372bec2014-08-14 14:03:3043 Update()
[email protected]c71d3282014-04-09 01:56:2044 with open(json_data_file, 'r') as tempf:
[email protected]4e8a2472014-03-19 22:01:3945 toolchain_data = json.load(tempf)
[email protected]4e8a2472014-03-19 22:01:3946
47 toolchain = toolchain_data['path']
48 version = toolchain_data['version']
scottmg54e45062015-06-02 01:15:4449 win_sdk = toolchain_data.get('win_sdk')
50 if not win_sdk:
51 win_sdk = toolchain_data['win8sdk']
[email protected]4e8a2472014-03-19 22:01:3952 wdk = toolchain_data['wdk']
53 # TODO(scottmg): The order unfortunately matters in these. They should be
54 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
55 # below). http://crbug.com/345992
brucedawsonaaff8dc2015-11-21 02:21:5256 vs_runtime_dll_dirs = toolchain_data['runtime_dirs']
[email protected]4e8a2472014-03-19 22:01:3957
58 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
59 os.environ['GYP_MSVS_VERSION'] = version
thestig9b24fa52017-03-11 01:46:4260
61 # Limit the scope of the gyp import to only where it is used. This
62 # potentially lets build configs that never execute this block to drop
63 # their GYP checkout.
64 import gyp
65
[email protected]4e8a2472014-03-19 22:01:3966 # We need to make sure windows_sdk_path is set to the automated
67 # toolchain values in GYP_DEFINES, but don't want to override any
68 # otheroptions.express
69 # values there.
70 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
scottmg54e45062015-06-02 01:15:4471 gyp_defines_dict['windows_sdk_path'] = win_sdk
[email protected]4e8a2472014-03-19 22:01:3972 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
73 for k, v in gyp_defines_dict.iteritems())
thestig9b24fa52017-03-11 01:46:4274
scottmg54e45062015-06-02 01:15:4475 os.environ['WINDOWSSDKDIR'] = win_sdk
[email protected]4e8a2472014-03-19 22:01:3976 os.environ['WDK_DIR'] = wdk
77 # Include the VS runtime in the PATH in case it's not machine-installed.
thakis44a40f82016-02-15 18:18:0178 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
79 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
bratellc7af8792016-01-07 16:30:1280 elif sys.platform == 'win32' and not depot_tools_win_toolchain:
81 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
82 os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
lwchkg833a437f2016-01-19 00:39:0883 if not 'GYP_MSVS_VERSION' in os.environ:
84 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
bratellc7af8792016-01-07 16:30:1285
brucedawsone7bd0342016-06-01 18:37:1886 # When using an installed toolchain these files aren't needed in the output
87 # directory in order to run binaries locally, but they are needed in order
88 # to create isolates or the mini_installer. Copying them to the output
89 # directory ensures that they are available when needed.
90 bitness = platform.architecture()[0]
91 # When running 64-bit python the x64 DLLs will be in System32
92 x64_path = 'System32' if bitness == '64bit' else 'Sysnative'
93 x64_path = os.path.join(r'C:\Windows', x64_path)
94 vs_runtime_dll_dirs = [x64_path, r'C:\Windows\SysWOW64']
95
brucedawsonaaff8dc2015-11-21 02:21:5296 return vs_runtime_dll_dirs
[email protected]4e8a2472014-03-19 22:01:3997
98
bratellc7af8792016-01-07 16:30:1299def _RegistryGetValueUsingWinReg(key, value):
100 """Use the _winreg module to obtain the value of a registry key.
101
102 Args:
103 key: The registry key.
104 value: The particular registry value to read.
105 Return:
106 contents of the registry key's value, or None on failure. Throws
107 ImportError if _winreg is unavailable.
108 """
109 import _winreg
110 try:
111 root, subkey = key.split('\\', 1)
112 assert root == 'HKLM' # Only need HKLM for now.
113 with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey:
114 return _winreg.QueryValueEx(hkey, value)[0]
115 except WindowsError:
116 return None
117
118
119def _RegistryGetValue(key, value):
120 try:
121 return _RegistryGetValueUsingWinReg(key, value)
122 except ImportError:
123 raise Exception('The python library _winreg not found.')
124
125
halton.huo815e1772016-01-13 02:23:30126def GetVisualStudioVersion():
sebmarchande44b02e2016-01-15 22:29:57127 """Return GYP_MSVS_VERSION of Visual Studio.
halton.huo815e1772016-01-13 02:23:30128 """
sebmarchande44b02e2016-01-15 22:29:57129 return os.environ.get('GYP_MSVS_VERSION', CURRENT_DEFAULT_TOOLCHAIN_VERSION)
halton.huo815e1772016-01-13 02:23:30130
131
bratellc7af8792016-01-07 16:30:12132def DetectVisualStudioPath():
133 """Return path to the GYP_MSVS_VERSION of Visual Studio.
134 """
135
136 # Note that this code is used from
137 # build/toolchain/win/setup_toolchain.py as well.
halton.huo815e1772016-01-13 02:23:30138 version_as_year = GetVisualStudioVersion()
bratellc7af8792016-01-07 16:30:12139 year_to_version = {
bratellc7af8792016-01-07 16:30:12140 '2015': '14.0',
brucedawsonadddab42017-01-23 06:57:21141 '2017': '15.0',
bratellc7af8792016-01-07 16:30:12142 }
143 if version_as_year not in year_to_version:
144 raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)'
145 ' not supported. Supported versions are: %s') % (
146 version_as_year, ', '.join(year_to_version.keys())))
147 version = year_to_version[version_as_year]
brucedawsonadddab42017-01-23 06:57:21148 if version_as_year == '2017':
149 # The VC++ 2017 install location needs to be located using COM instead of
150 # the registry. For details see:
151 # https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
152 # For now we use a hardcoded default with an environment variable override.
153 path = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional'
154 path = os.environ.get('vs2017_install', path)
155 if os.path.exists(path):
156 return path
157 else:
158 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version,
159 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version]
160 for key in keys:
161 path = _RegistryGetValue(key, 'InstallDir')
162 if not path:
163 continue
164 path = os.path.normpath(os.path.join(path, '..', '..'))
165 return path
bratellc7af8792016-01-07 16:30:12166
167 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)'
168 ' not found.') % (version_as_year))
169
170
scottmg54e45062015-06-02 01:15:44171def _VersionNumber():
172 """Gets the standard version number ('120', '140', etc.) based on
173 GYP_MSVS_VERSION."""
halton.huo815e1772016-01-13 02:23:30174 vs_version = GetVisualStudioVersion()
thestig9b24fa52017-03-11 01:46:42175 if vs_version == '2015':
scottmg54e45062015-06-02 01:15:44176 return '140'
thestig9b24fa52017-03-11 01:46:42177 if vs_version == '2017':
brucedawsonadddab42017-01-23 06:57:21178 return '150'
thestig9b24fa52017-03-11 01:46:42179 raise ValueError('Unexpected GYP_MSVS_VERSION')
scottmg54e45062015-06-02 01:15:44180
181
brucedawsond5273dd2016-02-09 04:27:52182def _CopyRuntimeImpl(target, source, verbose=True):
gab381d9f172016-04-18 15:29:14183 """Copy |source| to |target| if it doesn't already exist or if it needs to be
184 updated (comparing last modified time as an approximate float match as for
185 some reason the values tend to differ by ~1e-07 despite being copies of the
186 same file... https://crbug.com/603603).
dpranke0b951952014-11-15 00:09:14187 """
188 if (os.path.isdir(os.path.dirname(target)) and
189 (not os.path.isfile(target) or
gab381d9f172016-04-18 15:29:14190 abs(os.stat(target).st_mtime - os.stat(source).st_mtime) >= 0.01)):
brucedawsond5273dd2016-02-09 04:27:52191 if verbose:
192 print 'Copying %s to %s...' % (source, target)
dpranke0b951952014-11-15 00:09:14193 if os.path.exists(target):
brucedawsone7bd0342016-06-01 18:37:18194 # Make the file writable so that we can delete it now.
195 os.chmod(target, stat.S_IWRITE)
dpranke0b951952014-11-15 00:09:14196 os.unlink(target)
197 shutil.copy2(source, target)
brucedawsone7bd0342016-06-01 18:37:18198 # Make the file writable so that we can overwrite or delete it later.
199 os.chmod(target, stat.S_IWRITE)
dpranke0b951952014-11-15 00:09:14200
201
brucedawson46cd6d932017-03-13 21:12:31202def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
scottmg54e45062015-06-02 01:15:44203 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
204 exist, but the target directory does exist."""
sebmarchand7cebe212015-12-17 20:44:35205 for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
scottmg54e45062015-06-02 01:15:44206 dll = dll_pattern % file_part
207 target = os.path.join(target_dir, dll)
208 source = os.path.join(source_dir, dll)
209 _CopyRuntimeImpl(target, source)
brucedawson46cd6d932017-03-13 21:12:31210 # Copy the UCRT files needed by VS 2015 from the Windows SDK. This location
211 # includes the api-ms-win-crt-*.dll files that are not found in the Windows
212 # directory. These files are needed for component builds.
213 # If WINDOWSSDKDIR is not set use the default SDK path. This will be the case
214 # when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run.
215 win_sdk_dir = os.path.normpath(
216 os.environ.get('WINDOWSSDKDIR',
217 'C:\\Program Files (x86)\\Windows Kits\\10'))
218 ucrt_dll_dirs = os.path.join(win_sdk_dir, r'Redist\ucrt\DLLs', target_cpu)
219 ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll'))
brucedawsone7bd0342016-06-01 18:37:18220 assert len(ucrt_files) > 0
221 for ucrt_src_file in ucrt_files:
brucedawsonc6f6c692016-02-22 23:09:18222 file_part = os.path.basename(ucrt_src_file)
223 ucrt_dst_file = os.path.join(target_dir, file_part)
224 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
225 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
226 os.path.join(source_dir, 'ucrtbase' + suffix))
dpranke0b951952014-11-15 00:09:14227
228
brucedawsonaaff8dc2015-11-21 02:21:52229def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
230 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target
brucedawsone7c0d992017-03-27 20:59:15231 directory does exist. Handles VS 2015 and VS 2017."""
brucedawsonaaff8dc2015-11-21 02:21:52232 suffix = "d.dll" if debug else ".dll"
brucedawsone7c0d992017-03-27 20:59:15233 # VS 2017 uses the same CRT DLLs as VS 2015.
234 _CopyUCRTRuntime(target_dir, source_dir, target_cpu, '%s140' + suffix,
235 suffix)
brucedawsonaaff8dc2015-11-21 02:21:52236
237 # Copy the PGO runtime library to the release directories.
238 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
239 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
240 'VC', 'bin')
241 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
242 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll'
243 if target_cpu == "x86":
244 source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll)
245 if os.path.exists(source_x86):
246 _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll), source_x86)
247 elif target_cpu == "x64":
248 source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll)
249 if os.path.exists(source_x64):
250 _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll),
251 source_x64)
252 else:
253 raise NotImplementedError("Unexpected target_cpu value:" + target_cpu)
254
255
[email protected]4e8a2472014-03-19 22:01:39256def CopyVsRuntimeDlls(output_dir, runtime_dirs):
257 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
258 directory so that even if not system-installed, built binaries are likely to
259 be able to run.
260
261 This needs to be run after gyp has been run so that the expected target
262 output directories are already created.
brucedawsonaaff8dc2015-11-21 02:21:52263
264 This is used for the GYP build and gclient runhooks.
[email protected]4e8a2472014-03-19 22:01:39265 """
[email protected]4e8a2472014-03-19 22:01:39266 x86, x64 = runtime_dirs
267 out_debug = os.path.join(output_dir, 'Debug')
268 out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
269 out_release = os.path.join(output_dir, 'Release')
270 out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64')
271 out_debug_x64 = os.path.join(output_dir, 'Debug_x64')
272 out_release_x64 = os.path.join(output_dir, 'Release_x64')
273
274 if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64):
275 os.makedirs(out_debug_nacl64)
276 if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
277 os.makedirs(out_release_nacl64)
brucedawsonaaff8dc2015-11-21 02:21:52278 _CopyRuntime(out_debug, x86, "x86", debug=True)
279 _CopyRuntime(out_release, x86, "x86", debug=False)
280 _CopyRuntime(out_debug_x64, x64, "x64", debug=True)
281 _CopyRuntime(out_release_x64, x64, "x64", debug=False)
282 _CopyRuntime(out_debug_nacl64, x64, "x64", debug=True)
283 _CopyRuntime(out_release_nacl64, x64, "x64", debug=False)
dpranke0b951952014-11-15 00:09:14284
285
dpranke43276212015-02-20 02:55:19286def CopyDlls(target_dir, configuration, target_cpu):
dpranke0b951952014-11-15 00:09:14287 """Copy the VS runtime DLLs into the requested directory as needed.
288
289 configuration is one of 'Debug' or 'Release'.
dpranke43276212015-02-20 02:55:19290 target_cpu is one of 'x86' or 'x64'.
dpranke0b951952014-11-15 00:09:14291
292 The debug configuration gets both the debug and release DLLs; the
293 release config only the latter.
brucedawsonaaff8dc2015-11-21 02:21:52294
295 This is used for the GN build.
dpranke0b951952014-11-15 00:09:14296 """
brucedawsonaaff8dc2015-11-21 02:21:52297 vs_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
298 if not vs_runtime_dll_dirs:
dpranke0b951952014-11-15 00:09:14299 return
300
brucedawsonaaff8dc2015-11-21 02:21:52301 x64_runtime, x86_runtime = vs_runtime_dll_dirs
dpranke43276212015-02-20 02:55:19302 runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime
brucedawsonaaff8dc2015-11-21 02:21:52303 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
dpranke0b951952014-11-15 00:09:14304 if configuration == 'Debug':
brucedawsonaaff8dc2015-11-21 02:21:52305 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
[email protected]33222522014-07-22 00:18:32306
[email protected]4e8a2472014-03-19 22:01:39307
[email protected]c71d3282014-04-09 01:56:20308def _GetDesiredVsToolchainHashes():
309 """Load a list of SHA1s corresponding to the toolchains that we want installed
310 to build with."""
thestig9b24fa52017-03-11 01:46:42311 env_version = GetVisualStudioVersion()
thestig9b24fa52017-03-11 01:46:42312 if env_version == '2015':
scottmgb77dd492016-12-08 05:58:07313 # Update 3 final with patches with 10.0.14393.0 SDK.
314 return ['d3cb0e37bdd120ad0ac4650b674b09e81be45616']
brucedawson560bb952017-03-24 23:10:01315 if env_version == '2017':
brucedawson6a01e982017-03-28 23:28:26316 # VS 2017 RTM with 10.0.14393.0 SDK and dbghelp.dll fixes.
317 return ['4e8a360587a3c8ff3fa46aa9271e982bf3e948ec']
thestig9b24fa52017-03-11 01:46:42318 raise Exception('Unsupported VS version %s' % env_version)
[email protected]c71d3282014-04-09 01:56:20319
320
sebmarchande44b02e2016-01-15 22:29:57321def ShouldUpdateToolchain():
322 """Check if the toolchain should be upgraded."""
323 if not os.path.exists(json_data_file):
324 return True
325 with open(json_data_file, 'r') as tempf:
326 toolchain_data = json.load(tempf)
327 version = toolchain_data['version']
328 env_version = GetVisualStudioVersion()
329 # If there's a mismatch between the version set in the environment and the one
330 # in the json file then the toolchain should be updated.
331 return version != env_version
332
333
thakis4f4b1372015-08-11 22:25:00334def Update(force=False):
[email protected]c71d3282014-04-09 01:56:20335 """Requests an update of the toolchain to the specific hashes we have at
336 this revision. The update outputs a .json of the various configuration
337 information required to pass to gyp which we use in |GetToolchainDir()|.
338 """
thakis4f4b1372015-08-11 22:25:00339 if force != False and force != '--force':
340 print >>sys.stderr, 'Unknown parameter "%s"' % force
341 return 1
342 if force == '--force' or os.path.exists(json_data_file):
343 force = True
344
[email protected]c71d3282014-04-09 01:56:20345 depot_tools_win_toolchain = \
346 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
thakis4f4b1372015-08-11 22:25:00347 if ((sys.platform in ('win32', 'cygwin') or force) and
348 depot_tools_win_toolchain):
[email protected]c71d3282014-04-09 01:56:20349 import find_depot_tools
350 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
brucedawson2b33e7e2016-03-11 19:55:25351 # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit
352 # in the correct directory.
353 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
[email protected]c71d3282014-04-09 01:56:20354 get_toolchain_args = [
355 sys.executable,
356 os.path.join(depot_tools_path,
357 'win_toolchain',
358 'get_toolchain_if_necessary.py'),
359 '--output-json', json_data_file,
360 ] + _GetDesiredVsToolchainHashes()
thakis4f4b1372015-08-11 22:25:00361 if force:
362 get_toolchain_args.append('--force')
[email protected]c71d3282014-04-09 01:56:20363 subprocess.check_call(get_toolchain_args)
364
[email protected]4e8a2472014-03-19 22:01:39365 return 0
366
[email protected]ffe205622014-03-20 17:42:25367
brucedawson12bbca42016-03-23 00:58:06368def NormalizePath(path):
369 while path.endswith("\\"):
370 path = path[:-1]
371 return path
372
373
jochen6c29ace2017-02-15 22:45:26374def SetEnvironmentAndGetSDKDir():
375 """Gets location information about the current sdk (must have been
[email protected]308a6cae2014-05-28 20:32:01376 previously updated by 'update'). This is used for the GN build."""
scottmg9bf8fb32014-11-19 19:33:28377 runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
ckocagilfc8d7f232014-09-30 19:31:43378
379 # If WINDOWSSDKDIR is not set, search the default SDK path and set it.
380 if not 'WINDOWSSDKDIR' in os.environ:
brucedawson953e3762016-01-21 23:35:35381 default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10'
ckocagilfc8d7f232014-09-30 19:31:43382 if os.path.isdir(default_sdk_path):
383 os.environ['WINDOWSSDKDIR'] = default_sdk_path
384
jochen6c29ace2017-02-15 22:45:26385 return NormalizePath(os.environ['WINDOWSSDKDIR'])
386
387
388def GetToolchainDir():
389 """Gets location information about the current toolchain (must have been
390 previously updated by 'update'). This is used for the GN build."""
391 runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
392 win_sdk_dir = SetEnvironmentAndGetSDKDir()
393
[email protected]308a6cae2014-05-28 20:32:01394 print '''vs_path = "%s"
395sdk_path = "%s"
396vs_version = "%s"
397wdk_dir = "%s"
scottmg9bf8fb32014-11-19 19:33:28398runtime_dirs = "%s"
[email protected]308a6cae2014-05-28 20:32:01399''' % (
brucedawson12bbca42016-03-23 00:58:06400 NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH']),
jochen6c29ace2017-02-15 22:45:26401 win_sdk_dir,
halton.huo815e1772016-01-13 02:23:30402 GetVisualStudioVersion(),
brucedawson12bbca42016-03-23 00:58:06403 NormalizePath(os.environ.get('WDK_DIR', '')),
thakis44a40f82016-02-15 18:18:01404 os.path.pathsep.join(runtime_dll_dirs or ['None']))
[email protected]c71d3282014-04-09 01:56:20405
406
407def main():
[email protected]c71d3282014-04-09 01:56:20408 commands = {
409 'update': Update,
410 'get_toolchain_dir': GetToolchainDir,
dpranke0b951952014-11-15 00:09:14411 'copy_dlls': CopyDlls,
[email protected]c71d3282014-04-09 01:56:20412 }
413 if len(sys.argv) < 2 or sys.argv[1] not in commands:
414 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
415 return 1
dpranke0b951952014-11-15 00:09:14416 return commands[sys.argv[1]](*sys.argv[2:])
[email protected]c71d3282014-04-09 01:56:20417
418
[email protected]4e8a2472014-03-19 22:01:39419if __name__ == '__main__':
420 sys.exit(main())