[pkg-d-commits] [ldc] 79/95: MSVC: Detect VS 2017 and VS Build Tools 2017
Matthias Klumpp
mak at moszumanska.debian.org
Thu Jul 13 20:54:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.3.0-beta1
in repository ldc.
commit 236bd2651a7f4e5b38767f03dd7c05f3bccfddb9
Author: Martin <noone at nowhere.com>
Date: Sat Apr 8 22:11:57 2017 +0200
MSVC: Detect VS 2017 and VS Build Tools 2017
The Visual Studio Build Tools 2017 path is nowhere in the registry, so
only attempt to locate it in its default installation path.
VS 2017 revamps the directory structure, so use another batch file to set
up the environment (Common7\Tools\VsDevCmd.bat).
---
vcbuild/msvcEnv.bat | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/vcbuild/msvcEnv.bat b/vcbuild/msvcEnv.bat
index eb714f0..6555532 100644
--- a/vcbuild/msvcEnv.bat
+++ b/vcbuild/msvcEnv.bat
@@ -3,20 +3,33 @@
:: Environment already set up?
if not "%VSINSTALLDIR%"=="" goto :eof
+:: Skip detection if an existing LDC_VSDIR environment variable points to an existing folder
if "%LDC_VSDIR%"=="" goto detect
-
-:: Check if the existing LDC_VSDIR environment variable points to a VS/VC installation folder
if not "%LDC_VSDIR:~-1%"=="\" set LDC_VSDIR=%LDC_VSDIR%\
-if not "%LDC_VSDIR:~-4%"=="\VC\" set LDC_VSDIR=%LDC_VSDIR%VC\
-if exist "%LDC_VSDIR%vcvarsall.bat" goto setup
+if exist "%LDC_VSDIR%" goto setup
-:: Try to detect the latest VC installation directory
+:: Try to detect the latest VS installation directory
:detect
set LDC_VSDIR=
+:: VC++ 2013
for /F "tokens=1,2*" %%i in ('reg query HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\Setup\VC /v ProductDir 2^> nul') do set LDC_VSDIR=%%k
for /F "tokens=1,2*" %%i in ('reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\12.0\Setup\VC /v ProductDir 2^> nul') do set LDC_VSDIR=%%k
+:: VC++ 2015
for /F "tokens=1,2*" %%i in ('reg query HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC /v ProductDir 2^> nul') do set LDC_VSDIR=%%k
for /F "tokens=1,2*" %%i in ('reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\Setup\VC /v ProductDir 2^> nul') do set LDC_VSDIR=%%k
+:: (remove 'VC\' suffix)
+if not "%LDC_VSDIR%"=="" set LDC_VSDIR=%LDC_VSDIR:~0,-3%
+:: VS Build Tools 2017 (default installation path)
+if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\" set LDC_VSDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\
+if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools\" set LDC_VSDIR=%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools\
+:: VS 2017
+for /F "tokens=1,2*" %%i in ('reg query HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7 /v 15.0 2^> nul') do (
+ if exist "%%kVC\Auxiliary\Build\vcvarsall.bat" set LDC_VSDIR=%%k
+)
+for /F "tokens=1,2*" %%i in ('reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 /v 15.0 2^> nul') do (
+ if exist "%%kVC\Auxiliary\Build\vcvarsall.bat" set LDC_VSDIR=%%k
+)
+
if "%LDC_VSDIR%"=="" (
echo WARNING: no Visual C++ installation detected
goto :eof
@@ -24,10 +37,15 @@ if "%LDC_VSDIR%"=="" (
:: Let MSVC set up environment variables
:setup
-echo Using Visual C++: %LDC_VSDIR:~0,-1%
-if not exist "%LDC_VSDIR%vcvarsall.bat" (
- echo WARNING: could not find vcvarsall.bat
+echo Using Visual Studio: %LDC_VSDIR:~0,-1%
+:: VC++ 2013/2015
+if exist "%LDC_VSDIR%VC\vcvarsall.bat" (
+ call "%LDC_VSDIR%VC\vcvarsall.bat" %1
+ goto :eof
+)
+:: VC++ 2017
+if exist "%LDC_VSDIR%Common7\Tools\vsdevcmd.bat" (
+ call "%LDC_VSDIR%Common7\Tools\vsdevcmd.bat" -arch=%1 -no_logo
goto :eof
)
-:: Forward the first arg to the MS batch file
-call "%LDC_VSDIR%vcvarsall.bat" %1
+echo WARNING: could not find Visual C++ batch file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list