Skip to content

Try to detect VS2017 using vswhere #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/engine/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ ECHO ### Toolsets supported by this script are: borland, como, gcc,
ECHO ### gcc-nocygwin, intel-win32, metrowerks, mingw, msvc, vc7, vc8,
ECHO ### vc9, vc10, vc11, vc12, vc14, vc141
ECHO ###
ECHO ### If you have Visual Studio 2017 installed you will need to build from
ECHO ### the Visual Studio Command Prompt for VS 2017 as we where unable to
ECHO ### detect your toolset installtion.
ECHO ### If you have Visual Studio 2017 installed you will need either update
ECHO ### the Visual Studio 2017 installer or run from VS 2017 Command Prompt
ECHO ### as we where unable to detect your toolset installation.
ECHO ###
call :Set_Error
endlocal
Expand Down
1 change: 1 addition & 0 deletions src/engine/config_toolset.bat
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
set "_known_=1"
:Skip_VC14
if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc141_" goto Skip_VC141
call vswhere_usability_wrapper.cmd
if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
if NOT "_%VS150COMNTOOLS%_" == "__" (
set "BOOST_JAM_TOOLSET_ROOT=%VS150COMNTOOLS%..\..\VC\"
Expand Down
3 changes: 3 additions & 0 deletions src/engine/guess_toolset.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ goto :eof
:Guess
REM Check the variable first. This can be set manually by the user (by running the tools commmand prompt).
call :Clear_Error
call vswhere_usability_wrapper.cmd
if NOT "_%VS150COMNTOOLS%_" == "__" (
set "BOOST_JAM_TOOLSET=vc141"
set "BOOST_JAM_TOOLSET_ROOT=%VS150COMNTOOLS%..\..\VC\"
goto :eof)

:skip_vswhere
if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" (
set "BOOST_JAM_TOOLSET=vc141"
set "BOOST_JAM_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\VC\"
Expand Down
20 changes: 20 additions & 0 deletions src/engine/vswhere_usability_wrapper.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
:: Copyright 2017 - Refael Ackermann
:: Distributed under MIT style license
:: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
:: version: 1.14.0

@if not defined DEBUG_HELPER @ECHO OFF
setlocal
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
set VSWHERE_PRP=-property installationPath
set VSWHERE_LMT=-version "[15.0,16.0)"
SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
if not exist "%VSWHERE%" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer"
if not exist "%VSWHERE%" exit /B 1
set Path=%Path%;%VSWHERE%
for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
endlocal
set "VCINSTALLDIR=%%i\VC\"
set "VS150COMNTOOLS=%%i\Common7\Tools\"
exit /B 0)
37 changes: 33 additions & 4 deletions src/tools/msvc.jam
Original file line number Diff line number Diff line change
Expand Up @@ -1250,10 +1250,40 @@ local rule default-path ( version )
}
else
{
# Check environment.
# try to use vswhere
local pseudo_env_VS150 ;
if $(version) = 14.1 || $(version) = "default"
{
local req = "-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ;
local prop = "-property installationPath" ;
local limit = "-version \"[15.0,16.0)\"" ;
local root = [ os.environ "ProgramFiles(x86)" ] ;
if ( ! $(root) )
{
root = [ os.environ "ProgramFiles" ] ;
}
local vswhere = "$(root)\\Microsoft Visual Studio\\Installer\\vswhere.exe" ;
if ( [ path.exists $(vswhere) ] )
{
local vmwhere_cmd = "\"$(vswhere)\" -latest -products * $(req) $(prop) $(limit)" ;
local shell_ret = [ SPLIT_BY_CHARACTERS [ SHELL $(vmwhere_cmd) ] : "\n" ] ;
pseudo_env_VS150 = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ;
}
}

# Check environment or previous path_VS150
for local env in $(.version-$(version)-env)
{
local env-path = [ os.environ $(env) ] ;
local env-path ;
if ( $(pseudo_env_VS150) && [ path.exists $(pseudo_env_VS150) ] )
{
env-path = $(pseudo_env_VS150) ;
}
else
{
env-path = [ os.environ $(env) ] ;
}
ECHO "env-path $(env-path)" ;
if $(env-path) && $(.version-$(version)-path)
{
for local bin-path in $(.version-$(version)-path)
Expand Down Expand Up @@ -1669,8 +1699,7 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
.version-7.1toolkit-path = "Microsoft Visual C++ Toolkit 2003/bin" ;
.version-7.1toolkit-env = VCToolkitInstallDir ;
# Visual Studio 2017 doesn't use a registry at all. And the suggested methods
# of discovery involve having a compiled program. We can't do that as it would
# make for a recursive discovery and build dependency cycle. So we search
# of discovery involve having a compiled program. So as a fallback we search
# paths for VS2017 (aka msvc >= 14.1).
.version-14.1-path =
"../../VC/Tools/MSVC/*/bin/Host*/*"
Expand Down