blob: c5db1b249e40ff8df0986bad566df879563c2299 [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
24import gyp
25
26
brucedawson2b33e7e2016-03-11 19:55:2527# Use MSVS2015 as the default toolchain.
28CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015'
sebmarchande44b02e2016-01-15 22:29:5729
30
[email protected]c71d3282014-04-09 01:56:2031def SetEnvironmentAndGetRuntimeDllDirs():
32 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
33 returns the location of the VS runtime DLLs so they can be copied into
34 the output directory after gyp generation.
brucedawsone7bd0342016-06-01 18:37:1835
36 Return value is [x64path, x86path] or None
[email protected]4e8a2472014-03-19 22:01:3937 """
brucedawsonaaff8dc2015-11-21 02:21:5238 vs_runtime_dll_dirs = None
[email protected]4e8a2472014-03-19 22:01:3939 depot_tools_win_toolchain = \
40 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
thakis4f4b1372015-08-11 22:25:0041 # When running on a non-Windows host, only do this if the SDK has explicitly
42 # been downloaded before (in which case json_data_file will exist).
scottmg05eac9c02015-08-25 23:03:3543 if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file))
44 and depot_tools_win_toolchain):
sebmarchande44b02e2016-01-15 22:29:5745 if ShouldUpdateToolchain():
[email protected]9372bec2014-08-14 14:03:3046 Update()
[email protected]c71d3282014-04-09 01:56:2047 with open(json_data_file, 'r') as tempf:
[email protected]4e8a2472014-03-19 22:01:3948 toolchain_data = json.load(tempf)
[email protected]4e8a2472014-03-19 22:01:3949
50 toolchain = toolchain_data['path']
51 version = toolchain_data['version']
scottmg54e45062015-06-02 01:15:4452 win_sdk = toolchain_data.get('win_sdk')
53 if not win_sdk:
54 win_sdk = toolchain_data['win8sdk']
[email protected]4e8a2472014-03-19 22:01:3955 wdk = toolchain_data['wdk']
56 # TODO(scottmg): The order unfortunately matters in these. They should be
57 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
58 # below). http://crbug.com/345992
brucedawsonaaff8dc2015-11-21 02:21:5259 vs_runtime_dll_dirs = toolchain_data['runtime_dirs']
[email protected]4e8a2472014-03-19 22:01:3960
61 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
62 os.environ['GYP_MSVS_VERSION'] = version
63 # We need to make sure windows_sdk_path is set to the automated
64 # toolchain values in GYP_DEFINES, but don't want to override any
65 # otheroptions.express
66 # values there.
67 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
scottmg54e45062015-06-02 01:15:4468 gyp_defines_dict['windows_sdk_path'] = win_sdk
[email protected]4e8a2472014-03-19 22:01:3969 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
70 for k, v in gyp_defines_dict.iteritems())
scottmg54e45062015-06-02 01:15:4471 os.environ['WINDOWSSDKDIR'] = win_sdk
[email protected]4e8a2472014-03-19 22:01:3972 os.environ['WDK_DIR'] = wdk
73 # Include the VS runtime in the PATH in case it's not machine-installed.
thakis44a40f82016-02-15 18:18:0174 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
75 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
bratellc7af8792016-01-07 16:30:1276 elif sys.platform == 'win32' and not depot_tools_win_toolchain:
77 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
78 os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
lwchkg833a437f2016-01-19 00:39:0879 if not 'GYP_MSVS_VERSION' in os.environ:
80 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
bratellc7af8792016-01-07 16:30:1281
brucedawsone7bd0342016-06-01 18:37:1882 # When using an installed toolchain these files aren't needed in the output
83 # directory in order to run binaries locally, but they are needed in order
84 # to create isolates or the mini_installer. Copying them to the output
85 # directory ensures that they are available when needed.
86 bitness = platform.architecture()[0]
87 # When running 64-bit python the x64 DLLs will be in System32
88 x64_path = 'System32' if bitness == '64bit' else 'Sysnative'
89 x64_path = os.path.join(r'C:\Windows', x64_path)
90 vs_runtime_dll_dirs = [x64_path, r'C:\Windows\SysWOW64']
91
brucedawsonaaff8dc2015-11-21 02:21:5292 return vs_runtime_dll_dirs
[email protected]4e8a2472014-03-19 22:01:3993
94
bratellc7af8792016-01-07 16:30:1295def _RegistryGetValueUsingWinReg(key, value):
96 """Use the _winreg module to obtain the value of a registry key.
97
98 Args:
99 key: The registry key.
100 value: The particular registry value to read.
101 Return:
102 contents of the registry key's value, or None on failure. Throws
103 ImportError if _winreg is unavailable.
104 """
105 import _winreg
106 try:
107 root, subkey = key.split('\\', 1)
108 assert root == 'HKLM' # Only need HKLM for now.
109 with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey:
110 return _winreg.QueryValueEx(hkey, value)[0]
111 except WindowsError:
112 return None
113
114
115def _RegistryGetValue(key, value):
116 try:
117 return _RegistryGetValueUsingWinReg(key, value)
118 except ImportError:
119 raise Exception('The python library _winreg not found.')
120
121
halton.huo815e1772016-01-13 02:23:30122def GetVisualStudioVersion():
sebmarchande44b02e2016-01-15 22:29:57123 """Return GYP_MSVS_VERSION of Visual Studio.
halton.huo815e1772016-01-13 02:23:30124 """
sebmarchande44b02e2016-01-15 22:29:57125 return os.environ.get('GYP_MSVS_VERSION', CURRENT_DEFAULT_TOOLCHAIN_VERSION)
halton.huo815e1772016-01-13 02:23:30126
127
bratellc7af8792016-01-07 16:30:12128def DetectVisualStudioPath():
129 """Return path to the GYP_MSVS_VERSION of Visual Studio.
130 """
131
132 # Note that this code is used from
133 # build/toolchain/win/setup_toolchain.py as well.
halton.huo815e1772016-01-13 02:23:30134 version_as_year = GetVisualStudioVersion()
bratellc7af8792016-01-07 16:30:12135 year_to_version = {
136 '2013': '12.0',
137 '2015': '14.0',
brucedawsonadddab42017-01-23 06:57:21138 '2017': '15.0',
bratellc7af8792016-01-07 16:30:12139 }
140 if version_as_year not in year_to_version:
141 raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)'
142 ' not supported. Supported versions are: %s') % (
143 version_as_year, ', '.join(year_to_version.keys())))
144 version = year_to_version[version_as_year]
brucedawsonadddab42017-01-23 06:57:21145 if version_as_year == '2017':
146 # The VC++ 2017 install location needs to be located using COM instead of
147 # the registry. For details see:
148 # https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
149 # For now we use a hardcoded default with an environment variable override.
150 path = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional'
151 path = os.environ.get('vs2017_install', path)
152 if os.path.exists(path):
153 return path
154 else:
155 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version,
156 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version]
157 for key in keys:
158 path = _RegistryGetValue(key, 'InstallDir')
159 if not path:
160 continue
161 path = os.path.normpath(os.path.join(path, '..', '..'))
162 return path
bratellc7af8792016-01-07 16:30:12163
164 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)'
165 ' not found.') % (version_as_year))
166
167
scottmg54e45062015-06-02 01:15:44168def _VersionNumber():
169 """Gets the standard version number ('120', '140', etc.) based on
170 GYP_MSVS_VERSION."""
halton.huo815e1772016-01-13 02:23:30171 vs_version = GetVisualStudioVersion()
172 if vs_version == '2013':
scottmg54e45062015-06-02 01:15:44173 return '120'
halton.huo815e1772016-01-13 02:23:30174 elif vs_version == '2015':
scottmg54e45062015-06-02 01:15:44175 return '140'
brucedawsonadddab42017-01-23 06:57:21176 elif vs_version == '2017':
177 return '150'
scottmg54e45062015-06-02 01:15:44178 else:
179 raise ValueError('Unexpected GYP_MSVS_VERSION')
180
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
scottmg54e45062015-06-02 01:15:44202def _CopyRuntime2013(target_dir, source_dir, dll_pattern):
203 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
204 exist, but the target directory does exist."""
205 for file_part in ('p', 'r'):
206 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)
210
211
brucedawsonadddab42017-01-23 06:57:21212def _CopyUCRTRuntime(target_dir, source_dir, dll_pattern, suffix):
scottmg54e45062015-06-02 01:15:44213 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
214 exist, but the target directory does exist."""
sebmarchand7cebe212015-12-17 20:44:35215 for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
scottmg54e45062015-06-02 01:15:44216 dll = dll_pattern % file_part
217 target = os.path.join(target_dir, dll)
218 source = os.path.join(source_dir, dll)
219 _CopyRuntimeImpl(target, source)
brucedawsone7bd0342016-06-01 18:37:18220 # OS installs of Visual Studio (and all installs of Windows 10) put the
221 # universal CRT files in c:\Windows\System32\downlevel - look for them there
222 # to support DEPOT_TOOLS_WIN_TOOLCHAIN=0.
223 if os.path.exists(os.path.join(source_dir, 'downlevel')):
224 ucrt_src_glob = os.path.join(source_dir, 'downlevel', 'api-ms-win-*.dll')
225 else:
226 ucrt_src_glob = os.path.join(source_dir, 'api-ms-win-*.dll')
227 ucrt_files = glob.glob(ucrt_src_glob)
228 assert len(ucrt_files) > 0
229 for ucrt_src_file in ucrt_files:
brucedawsonc6f6c692016-02-22 23:09:18230 file_part = os.path.basename(ucrt_src_file)
231 ucrt_dst_file = os.path.join(target_dir, file_part)
232 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
233 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
234 os.path.join(source_dir, 'ucrtbase' + suffix))
dpranke0b951952014-11-15 00:09:14235
236
brucedawsonaaff8dc2015-11-21 02:21:52237def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
238 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target
brucedawsonadddab42017-01-23 06:57:21239 directory does exist. Handles VS 2013, VS 2015, and VS 2017."""
brucedawsonaaff8dc2015-11-21 02:21:52240 suffix = "d.dll" if debug else ".dll"
brucedawsonadddab42017-01-23 06:57:21241 if GetVisualStudioVersion() == '2015' or GetVisualStudioVersion() == '2017':
242 # VS 2017 RC uses the same CRT DLLs as VS 2015.
243 _CopyUCRTRuntime(target_dir, source_dir, '%s140' + suffix, suffix)
brucedawsonaaff8dc2015-11-21 02:21:52244 else:
245 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix)
246
247 # Copy the PGO runtime library to the release directories.
248 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
249 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
250 'VC', 'bin')
251 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
252 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll'
253 if target_cpu == "x86":
254 source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll)
255 if os.path.exists(source_x86):
256 _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll), source_x86)
257 elif target_cpu == "x64":
258 source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll)
259 if os.path.exists(source_x64):
260 _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll),
261 source_x64)
262 else:
263 raise NotImplementedError("Unexpected target_cpu value:" + target_cpu)
264
265
[email protected]4e8a2472014-03-19 22:01:39266def CopyVsRuntimeDlls(output_dir, runtime_dirs):
267 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
268 directory so that even if not system-installed, built binaries are likely to
269 be able to run.
270
271 This needs to be run after gyp has been run so that the expected target
272 output directories are already created.
brucedawsonaaff8dc2015-11-21 02:21:52273
274 This is used for the GYP build and gclient runhooks.
[email protected]4e8a2472014-03-19 22:01:39275 """
[email protected]4e8a2472014-03-19 22:01:39276 x86, x64 = runtime_dirs
277 out_debug = os.path.join(output_dir, 'Debug')
278 out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
279 out_release = os.path.join(output_dir, 'Release')
280 out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64')
281 out_debug_x64 = os.path.join(output_dir, 'Debug_x64')
282 out_release_x64 = os.path.join(output_dir, 'Release_x64')
283
284 if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64):
285 os.makedirs(out_debug_nacl64)
286 if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
287 os.makedirs(out_release_nacl64)
brucedawsonaaff8dc2015-11-21 02:21:52288 _CopyRuntime(out_debug, x86, "x86", debug=True)
289 _CopyRuntime(out_release, x86, "x86", debug=False)
290 _CopyRuntime(out_debug_x64, x64, "x64", debug=True)
291 _CopyRuntime(out_release_x64, x64, "x64", debug=False)
292 _CopyRuntime(out_debug_nacl64, x64, "x64", debug=True)
293 _CopyRuntime(out_release_nacl64, x64, "x64", debug=False)
dpranke0b951952014-11-15 00:09:14294
295
dpranke43276212015-02-20 02:55:19296def CopyDlls(target_dir, configuration, target_cpu):
dpranke0b951952014-11-15 00:09:14297 """Copy the VS runtime DLLs into the requested directory as needed.
298
299 configuration is one of 'Debug' or 'Release'.
dpranke43276212015-02-20 02:55:19300 target_cpu is one of 'x86' or 'x64'.
dpranke0b951952014-11-15 00:09:14301
302 The debug configuration gets both the debug and release DLLs; the
303 release config only the latter.
brucedawsonaaff8dc2015-11-21 02:21:52304
305 This is used for the GN build.
dpranke0b951952014-11-15 00:09:14306 """
brucedawsonaaff8dc2015-11-21 02:21:52307 vs_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
308 if not vs_runtime_dll_dirs:
dpranke0b951952014-11-15 00:09:14309 return
310
brucedawsonaaff8dc2015-11-21 02:21:52311 x64_runtime, x86_runtime = vs_runtime_dll_dirs
dpranke43276212015-02-20 02:55:19312 runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime
brucedawsonaaff8dc2015-11-21 02:21:52313 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
dpranke0b951952014-11-15 00:09:14314 if configuration == 'Debug':
brucedawsonaaff8dc2015-11-21 02:21:52315 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
[email protected]33222522014-07-22 00:18:32316
jochen6c29ace2017-02-15 22:45:26317 _CopyDebugger(target_dir, target_cpu)
318
319
320def _CopyDebugger(target_dir, target_cpu):
321 """Copy cdb.exe into the requested directory as needed.
322
323 target_cpu is one of 'x86' or 'x64'.
324
325 This is used for the GN build.
326 """
327 win_sdk_dir = SetEnvironmentAndGetSDKDir()
328 if not win_sdk_dir:
329 return
330
331 debugger_files = (
332 'cdb.exe', 'dbgeng.dll', 'dbghelp.dll', 'dbgmodel.dll', 'dbgcore.dll')
333
334 for debug_file in debugger_files:
335 full_path = os.path.join(win_sdk_dir, 'Debuggers', target_cpu, debug_file)
336 target_path = os.path.join(target_dir, debug_file)
337 _CopyRuntimeImpl(target_path, full_path)
338
[email protected]4e8a2472014-03-19 22:01:39339
[email protected]c71d3282014-04-09 01:56:20340def _GetDesiredVsToolchainHashes():
341 """Load a list of SHA1s corresponding to the toolchains that we want installed
342 to build with."""
halton.huo815e1772016-01-13 02:23:30343 if GetVisualStudioVersion() == '2015':
scottmgb77dd492016-12-08 05:58:07344 # Update 3 final with patches with 10.0.14393.0 SDK.
345 return ['d3cb0e37bdd120ad0ac4650b674b09e81be45616']
scottmg54e45062015-06-02 01:15:44346 else:
brucedawsonb10de5ec2016-04-13 18:18:53347 return ['03a4e939cd325d6bc5216af41b92d02dda1366a6']
[email protected]c71d3282014-04-09 01:56:20348
349
sebmarchande44b02e2016-01-15 22:29:57350def ShouldUpdateToolchain():
351 """Check if the toolchain should be upgraded."""
352 if not os.path.exists(json_data_file):
353 return True
354 with open(json_data_file, 'r') as tempf:
355 toolchain_data = json.load(tempf)
356 version = toolchain_data['version']
357 env_version = GetVisualStudioVersion()
358 # If there's a mismatch between the version set in the environment and the one
359 # in the json file then the toolchain should be updated.
360 return version != env_version
361
362
thakis4f4b1372015-08-11 22:25:00363def Update(force=False):
[email protected]c71d3282014-04-09 01:56:20364 """Requests an update of the toolchain to the specific hashes we have at
365 this revision. The update outputs a .json of the various configuration
366 information required to pass to gyp which we use in |GetToolchainDir()|.
367 """
thakis4f4b1372015-08-11 22:25:00368 if force != False and force != '--force':
369 print >>sys.stderr, 'Unknown parameter "%s"' % force
370 return 1
371 if force == '--force' or os.path.exists(json_data_file):
372 force = True
373
[email protected]c71d3282014-04-09 01:56:20374 depot_tools_win_toolchain = \
375 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
thakis4f4b1372015-08-11 22:25:00376 if ((sys.platform in ('win32', 'cygwin') or force) and
377 depot_tools_win_toolchain):
[email protected]c71d3282014-04-09 01:56:20378 import find_depot_tools
379 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
brucedawson2b33e7e2016-03-11 19:55:25380 # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit
381 # in the correct directory.
382 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
[email protected]c71d3282014-04-09 01:56:20383 get_toolchain_args = [
384 sys.executable,
385 os.path.join(depot_tools_path,
386 'win_toolchain',
387 'get_toolchain_if_necessary.py'),
388 '--output-json', json_data_file,
389 ] + _GetDesiredVsToolchainHashes()
thakis4f4b1372015-08-11 22:25:00390 if force:
391 get_toolchain_args.append('--force')
[email protected]c71d3282014-04-09 01:56:20392 subprocess.check_call(get_toolchain_args)
393
[email protected]4e8a2472014-03-19 22:01:39394 return 0
395
[email protected]ffe205622014-03-20 17:42:25396
brucedawson12bbca42016-03-23 00:58:06397def NormalizePath(path):
398 while path.endswith("\\"):
399 path = path[:-1]
400 return path
401
402
jochen6c29ace2017-02-15 22:45:26403def SetEnvironmentAndGetSDKDir():
404 """Gets location information about the current sdk (must have been
[email protected]308a6cae2014-05-28 20:32:01405 previously updated by 'update'). This is used for the GN build."""
scottmg9bf8fb32014-11-19 19:33:28406 runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
ckocagilfc8d7f232014-09-30 19:31:43407
408 # If WINDOWSSDKDIR is not set, search the default SDK path and set it.
409 if not 'WINDOWSSDKDIR' in os.environ:
brucedawson953e3762016-01-21 23:35:35410 default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10'
ckocagilfc8d7f232014-09-30 19:31:43411 if os.path.isdir(default_sdk_path):
412 os.environ['WINDOWSSDKDIR'] = default_sdk_path
413
jochen6c29ace2017-02-15 22:45:26414 return NormalizePath(os.environ['WINDOWSSDKDIR'])
415
416
417def GetToolchainDir():
418 """Gets location information about the current toolchain (must have been
419 previously updated by 'update'). This is used for the GN build."""
420 runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
421 win_sdk_dir = SetEnvironmentAndGetSDKDir()
422
[email protected]308a6cae2014-05-28 20:32:01423 print '''vs_path = "%s"
424sdk_path = "%s"
425vs_version = "%s"
426wdk_dir = "%s"
scottmg9bf8fb32014-11-19 19:33:28427runtime_dirs = "%s"
[email protected]308a6cae2014-05-28 20:32:01428''' % (
brucedawson12bbca42016-03-23 00:58:06429 NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH']),
jochen6c29ace2017-02-15 22:45:26430 win_sdk_dir,
halton.huo815e1772016-01-13 02:23:30431 GetVisualStudioVersion(),
brucedawson12bbca42016-03-23 00:58:06432 NormalizePath(os.environ.get('WDK_DIR', '')),
thakis44a40f82016-02-15 18:18:01433 os.path.pathsep.join(runtime_dll_dirs or ['None']))
[email protected]c71d3282014-04-09 01:56:20434
435
436def main():
[email protected]c71d3282014-04-09 01:56:20437 commands = {
438 'update': Update,
439 'get_toolchain_dir': GetToolchainDir,
dpranke0b951952014-11-15 00:09:14440 'copy_dlls': CopyDlls,
[email protected]c71d3282014-04-09 01:56:20441 }
442 if len(sys.argv) < 2 or sys.argv[1] not in commands:
443 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
444 return 1
dpranke0b951952014-11-15 00:09:14445 return commands[sys.argv[1]](*sys.argv[2:])
[email protected]c71d3282014-04-09 01:56:20446
447
[email protected]4e8a2472014-03-19 22:01:39448if __name__ == '__main__':
449 sys.exit(main())