Boost logo

Boost-Build :

From: Alexey Pakhunov (alexeypa_at_[hidden])
Date: 2005-09-21 15:46:30


Hi All,

One more patch for review. This time it is autodetection code for the
msvc toolset. This patch depends on other patches I posted recently:
http://article.gmane.org/gmane.comp.lib.boost.build/10463,
http://article.gmane.org/gmane.comp.lib.boost.build/10521 and
http://article.gmane.org/gmane.comp.lib.boost.build/10295.

Best regards/Venlig hilsen,
Alexey Pakhunov.
 --------------010301030708040609000501 Content-Type: text/plain;
name="msvc.autodetection.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="msvc.autodetection.diff"

Index: msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.51
diff -c -3 -r1.51 msvc.jam
*** msvc.jam 21 Sep 2005 13:44:06 -0000 1.51
--- msvc.jam 21 Sep 2005 20:38:28 -0000
***************
*** 126,136 ****
{
version = 8.0 ;
}
! else if [ MATCH "(NET 2003[\/\\]VC7)" : $(command) ] ||
! [ MATCH "(Microsoft Visual C\\+\\+ Toolkit 2003)" : $(command) ]
{
version = 7.1 ;
}
else if [ MATCH "(.NET[\/\\]VC7)" : $(command) ]
{
version = 7.0 ;
--- 126,139 ----
{
version = 8.0 ;
}
! 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 ;
***************
*** 166,237 ****
}
}

- 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) ;
}
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)
{
! # 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) ] ] ;
!
}
}

--- 169,218 ----
}
}

! # Returns the default installation path for the given version.
! local rule default-path ( version )
! {
! local path ;

! # 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 ;
+
if $(version)
{
! default-path += [ default-path $(version) ] ;
}
else
{
! for local i in $(.known-versions)
{
! default-path += [ default-path $(i) ] ;
}
}

***************
*** 413,415 ****
--- 394,467 ----
}

+ #
+ # Autodetection code
+ # tries to detect 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 ;
+
+ # Default installation paths relative to "Program Files" directory
+ .version-6.0-path = "Microsoft Visual Studio" "VC98" "bin" ;
+ .version-7.1toolkit-path = "Microsoft Visual C++ Toolkit 2003" "bin" ;
+
+ # Known environment variables
+ .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 )
+ {
+ 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 R in 8.0 7.1 7.0
+ {
+ local vc-path = [ W32_GETREG
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$(R)\\Setup\\VC"
+ : "ProductDir" ] ;
+ local vc-version = $(R) ;
+
+ if $(vc-path)
+ {
+ vc-path = [ path.native [ path.join [ path.make-NT $(vc-path) ] "bin" ] ] ;
+
+ register-configuration $(vc-version) : $(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) ] ;
+ }
+ }
+
 --------------010301030708040609000501--


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk