Skip to content

Commit

Permalink
VS2017 get path using vswhere
Browse files Browse the repository at this point in the history
References:

https://blogs.msdn.microsoft.com/heaths/2017/04/21/vswhere-is-now-installed-with-visual-studio-2017/
https://github.com/Microsoft/vswhere/wiki/Find-VC
Seems safe to assume vswhere location in %ProgramFiles(x86)%\Microsoft
Visual Studio\Installer
  • Loading branch information
madrazo committed Aug 25, 2017
1 parent 9948baf commit 7ae6b65
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
12 changes: 6 additions & 6 deletions toolchain/msvc-setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ setlocal enabledelayedexpansion
@call "%HXCPP_MSVC%\vcvars32.bat"
@echo HXCPP_VARS
@set
) else if exist "%HXCPP_MSVC%\vsvars32.bat" (
@call "%HXCPP_MSVC%\vsvars32.bat"
@echo HXCPP_VARS
@set
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" (
@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=x86 -app_platform=Desktop -no_logo
) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set InstallDir=%%i
)
@echo "!InstallDir!"
call "!InstallDir!\Common7\Tools\VsDevCmd.bat" -arch=x86 -app_platform=Desktop -no_logo
@echo HXCPP_VARS
@set
) else if exist "%VS140COMNTOOLS%\vsvars32.bat" (
Expand Down
14 changes: 9 additions & 5 deletions toolchain/msvc-winrt-setup.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
setlocal enabledelayedexpansion
@if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" (
@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=x86 -app_platform=UWP -no_logo
@echo HXCPP_VARS
@set
@if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set InstallDir=%%i
)
@echo "!InstallDir!"
call "!InstallDir!\Common7\Tools\VsDevCmd.bat" -arch=x86 -app_platform=UWP -no_logo
@echo HXCPP_VARS
@set
) else if exist "%VS140COMNTOOLS%\vsvars32.bat" (
@call "%VS140COMNTOOLS%\vsvars32.bat"
@set "INCLUDE=%WindowsSdkDir%Include;!INCLUDE!"
Expand All @@ -12,5 +16,5 @@ setlocal enabledelayedexpansion
@echo HXCPP_VARS
@set
) else (
echo Warning: Could not find environment variables for Visual Studio 2015
echo Warning: Could not find environment variables for Visual Studio 2015 or 2017
)
14 changes: 9 additions & 5 deletions toolchain/msvc-winrt64-setup.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
setlocal enabledelayedexpansion
@if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" (
@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -app_platform=UWP -no_logo
@echo HXCPP_VARS
@set
@if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set InstallDir=%%i
)
@echo "!InstallDir!"
call "!InstallDir!\Common7\Tools\VsDevCmd.bat" -arch=amd64 -app_platform=UWP -no_logo
@echo HXCPP_VARS
@set
) else if exist "%VS140COMNTOOLS%\..\..\VC\bin\x86_amd64\vcvarsx86_amd64.bat" (
@call "%VS140COMNTOOLS%\..\..\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
@set "INCLUDE=%WindowsSdkDir%Include;!INCLUDE!"
Expand All @@ -13,5 +17,5 @@ setlocal enabledelayedexpansion
@set
@echo HXCPP_HACK_PDBSRV=1
) else (
echo Warning: Could not find x64 environment variables for Visual Studio 2015
echo Warning: Could not find x64 environment variables for Visual Studio 2015 or 2017
)
10 changes: 7 additions & 3 deletions toolchain/msvc64-setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ setlocal enabledelayedexpansion
@echo HXCPP_VARS
@set
)
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" (
@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -app_platform=Desktop -no_logo
) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set InstallDir=%%i
)
@echo "!InstallDir!"
call "!InstallDir!\Common7\Tools\VsDevCmd.bat" -arch=amd64 -app_platform=Desktop -no_logo
@echo HXCPP_VARS
@set
) else if exist "%VS140COMNTOOLS%\..\..\VC\bin\x86_amd64\vcvarsx86_amd64.bat" (
Expand All @@ -30,4 +34,4 @@ setlocal enabledelayedexpansion
@set
) else (
echo Error: 64bit is not automatically supported for this version of VC. Set HXCPP_MSVC_CUSTOM and manually configure the executable, library and include paths
)
)

0 comments on commit 7ae6b65

Please sign in to comment.