Skip to content

Commit

Permalink
Merge pull request #170 from refack/develop
Browse files Browse the repository at this point in the history
fix #157: detect vs2017 (vc141) and setup environment
  • Loading branch information
grafikrobot authored Mar 12, 2017
2 parents dc2f03d + b2260a9 commit 747287c
Show file tree
Hide file tree
Showing 6 changed files with 334 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/bin
/bootstrap.log
/test/test_results.txt
.tmp.json
8 changes: 5 additions & 3 deletions src/engine/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ REM location of the found toolset.

call :Clear_Error
call :Test_Empty %ProgramFiles%
if not errorlevel 1 set ProgramFiles=C:\Program Files
if not errorlevel 1 set "ProgramFiles=C:\Program Files"

call :Clear_Error
if NOT "_%VS150COMNTOOLS%_" == "__" (
SET cl141cmd="%~dp0..\tools\vc141helper\cl141_path.cmd"
for /F "tokens=*" %%A IN ('cmd /D /S /C "%cl141cmd% InstallationPath"') DO if NOT "_%%A_" == "__" (
if errorlevel 1 goto :eof
set "BOOST_JAM_TOOLSET=vc1410"
set "BOOST_JAM_TOOLSET_ROOT=%VS150COMNTOOLS%..\..\VC\"
set "BOOST_JAM_TOOLSET_ROOT=%%A\VC\"
goto :eof)
call :Clear_Error
if EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" (
Expand Down
38 changes: 32 additions & 6 deletions src/tools/msvc.jam
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,19 @@ local rule auto-detect-toolset-versions ( )
# Get installation paths from the registry.
for local i in $(.known-versions)
{
if $(i) = 14.10
{
local file = [ path.make [ modules.binding $(__name__) ] ] ;
local cl141_path = [ path.native [ path.join [ path.parent $(file) ] vc141helper cl141_path.cmd ] ] ;
local shell_ret = [ SHELL $(cl141_path) ] ;
local cl_path = $(shell_ret:D) ;
if $(cl_path)
{
path = [ path.native $(cl_path) ] ;
register-configuration $(i) : $(path) ;
}
}

if $(.version-$(i)-reg)
{
local vc-path ;
Expand Down Expand Up @@ -820,7 +833,16 @@ local rule generate-setup-cmd ( version : command : parent : options * : cpu : g
}
else
{
if [ MATCH "(14.10)" : $(version) ]
{
if $(.debug-configuration)
{
ECHO 'notice: [generate-setup-cmd] $(version) is 14.10' ;
}
parent = [ path.native [ path.join $(parent) "..\\..\\..\\..\\..\\Auxiliary\\Build" ] ] ;
}
setup = [ locate-default-setup $(command) : $(parent) : $(default-setup) ] ;
setup ?= [ path.join $(parent) "vcvarsall.bat" ] ;
}
}

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

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

# For 14.10 we need the exact version as MS is planning rolling updates
# that will cause our `setup-cmd` to become invalid
exact-version = [ MATCH "(14\.10\.[0-9\.]+)" : $(command) ] ;

# If version is specified, we try to search first in default paths, and
# only then in PATH.
command = [ common.get-invocation-command msvc : cl.exe : $(command) :
Expand All @@ -907,9 +933,9 @@ local rule configure-really ( version ? : options * )
# version from the path.
# FIXME: We currently detect both Microsoft Visual Studio 9.0 and
# 9.0express as 9.0 here.
if [ MATCH "(Microsoft Visual Studio 15)" : $(command) ]
if [ MATCH "(MSVC\\14.10)" : $(command) ]
{
version = 15.0 ;
version = 14.10 ;
}
else if [ MATCH "(Microsoft Visual Studio 14)" : $(command) ]
{
Expand Down Expand Up @@ -1073,7 +1099,8 @@ local rule configure-really ( version ? : options * )

for local c in $(cpu)
{
setup-$(c) = [ generate-setup-cmd $(version) : $(command) : $(parent) : $(options) : $(c) : $(global-setup) : $(default-global-setup-options-$(c)) : $(default-setup-$(c)) ] ;
exact-version ?= $(version) ;
setup-$(c) = [ generate-setup-cmd $(exact-version) : $(command) : $(parent) : $(options) : $(c) : $(global-setup) : $(default-global-setup-options-$(c)) : $(default-setup-$(c)) ] ;
}

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

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

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

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

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

0 comments on commit 747287c

Please sign in to comment.