Skip to content

Commit 747287c

Browse files
authored
Merge pull request #170 from refack/develop
fix #157: detect vs2017 (vc141) and setup environment
2 parents dc2f03d + b2260a9 commit 747287c

6 files changed

Lines changed: 334 additions & 9 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/bin
99
/bootstrap.log
1010
/test/test_results.txt
11+
.tmp.json

src/engine/build.bat

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ REM location of the found toolset.
9898

9999
call :Clear_Error
100100
call :Test_Empty %ProgramFiles%
101-
if not errorlevel 1 set ProgramFiles=C:\Program Files
101+
if not errorlevel 1 set "ProgramFiles=C:\Program Files"
102102

103103
call :Clear_Error
104-
if NOT "_%VS150COMNTOOLS%_" == "__" (
104+
SET cl141cmd="%~dp0..\tools\vc141helper\cl141_path.cmd"
105+
for /F "tokens=*" %%A IN ('cmd /D /S /C "%cl141cmd% InstallationPath"') DO if NOT "_%%A_" == "__" (
106+
if errorlevel 1 goto :eof
105107
set "BOOST_JAM_TOOLSET=vc1410"
106-
set "BOOST_JAM_TOOLSET_ROOT=%VS150COMNTOOLS%..\..\VC\"
108+
set "BOOST_JAM_TOOLSET_ROOT=%%A\VC\"
107109
goto :eof)
108110
call :Clear_Error
109111
if EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" (

src/tools/msvc.jam

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,19 @@ local rule auto-detect-toolset-versions ( )
708708
# Get installation paths from the registry.
709709
for local i in $(.known-versions)
710710
{
711+
if $(i) = 14.10
712+
{
713+
local file = [ path.make [ modules.binding $(__name__) ] ] ;
714+
local cl141_path = [ path.native [ path.join [ path.parent $(file) ] vc141helper cl141_path.cmd ] ] ;
715+
local shell_ret = [ SHELL $(cl141_path) ] ;
716+
local cl_path = $(shell_ret:D) ;
717+
if $(cl_path)
718+
{
719+
path = [ path.native $(cl_path) ] ;
720+
register-configuration $(i) : $(path) ;
721+
}
722+
}
723+
711724
if $(.version-$(i)-reg)
712725
{
713726
local vc-path ;
@@ -820,7 +833,16 @@ local rule generate-setup-cmd ( version : command : parent : options * : cpu : g
820833
}
821834
else
822835
{
836+
if [ MATCH "(14.10)" : $(version) ]
837+
{
838+
if $(.debug-configuration)
839+
{
840+
ECHO 'notice: [generate-setup-cmd] $(version) is 14.10' ;
841+
}
842+
parent = [ path.native [ path.join $(parent) "..\\..\\..\\..\\..\\Auxiliary\\Build" ] ] ;
843+
}
823844
setup = [ locate-default-setup $(command) : $(parent) : $(default-setup) ] ;
845+
setup ?= [ path.join $(parent) "vcvarsall.bat" ] ;
824846
}
825847
}
826848

@@ -894,6 +916,10 @@ local rule configure-really ( version ? : options * )
894916

895917
local command = [ feature.get-values <command> : $(options) ] ;
896918

919+
# For 14.10 we need the exact version as MS is planning rolling updates
920+
# that will cause our `setup-cmd` to become invalid
921+
exact-version = [ MATCH "(14\.10\.[0-9\.]+)" : $(command) ] ;
922+
897923
# If version is specified, we try to search first in default paths, and
898924
# only then in PATH.
899925
command = [ common.get-invocation-command msvc : cl.exe : $(command) :
@@ -907,9 +933,9 @@ local rule configure-really ( version ? : options * )
907933
# version from the path.
908934
# FIXME: We currently detect both Microsoft Visual Studio 9.0 and
909935
# 9.0express as 9.0 here.
910-
if [ MATCH "(Microsoft Visual Studio 15)" : $(command) ]
936+
if [ MATCH "(MSVC\\14.10)" : $(command) ]
911937
{
912-
version = 15.0 ;
938+
version = 14.10 ;
913939
}
914940
else if [ MATCH "(Microsoft Visual Studio 14)" : $(command) ]
915941
{
@@ -1073,7 +1099,8 @@ local rule configure-really ( version ? : options * )
10731099

10741100
for local c in $(cpu)
10751101
{
1076-
setup-$(c) = [ generate-setup-cmd $(version) : $(command) : $(parent) : $(options) : $(c) : $(global-setup) : $(default-global-setup-options-$(c)) : $(default-setup-$(c)) ] ;
1102+
exact-version ?= $(version) ;
1103+
setup-$(c) = [ generate-setup-cmd $(exact-version) : $(command) : $(parent) : $(options) : $(c) : $(global-setup) : $(default-global-setup-options-$(c)) : $(default-setup-$(c)) ] ;
10771104
}
10781105

10791106
# Windows phone has different setup scripts, located in a different directory hierarchy.
@@ -1595,7 +1622,7 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
15951622
armv7 armv7s ;
15961623

15971624
# Known toolset versions, in order of preference.
1598-
.known-versions = 15.0 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1
1625+
.known-versions = 14.10 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1
15991626
7.1toolkit 7.0 6.0 ;
16001627

16011628
# Version aliases.
@@ -1608,7 +1635,7 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
16081635
.version-alias-11 = 11.0 ;
16091636
.version-alias-12 = 12.0 ;
16101637
.version-alias-14 = 14.0 ;
1611-
.version-alias-15 = 15.0 ;
1638+
.version-alias-15 = 14.10 ;
16121639

16131640
# Names of registry keys containing the Visual C++ installation path (relative
16141641
# to "HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft").
@@ -1624,7 +1651,6 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
16241651
.version-11.0-reg = "VisualStudio\\11.0\\Setup\\VC" ;
16251652
.version-12.0-reg = "VisualStudio\\12.0\\Setup\\VC" ;
16261653
.version-14.0-reg = "VisualStudio\\14.0\\Setup\\VC" ;
1627-
.version-15.0-reg = "VisualStudio\\15.0\\Setup\\VC" ;
16281654

16291655
# Visual C++ Toolkit 2003 does not store its installation path in the registry.
16301656
# The environment variable 'VCToolkitInstallDir' and the default installation
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2017 - Refael Ackermann
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
if (-NOT (Test-Path 'Registry::HKEY_CLASSES_ROOT\CLSID\{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}')) { Exit 1 }
6+
$jsonFile = '.tmp.json'
7+
Invoke-Expression 'powershell -NoProfile -ExecutionPolicy Unrestricted -Command "&{ Add-Type -Path GetVS2017Configuration.cs; [VisualStudioConfiguration.Main]::Query()}"' > $jsonFile
8+
$instPath = (Get-Content $jsonFile | ? {$_ -like "*InstallationPath*"}) -split '"' -replace '\\\\', '\' | Select-Object -skip 3 -first 1
9+
if ($args[0] -eq 'InstallationPath') { echo $instPath; exit }
10+
if ($env:PROCESSOR_ARCHITEW6432 -ne $null) {$filt = '*64\x64*'} else {$filt = '*86\x86*'}
11+
$cls = get-childitem $instPath -Include cl.exe -Recurse | ? { $_.Directory -like '*Host*' }
12+
$cl = $cls | ? { $_.Directory -like $filt }
13+
if ($cl -ne $null) {echo $cl.FullName} else {echo $cls[0].FullName}

0 commit comments

Comments
 (0)