Commit e169e997 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Update tools\win\setenv.bat to support VS 2019

tools\win\setenv.bat is a mostly unknown but sometimes useful batch file
that adds the VS tools to the path. It respects the value of
DEPOT_TOOLS_WIN_TOOLCHAIN and the current toolchain hash. This change
updates it to add support for VS 2019, and remove support for VS 2015.
It also takes away support for selecting 32-bit versus 64-bit target
toolchains because this feature was never used and was too much work to
support (since the packaged toolchain and vcvarsall.bat flags are
different).

This change also fixes a bug where the name of the batch file would be
retained in the command-prompt title after this script exits. Using the
"call" command fixes that. The retained title is ultimately a Windows
command prompt bug which is not going to get fixed. Adding the call
command then requires quoting the command path in the Python script.

Change-Id: I2b4943dc1e391d9fb4a9e76dd8b592223dc31fb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392013
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarJesse McKenna <jessemckenna@google.com>
Cr-Commit-Position: refs/heads/master@{#804940}
parent e4530b95
...@@ -8,7 +8,7 @@ REM Run this script to add the current toolchain, as determined by ...@@ -8,7 +8,7 @@ REM Run this script to add the current toolchain, as determined by
REM DEPOT_TOOLS_WIN_TOOLCHAIN and the hash in vs_toolchain.py, REM DEPOT_TOOLS_WIN_TOOLCHAIN and the hash in vs_toolchain.py,
REM to the path. Be aware of running this multiple times as too-long paths will REM to the path. Be aware of running this multiple times as too-long paths will
REM break things. REM break things.
REM To get the toolchain for x64 targets pass /x64 to this batch file.
REM Execute whatever is printed by setenv.py. REM Execute whatever is printed by setenv.py. Use "CALL" to ensure that the
FOR /f "usebackq tokens=*" %%a in (`python %~dp0setenv.py`) do %%a %1 REM command title is reset when this script finishes executing.
FOR /f "usebackq tokens=*" %%a in (`python %~dp0setenv.py`) do CALL %%a
...@@ -19,13 +19,13 @@ import vs_toolchain ...@@ -19,13 +19,13 @@ import vs_toolchain
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))): if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))):
win_sdk_dir = vs_toolchain.SetEnvironmentAndGetSDKDir() win_sdk_dir = vs_toolchain.SetEnvironmentAndGetSDKDir()
print(os.path.normpath(os.path.join(win_sdk_dir, 'bin/SetEnv.cmd'))) script_path = os.path.normpath(os.path.join(win_sdk_dir, 'bin/SetEnv.cmd'))
print('"%s" /x64' % script_path)
else: else:
vs_version = vs_toolchain.GetVisualStudioVersion() vs_version = vs_toolchain.GetVisualStudioVersion()
vs_path = vs_toolchain.DetectVisualStudioPath() vs_path = vs_toolchain.DetectVisualStudioPath()
if vs_version == '2017': if vs_version in ['2017', '2019']:
print(os.path.join(vs_path, r'VC\Auxiliary\Build\vcvarsall.bat')) script_path = os.path.join(vs_path, r'VC\Auxiliary\Build\vcvarsall.bat')
elif vs_version == '2015': print('"%s" amd64' % script_path)
print(os.path.join(vs_path, r'VC\vcvarsall.bat'))
else: else:
raise Exception('Unknown VS version %s' % vs_version) raise Exception('Unknown VS version %s' % vs_version)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment