Support VS 2017 Preview and changed VS directories

VS 2017 Preview installs to a different directory from VS 2017 RTM, so
the packaging script needs to be updated to handle this. It does this by
using vswhere.exe so that any VS 2017 install can be found
automatically. If there are multiple installs then it is not well
defined which one will be found, so make sure you don't have multiple
installs.

The other change is to more robustly find the many directory paths which
contain embedded version numbers. Previously these were hard-coded for
VS 2017 RTM but this quickly gets tedious so now glob.glob is used to
find the matching directories. This will intentionally fail if there is
any ambiguity.

R=scottmg@chromium.org
BUG=683729

Change-Id: I02f7ae7589e271d6d9897f899e0730d7163f76ef
Reviewed-on: https://chromium-review.googlesource.com/516442
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
changes/42/516442/4
Bruce Dawson 8 years ago committed by Commit Bot
parent 05fec0394f
commit aad003b6c1

@ -28,6 +28,7 @@ import optparse
import os
import platform
import shutil
import subprocess
import sys
import tempfile
import zipfile
@ -39,6 +40,32 @@ VS_VERSION = None
WIN_VERSION = None
VC_TOOLS = None
def GetVSPath():
if VS_VERSION == '2015':
return r'C:\Program Files (x86)\Microsoft Visual Studio 14.0'
elif VS_VERSION == '2017':
# Use vswhere to find the VS 2017 installation. This handles preview
# versions automatically. This assumes that only one version is installed.
command = (r'C:\Program Files (x86)\Microsoft Visual Studio\Installer'
r'\vswhere.exe')
marker = 'installationPath: '
for line in subprocess.check_output(command).splitlines():
if line.startswith(marker):
return line[len(marker):]
raise Exception('VS 2017 path not found in vswhere output')
else:
raise ValueError(VS_VERSION)
def ExpandWildcards(root, sub_dir):
# normpath is needed to change '/' to '\\' characters.
matches = glob.glob(os.path.normpath(os.path.join(root, sub_dir)))
if len(matches) != 1:
raise Exception('%s had %d matches - should be one' % (full, len(matches)))
return matches[0]
def BuildFileList(override_dir):
result = []
@ -83,34 +110,28 @@ def BuildFileList(override_dir):
]
elif VS_VERSION == '2017':
paths += [
('VC/redist/MSVC/14.10.25008/x86/Microsoft.VC150.CRT', 'sys32'),
('VC/redist/MSVC/14.10.25008/x86/Microsoft.VC150.CRT', 'win_sdk/bin/x86'),
('VC/redist/MSVC/14.10.25017/x86/Microsoft.VC150.MFC', 'sys32'),
('VC/redist/MSVC/14.10.25008/debug_nonredist/x86/Microsoft.VC150.DebugCRT', 'sys32'),
('VC/redist/MSVC/14.10.25017/debug_nonredist/x86/Microsoft.VC150.DebugMFC', 'sys32'),
('VC/redist/MSVC/14.10.25008/x64/Microsoft.VC150.CRT', 'sys64'),
('VC/redist/MSVC/14.10.25008/x64/Microsoft.VC150.CRT', 'VC/bin/amd64_x86'),
('VC/redist/MSVC/14.10.25008/x64/Microsoft.VC150.CRT', 'VC/bin/amd64'),
('VC/redist/MSVC/14.10.25008/x64/Microsoft.VC150.CRT', 'win_sdk/bin/x64'),
('VC/redist/MSVC/14.10.25017/x64/Microsoft.VC150.MFC', 'sys64'),
('VC/redist/MSVC/14.10.25008/debug_nonredist/x64/Microsoft.VC150.DebugCRT', 'sys64'),
('VC/redist/MSVC/14.10.25017/debug_nonredist/x64/Microsoft.VC150.DebugMFC', 'sys64'),
('VC/redist/MSVC/14.*.*/x86/Microsoft.VC150.CRT', 'sys32'),
('VC/redist/MSVC/14.*.*/x86/Microsoft.VC150.CRT', 'win_sdk/bin/x86'),
('VC/redist/MSVC/14.*.*/x86/Microsoft.VC150.MFC', 'sys32'),
('VC/redist/MSVC/14.*.*/debug_nonredist/x86/Microsoft.VC150.DebugCRT', 'sys32'),
('VC/redist/MSVC/14.*.*/debug_nonredist/x86/Microsoft.VC150.DebugMFC', 'sys32'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC150.CRT', 'sys64'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC150.CRT', 'VC/bin/amd64_x86'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC150.CRT', 'VC/bin/amd64'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC150.CRT', 'win_sdk/bin/x64'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC150.MFC', 'sys64'),
('VC/redist/MSVC/14.*.*/debug_nonredist/x64/Microsoft.VC150.DebugCRT', 'sys64'),
('VC/redist/MSVC/14.*.*/debug_nonredist/x64/Microsoft.VC150.DebugMFC', 'sys64'),
]
else:
raise ValueError('VS_VERSION %s' % VS_VERSION)
if VS_VERSION == '2015':
vs_path = r'C:\Program Files (x86)\Microsoft Visual Studio 14.0'
elif VS_VERSION == '2017':
vs_path = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional'
else:
assert ValueError(VS_VERSION)
vs_path = GetVSPath()
for path in paths:
src = path[0] if isinstance(path, tuple) else path
# Note that vs_path is ignored if src is an absolute path.
# normpath is needed to change '/' to '\\' characters.
combined = os.path.normpath(os.path.join(vs_path, src))
combined = ExpandWildcards(vs_path, src)
if not os.path.exists(combined):
raise Exception('%s missing.' % combined)
if not os.path.isdir(combined):
@ -389,7 +410,10 @@ def main():
WIN_VERSION = options.winver
global VC_TOOLS
if VS_VERSION == '2017':
VC_TOOLS = 'VC/Tools/MSVC/14.10.25017'
vs_path = GetVSPath()
temp_tools_path = ExpandWildcards(vs_path, 'VC/Tools/MSVC/14.*.*')
# Strip off the leading vs_path characters and switch back to / separators.
VC_TOOLS = temp_tools_path[len(vs_path) + 1:].replace('\\', '/')
else:
VC_TOOLS = 'VC'

Loading…
Cancel
Save