2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-14 12:42:11 +00:00

Merge remote-tracking branch 'upstream/develop' into bootstrap-vs16-no-vswhere

This commit is contained in:
Tom Kent
2019-03-11 19:20:54 -05:00
3 changed files with 116 additions and 126 deletions

View File

@@ -1126,12 +1126,15 @@ local rule set-setup-command ( targets * : properties * )
#
local rule configure-really ( version ? : options * )
{
local v = $(version) ;
local command = [ feature.get-values <command> : $(options) ] ;
# Decide what the 'default' version is.
if ! $(v)
if ! $(version) && ! $(command)
{
# We were given neither a command, nor a version.
# Take the best registered (i.e. auto-detected) version.
# FIXME: consider whether an explicitly specified setup script
# should disable this logic. We already won't get here if
# there is a user specified command.
version = [ $(.versions).all ] ;
for local known in $(.known-versions)
{
@@ -1141,59 +1144,31 @@ local rule configure-really ( version ? : options * )
break ;
}
}
# version might still have multiple elements if no versions
# were auto-detected, but an unknown version was configured
# manually.
version = $(version[1]) ;
v = $(version) ;
# Note: 'version' can still be empty at this point if no versions have
# been auto-detected.
version ?= "default" ;
}
# Version alias -> real version number.
version = [ resolve-possible-msvc-version-alias $(version) ] ;
# Check whether the selected configuration is already in use.
if $(version) in [ $(.versions).used ]
# Handle a user-provided command, and deduce the version if necessary.
# If the user-requested version was not autodetected and no command
# was given, attempt to find it in PATH
if $(command) || ! ( $(version:E=default) in [ $(.versions).all ] )
{
# Allow multiple 'toolset.using' calls for the same configuration if the
# identical sets of options are used.
if $(options) && ( $(options) != [ $(.versions).get $(version) : options ] )
local found-command = [ common.get-invocation-command-nodefault msvc : cl.exe : $(command) ] ;
if $(found-command)
{
import errors ;
errors.error "MSVC toolset configuration: Toolset version"
"'$(version)' already configured." ;
command = $(found-command) ;
if ! $(command:D)
{
local path = [ common.get-absolute-tool-path $(command) ] ;
command = $(command:R=$(path)) ;
}
}
}
else
{
# Register a new configuration.
$(.versions).register $(version) ;
# Add user-supplied to auto-detected options.
options = [ $(.versions).get $(version) : options ] $(options) ;
# Mark the configuration as 'used'.
$(.versions).use $(version) ;
# Generate conditions and save them.
local conditions = [ common.check-init-parameters msvc : version $(v) ]
;
$(.versions).set $(version) : conditions : $(conditions) ;
local command = [ feature.get-values <command> : $(options) ] ;
# For 14.1+ we need the exact version as MS is planning rolling updates
# that will cause our `setup-cmd` to become invalid
exact-version = [ MATCH "(14\.[1-9][0-9]\.[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) :
[ default-paths $(version) ] : $(version) ] ;
if ( ! $(version) || $(version) = "default" ) && ! $(command:D)
else
{
# If we still failed to find cl.exe, bail out.
ECHO ;
ECHO warning\:
"Did not find command for MSVC toolset."
@@ -1204,21 +1179,20 @@ local rule configure-really ( version ? : options * )
"build from the 'Visual Studio Command Prompt for VS 2017'."
;
ECHO ;
command ?= cl.exe ;
}
common.handle-options msvc : $(conditions) : $(command) : $(options) ;
if ! $(version)
{
# Even if version is not explicitly specified, try to detect the
# version from the path.
# FIXME: We currently detect both Microsoft Visual Studio 9.0 and
# 9.0express as 9.0 here.
if [ MATCH "(MSVC\\14.2)" : $(command) ]
if [ MATCH "(MSVC\\\\14.2)" : $(command) ]
{
version = 14.2 ;
}
else if [ MATCH "(MSVC\\14.1)" : $(command) ]
else if [ MATCH "(MSVC\\\\14.1)" : $(command) ]
{
version = 14.1 ;
}
@@ -1264,6 +1238,44 @@ local rule configure-really ( version ? : options * )
version = 6.0 ;
}
}
}
# Version alias -> real version number.
version = [ resolve-possible-msvc-version-alias $(version) ] ;
# Check whether the selected configuration is already in use.
if $(version) in [ $(.versions).used ]
{
# Allow multiple 'toolset.using' calls for the same configuration if the
# identical sets of options are used.
if $(options) && ( $(options) != [ $(.versions).get $(version) : options ] )
{
import errors ;
errors.user-error "MSVC toolset configuration: Toolset version"
"'$(version)' already configured." ;
}
}
else
{
# Register a new configuration.
$(.versions).register $(version) ;
$(.versions).set $(version) : options : $(options) ;
# Mark the configuration as 'used'.
$(.versions).use $(version) ;
# Generate conditions and save them.
local conditions = [ common.check-init-parameters msvc : version $(version) ] ;
$(.versions).set $(version) : conditions : $(conditions) ;
command ?= [ $(.versions).get $(version) : default-command ] ;
# For 14.1+ we need the exact version as MS is planning rolling updates
# that will cause our `setup-cmd` to become invalid
exact-version = [ MATCH "(14\.[1-9][0-9]\.[0-9\.]+)" : $(command) ] ;
common.handle-options msvc : $(conditions) : $(command) : $(options) ;
# Generate and register setup command.
@@ -1458,7 +1470,7 @@ local rule configure-really ( version ? : options * )
{
for local cpu-condition in $(cpu-conditions)
{
ECHO "notice: [msvc-cfg] condition: '$(cpu-condition)', setup: '$(setup-$(c))'" ;
ECHO "notice: [msvc-cfg] condition: '$(cpu-condition)', setup: '$(setup-$(c):J= )'" ;
}
}
@@ -1536,15 +1548,7 @@ local rule configure-really ( version ? : options * )
#
local rule default-path ( version )
{
# Use auto-detected path if possible.
local result = [ feature.get-values <command> : [ $(.versions).get $(version)
: options ] ] ;
if $(result)
{
result = $(result:D) ;
}
else
local result ;
{
# try to use vswhere
local pseudo_env_VSCOMNTOOLS ;
@@ -1611,28 +1615,6 @@ local rule default-path ( version )
}
# Returns either the default installation path (if 'version' is not empty) or
# list of all known default paths (if no version is given)
#
local rule default-paths ( version ? )
{
local possible-paths ;
if $(version)
{
possible-paths += [ default-path $(version) ] ;
}
else
{
for local i in $(.known-versions)
{
possible-paths += [ default-path $(i) ] ;
}
}
return $(possible-paths) ;
}
rule get-rspline ( target : lang-opt )
{
@@ -1908,7 +1890,7 @@ local rule register-configuration ( version : path ? )
}
$(.versions).register $(version) ;
$(.versions).set $(version) : options : <command>$(command) ;
$(.versions).set $(version) : default-command : $(command) ;
}
}
}
@@ -1992,8 +1974,6 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
.version-alias-11 = 11.0 ;
.version-alias-12 = 12.0 ;
.version-alias-14 = 14.0 ;
.version-alias-14.1 = 14.1 ;
.version-alias-14.2 = 14.2 ;
# Names of registry keys containing the Visual C++ installation path (relative
# to "HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft").

