mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 00:12:11 +00:00
Implement autodetection code for the 'msvc' toolset. It is
able to detect Visual Studio 6.0, 7.0, 7.1, 8.0 and Visual C++ Toolkit 2003. Detected settings are used in the cases when: - only version number is passed (using msvc : 8.0 ;) - incomplete configuration command is given (using msvc : 8.0 : cl.exe ;) - any available compiler is configured (using : default ;) - all available compilers are configured (using : all ;) A user is free to overwrite any of detected settings. Patch from Alexey Pakhunov. [SVN r31120]
This commit is contained in:
@@ -223,11 +223,14 @@ local rule configure-really (
|
||||
{
|
||||
version = 8.0 ;
|
||||
}
|
||||
else if [ MATCH "(NET 2003[\/\\]VC7)" : $(command) ] ||
|
||||
[ MATCH "(Microsoft Visual C\\+\\+ Toolkit 2003)" : $(command) ]
|
||||
else if [ MATCH "(NET 2003[\/\\]VC7)" : $(command) ]
|
||||
{
|
||||
version = 7.1 ;
|
||||
}
|
||||
else if [ MATCH "(Microsoft Visual C\\+\\+ Toolkit 2003)" : $(command) ]
|
||||
{
|
||||
version = 7.1toolkit ;
|
||||
}
|
||||
else if [ MATCH "(.NET[\/\\]VC7)" : $(command) ]
|
||||
{
|
||||
version = 7.0 ;
|
||||
@@ -265,71 +268,58 @@ local rule configure-really (
|
||||
}
|
||||
|
||||
|
||||
# Returns the default installation path for the given version.
|
||||
local rule default-path ( version )
|
||||
{
|
||||
# Use auto-detected path if possible
|
||||
local path = [ get-values <command> :
|
||||
[ $(.versions).get $(version) : options ] ] ;
|
||||
|
||||
if $(path)
|
||||
{
|
||||
path = $(path:D) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
# Check environment
|
||||
if $(.version-$(version)-env)
|
||||
{
|
||||
local vc-path = [ os.environ $(.version-$(version)-env) ] ;
|
||||
if $(vc-path)
|
||||
{
|
||||
vc-path = [ path.make $(vc-path) ] ;
|
||||
vc-path = [ path.join $(vc-path) $(.version-$(version)-envpath) ] ;
|
||||
vc-path = [ path.native $(vc-path) ] ;
|
||||
|
||||
path = $(vc-path) ;
|
||||
}
|
||||
}
|
||||
|
||||
# Check default path
|
||||
if ! $(path) && $(.version-$(version)-path)
|
||||
{
|
||||
path = [ path.native [ path.join $(.ProgramFiles) $(.version-$(version)-path) ] ] ;
|
||||
}
|
||||
}
|
||||
|
||||
return $(path) ;
|
||||
}
|
||||
|
||||
# Returns either the default installation path (if 'version' is not empty) or list of all
|
||||
# known default paths (if no version is given)
|
||||
rule default-paths ( version ? )
|
||||
{
|
||||
local possible-paths ;
|
||||
|
||||
local ProgramFiles = [ os.environ ProgramFiles ] ;
|
||||
if ! $(ProgramFiles)
|
||||
{
|
||||
ProgramFiles = "c:\\Program Files" ;
|
||||
}
|
||||
|
||||
local version-6-path = $(ProgramFiles)"\\Microsoft Visual Studio\\VC98" ;
|
||||
local version-7-path = $(ProgramFiles)"\\Microsoft Visual Studio .NET\\VC7" ;
|
||||
local version-7.0-path = $(version-7-path) ;
|
||||
local version-7.1-path = $(ProgramFiles)"\\Microsoft Visual Studio .NET 2003\\VC7" ;
|
||||
local version-8.0-path = $(ProgramFiles)"\\Microsoft Visual Studio 8" ;
|
||||
|
||||
local VS71COMNTOOLS = [ os.environ VS71COMNTOOLS ] ;
|
||||
if $(VS71COMNTOOLS)
|
||||
{
|
||||
# VS71COMNTOOLS is set by VS .NET 2003 to <VSDIR>\Common7\Tools
|
||||
version-7.1-path = [ path.make $(VS71COMNTOOLS) ] ;
|
||||
version-7.1-path = [ path.parent $(version-7.1-path) ] ;
|
||||
version-7.1-path = [ path.parent $(version-7.1-path) ] ;
|
||||
version-7.1-path = [ path.join $(version-7.1-path) "VC7" ] ;
|
||||
version-7.1-path = [ path.native $(version-7.1-path) ] ;
|
||||
}
|
||||
|
||||
local VS80COMNTOOLS = [ os.environ VS80COMNTOOLS ] ;
|
||||
|
||||
if $(VS80COMNTOOLS)
|
||||
{
|
||||
# VS80COMNTOOLS is set by VS .NET 2005 to <VSDIR>\Common7\Tools
|
||||
version-8.0-path = [ path.make "$(VS80COMNTOOLS)" ] ;
|
||||
version-8.0-path = [ path.parent $(version-8.0-path) ] ;
|
||||
version-8.0-path = [ path.parent $(version-8.0-path) ] ;
|
||||
version-8.0-path = [ path.join $(version-8.0-path) "VC" ] ;
|
||||
version-8.0-path = [ path.native $(version-8.0-path) ] ;
|
||||
}
|
||||
|
||||
# Fixed so we don't add paths without \\bin to all versions.
|
||||
# Path without 7.1
|
||||
|
||||
if $(version)
|
||||
{
|
||||
local v = [ MATCH ^(6|[^6].*) : $(version) ] ;
|
||||
possible-paths += $(version-$(v)-path) ;
|
||||
default-path += [ default-path $(version) ] ;
|
||||
}
|
||||
else
|
||||
{
|
||||
possible-paths += $(version-8.0-path) $(version-7.1-path) $(version-7.0-path) $(version-6-path) ;
|
||||
}
|
||||
|
||||
# The vcvars32.bat is actually in "bin" directory.
|
||||
# (except for free VC7.1 tools)
|
||||
possible-paths = $(possible-paths)\\bin ;
|
||||
|
||||
local VCToolkitInstallDir = [ os.environ VCToolkitInstallDir ] ;
|
||||
if $(VCToolkitInstallDir)
|
||||
{
|
||||
if $(version) = "7.1" || ! $(version)
|
||||
for local i in $(.known-versions)
|
||||
{
|
||||
# NOTE it's impossible to switch between Toolkit and VS.
|
||||
# I wonder is toolkit and VS can be installed together?
|
||||
possible-paths += [ path.native [ path.make $(VCToolkitInstallDir) ] ] ;
|
||||
|
||||
default-path += [ default-path $(i) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,3 +519,84 @@ rule compile.c ( targets + : sources * : properties * )
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Autodetection code
|
||||
# detects versions listed as '.known-versions' using registry, environment
|
||||
# and checking default paths. Supports both native Windows and Cygwin.
|
||||
#
|
||||
|
||||
.ProgramFiles = [ path.make [ common.get-program-files-dir ] ] ;
|
||||
|
||||
.known-versions = 8.0 7.1 7.1toolkit 7.0 6.0 ;
|
||||
|
||||
# Name of the registry key that contains Visual C++ installation path
|
||||
# (relative to "HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft\VisualStudio\x.y\Setup"
|
||||
.version-6.0-reg = "Microsoft Visual C++" ;
|
||||
.version-7.0-reg = "VC" ;
|
||||
.version-7.1-reg = "VC" ;
|
||||
.version-8.0-reg = "VC" ;
|
||||
|
||||
# Visual C++ Toolkit 2003 do not store its installation path in the registry.
|
||||
# The environment variable 'VCToolkitInstallDir' and the default installation
|
||||
# path will be checked instead.
|
||||
.version-7.1toolkit-path = "Microsoft Visual C++ Toolkit 2003" "bin" ;
|
||||
.version-7.1toolkit-env = VCToolkitInstallDir ;
|
||||
|
||||
# Path to the folder containing "cl.exe" relative to the value of the corresponding
|
||||
# environment variable
|
||||
.version-7.1toolkit-envpath = "bin" ;
|
||||
|
||||
|
||||
# Validates given path, registers found configuration and prints debug information
|
||||
# about it.
|
||||
local rule register-configuration ( version : path ? )
|
||||
{
|
||||
if $(path)
|
||||
{
|
||||
local command = [ GLOB $(path) : cl.exe ] ;
|
||||
|
||||
if $(command)
|
||||
{
|
||||
if $(.debug-configuration)
|
||||
{
|
||||
ECHO "notice: msvc-$(version) detected, command: '$(command)'" ;
|
||||
}
|
||||
|
||||
$(.versions).register $(version) ;
|
||||
$(.versions).set $(version) : options : <command>$(command) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if [ os.name ] in NT CYGWIN
|
||||
{
|
||||
# Get installation paths from the registry
|
||||
|
||||
for local i in $(.known-versions)
|
||||
{
|
||||
if $(.version-$(i)-reg)
|
||||
{
|
||||
local vc-path = [ W32_GETREG
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$(i)\\Setup\\"$(.version-$(i)-reg)
|
||||
: "ProductDir" ] ;
|
||||
|
||||
if $(vc-path)
|
||||
{
|
||||
vc-path = [ path.native [ path.join [ path.make-NT $(vc-path) ] "bin" ] ] ;
|
||||
register-configuration $(i) : $(vc-path) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Check environment and default installation paths
|
||||
|
||||
for local i in $(.known-versions)
|
||||
{
|
||||
if ! $(i) in [ $(.versions).all ]
|
||||
{
|
||||
register-configuration $(i) : [ default-path $(i) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user