View File

@@ -66,13 +66,25 @@ class package-paths
option.set datarootdir : ;
}
self.prefix = [ path.make [ option.get prefix : $(default-prefix) ] ] ;
self.libdir = [ path.make [ option.get libdir : $(self.prefix)/lib ] ] ;
self.bindir = [ path.make [ option.get bindir : $(self.prefix)/bin ] ] ;
self.includedir =
[ path.make [ option.get includedir : $(self.prefix)/include ] ] ;
self.datarootdir =
[ path.make [ option.get datarootdir : $(self.prefix)/share ] ] ;
handle-path prefix : $(default-prefix) ;
handle-path libdir : $(self.prefix)/lib ;
handle-path bindir : $(self.prefix)/bin ;
handle-path includedir : $(self.prefix)/include ;
handle-path datarootdir : $(self.prefix)/share ;
}
local rule handle-path ( option : default-value )
{
local opt = [ option.get $(option) ] ;
if $(opt)
{
opt = [ path.root [ path.make $(opt) ] [ path.pwd ] ] ;
}
else
{
opt = $(default-value) ;
}
self.$(option) = $(opt) ;
}
rule prefix ( )
@@ -118,8 +130,7 @@ class package-paths
}
local adjusted-default =
[ path.join [ get $(relative-to) ] $(default-value) ] ;
self.$(option) =
[ path.make [ option.get $(option) : $(adjusted-default) ] ] ;
handle-path $(option) : $(adjusted-default) ;
}
return $(self.$(option)) ;
}

View File

@@ -10,10 +10,11 @@ import BoostBuild
import os
def setup():
t = BoostBuild.Tester(use_test_config=False)
t = BoostBuild.Tester(["p//install", "p//data"],
use_test_config=False)
t.write("jamroot.jam", "")
t.write("jamfile.jam", """\
t.write("p/jamroot.jam", "")
t.write("p/jamfile.jam", """\
import package ;
exe a : a.cpp ;
lib b : b.cpp ;
@@ -23,16 +24,16 @@ def setup():
: a.h ;
package.install-data data : Test : a.txt ;
""")
t.write("a.cpp", "int main() {}")
t.write("b.cpp", """
t.write("p/a.cpp", "int main() {}")
t.write("p/b.cpp", """
int
#ifdef _WIN32
__declspec(dllexport)
#endif
must_export_something;
""")
t.write("a.h", "")
t.write("a.txt", "")
t.write("p/a.h", "")
t.write("p/a.txt", "")
return t
def test_defaults():
@@ -40,7 +41,7 @@ def test_defaults():
# Since the default install location is outside out test area,
# we don't want to actually execute the build.
t.run_build_system(["-n", "-d1", "install", "data"])
t.run_build_system(["-n", "-d1"])
installdir = "C:/Test" if os.name == 'nt' else "/usr/local"
t.expect_output_lines([
@@ -64,7 +65,7 @@ def test_prefix():
option.set datarootdir : bad/share ;
""")
t.run_build_system(["--prefix=installdir", "install", "data"])
t.run_build_system(["--prefix=installdir"])
t.expect_addition("installdir/bin/a.exe")
t.expect_addition("installdir/lib/b.dll")
t.expect_addition("installdir/lib/b.lib")
@@ -87,8 +88,7 @@ def test_subdirs():
t.run_build_system(["--libdir=installdir/lib64",
"--bindir=installdir/binx",
"--includedir=installdir/includex",
"--datarootdir=installdir/sharex",
"install", "data"])
"--datarootdir=installdir/sharex"])
t.expect_addition("installdir/binx/a.exe")
t.expect_addition("installdir/lib64/b.dll")
t.expect_addition("installdir/lib64/b.lib")
@@ -112,8 +112,7 @@ def test_subdirs_with_prefix():
"--libdir=installdir/lib64",
"--bindir=installdir/binx",
"--includedir=installdir/includex",
"--datarootdir=installdir/sharex",
"install", "data"])
"--datarootdir=installdir/sharex"])
t.expect_addition("installdir/binx/a.exe")
t.expect_addition("installdir/lib64/b.dll")
t.expect_addition("installdir/lib64/b.lib")
@@ -129,7 +128,7 @@ def test_prefix_config_file():
option.set prefix : installdir ;
""")
t.run_build_system(["install", "data"])
t.run_build_system()
t.expect_addition("installdir/bin/a.exe")
t.expect_addition("installdir/lib/b.dll")
t.expect_addition("installdir/lib/b.lib")
@@ -149,7 +148,7 @@ def test_subdirs_config_file():
option.set datarootdir : installdir/sharex ;
""")
t.run_build_system(["install", "data"])
t.run_build_system()
t.expect_addition("installdir/binx/a.exe")
t.expect_addition("installdir/lib64/b.dll")
t.expect_addition("installdir/lib64/b.lib")
@@ -163,8 +162,8 @@ def test_multiple():
install prefixes.'''
t = BoostBuild.Tester(use_test_config=False)
t.write("jamroot.jam", "")
t.write("jamfile.jam", """\
t.write("p/jamroot.jam", "")
t.write("p/jamfile.jam", """\
import package ;
exe a : a.cpp ;
lib b : b.cpp ;
@@ -177,24 +176,24 @@ def test_multiple():
: b/<link>static b/<link>shared
: a.h ;
""")
t.write("a.cpp", "int main() {}")
t.write("b.cpp", """
t.write("p/a.cpp", "int main() {}")
t.write("p/b.cpp", """
int
#ifdef _WIN32
__declspec(dllexport)
#endif
must_export_something;
""")
t.write("a.h", "")
t.run_build_system(["installx", "instally"])
t.expect_addition("xxx/bin/a.exe")
t.expect_addition("xxx/lib/b.dll")
t.expect_addition("xxx/lib/b.lib")
t.expect_addition("xxx/include/a.h")
t.expect_addition("yyy/bin/a.exe")
t.expect_addition("yyy/lib/b.dll")
t.expect_addition("yyy/lib/b.lib")
t.expect_addition("yyy/include/a.h")
t.write("p/a.h", "")
t.run_build_system(["p//installx", "p//instally"])
t.expect_addition("p/xxx/bin/a.exe")
t.expect_addition("p/xxx/lib/b.dll")
t.expect_addition("p/xxx/lib/b.lib")
t.expect_addition("p/xxx/include/a.h")
t.expect_addition("p/yyy/bin/a.exe")
t.expect_addition("p/yyy/lib/b.dll")
t.expect_addition("p/yyy/lib/b.lib")
t.expect_addition("p/yyy/include/a.h")
def test_paths():
t = BoostBuild.Tester(pass_toolset=False)