Boost logo

Boost-Build :

From: Alexey Pakhunov (alexeypa_at_[hidden])
Date: 2005-08-03 15:15:32


Andrey Melnikov wrote:

Now I see. You and I mean a bit different things when we talking about
"separation of initialization and autodetection code".

>>Gm. I definitely want to separate initialization and autodetection code.
>> :) Why do you think it is a bad idea?
> 1) Because it was already separated into msvc.default-path rule. You can
> add more rules to msvc.jam if you need more modularity.

In my opinion 'msvc.default-path' offered a messy way of autodetection.
My goal is to make BBv2 to detect as many VS installations as possible
and then provide a way to select toolset configurations a user wants to
use. At the same time I do not want to allow "broken" configurations,
for example:

using msvc : 7.1 : "C:\\Program Files\\Microsoft Visual Studio
8\\VC\\bin\\cl.exe ;

A user should be able to set up a required configuration manually of
course. For example, if VC++ 8.0 will be available as a free toolkit 2005:

using msvc : 8.0 : "C:\\Program Files\\Microsoft Visual C++ Toolkit
2005\\bin\\cl.exe ;

> 2) msvc-config is an experimental thing. msvc toolkit should have its
> own autodetection facilities.

I'm not going to use msvc-config in the future. Even now there is no
practical difference where the autodetection code will be placed
physically. If you or someone else is against using msvc-config I will
assume there is a good reason for this and will move it to msvc.jam. I'd
like to focus on other configuration issues now.

It's not a good idea to deprecate
> using msvc : 8.0 ;
> We need using msvc ; syntax to work. We need a consistency between toolsets..

Agree. It will work in the final version of the patch.

> I'd like detection using environment removed completely. Can you imagine
> a scenario in which registry autodetection will fail?

I don't have any objections.

BTW do you know a good way to detect PSDK location using registry? I
have found only one key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3]
Install Dir="D:\Kits\Platform SDK\"

but it seems that {8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3} is different
for different versions of PSDK.

PS: I updated the patch according to your comments. (BTW you did a great
review. Thanks). It includes support of amd64 and ia64 in VS 8-only
configuration. I haven't updated initialization code yet.

Best regards,
Alexey Pakhunov.
 --------------050905060409000409080404 Content-Type: text/plain;
name="msvc64.2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="msvc64.2.diff"

diff -Naur BBv2.old/build/feature.jam BBv2.new/build/feature.jam
--- BBv2.old/build/feature.jam 2005-07-31 19:22:14.649342400 +0200
+++ BBv2.new/build/feature.jam 2005-07-30 22:54:47.611332800 +0200
@@ -567,6 +567,32 @@
extend-subfeature $(feature) $(value-string) : $(subfeature) : $(subvalues) ;
}

+# Declares a subfeature
+rule does-subfeature-exist (
+ feature # Root feature that is not a subfeature
+ value-string ? # A value-string specifying which feature or
+ # subfeature values this subfeature is specific to,
+ # if any
+
+ : subfeature # The name of the subfeature being declared
+)
+{
+ feature = [ grist $(feature) ] ;
+ validate-feature $(feature) ;
+
+ # Add grist to the subfeature name if a value-string was supplied
+ local subfeature-name = [ get-subfeature-name $(subfeature) $(value-string) ] ;
+
+ if $(subfeature-name) in $($(feature).subfeatures)
+ {
+ return true ;
+ }
+ else
+ {
+ return false ;
+ }
+}
+
# Set the components of the given composite property
rule compose ( composite-property : component-properties * )
{
diff -Naur BBv2.old/tools/common.jam BBv2.new/tools/common.jam
--- BBv2.old/tools/common.jam 2005-07-31 19:22:16.582121600 +0200
+++ BBv2.new/tools/common.jam 2005-07-30 22:54:29.264952000 +0200
@@ -38,7 +38,7 @@
{
local name = $($(index)[1]) ;
local value = $($(index)[2]) ;
-
+
if $(value)-is-specified
{
condition = $(condition)-$(value) ;
@@ -65,7 +65,12 @@
{
if ! $(.declared-subfeature.$(t).$(name))
{
- feature.subfeature toolset $(t) : $(name) : : propagated ;
+ # Check whether the subfeature already exists
+ local f = [ feature.does-subfeature-exist toolset $(t) : $(name) ] ;
+ if $(f) != true
+ {
+ feature.subfeature toolset $(t) : $(name) : : propagated ;
+ }
.declared-subfeature.$(t).$(name) = true ;
}
.had-value.$(toolset).$(name) = true ;
diff -Naur BBv2.old/tools/mc.jam BBv2.new/tools/mc.jam
--- BBv2.old/tools/mc.jam 1970-01-01 01:00:00.000000000 +0100
+++ BBv2.new/tools/mc.jam 2005-07-30 09:46:45.490379200 +0200
@@ -0,0 +1,36 @@
+#~ Copyright 2005 Alexey Pakhunov.
+#~ Distributed under the Boost Software License, Version 1.0.
+#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+import common ;
+import generators ;
+import feature : feature get-values ;
+import toolset : flags ;
+import type ;
+import rc ;
+
+rule init ( )
+{
+}
+
+type.register MC : mc ;
+
+
+# Command line options
+feature mc-input-encoding : ansi unicode : free ;
+feature mc-output-encoding : unicode ansi : free ;
+feature mc-set-customer-bit : no yes : free ;
+
+flags mc.compile MCFLAGS <mc-input-encoding>ansi : -a ;
+flags mc.compile MCFLAGS <mc-input-encoding>unicode : -u ;
+flags mc.compile MCFLAGS <mc-output-encoding>ansi : -A ;
+flags mc.compile MCFLAGS <mc-output-encoding>unicode : -U ;
+flags mc.compile MCFLAGS <mc-set-customer-bit>no : ;
+flags mc.compile MCFLAGS <mc-set-customer-bit>yes : -c ;
+
+generators.register-standard mc.compile : MC : H RC ;
+
+actions compile
+{
+ mc $(MCFLAGS) -h "$(<[1]:DW)" -r "$(<[2]:DW)" "$(>:W)"
+}
diff -Naur BBv2.old/tools/midl.jam BBv2.new/tools/midl.jam
--- BBv2.old/tools/midl.jam 1970-01-01 01:00:00.000000000 +0100
+++ BBv2.new/tools/midl.jam 2005-08-03 17:45:05.754699200 +0200
@@ -0,0 +1,93 @@
+#~ Copyright 2005 Alexey Pakhunov.
+#~ Distributed under the Boost Software License, Version 1.0.
+#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+# Microsoft Interface Definition Language (MIDL) related routines
+
+import common ;
+import generators ;
+import feature : feature get-values ;
+import scanner ;
+import toolset : flags ;
+import type ;
+
+rule init ( )
+{
+}
+
+type.register IDL : idl ;
+type.register TLB : tlb ;
+
+
+# Register scanner for MIDL files
+class midl-scanner : scanner
+{
+ import regex virtual-target path scanner ;
+
+ rule __init__ ( includes * )
+ {
+ scanner.__init__ ;
+
+ self.includes = $(includes) ;
+ }
+
+ rule pattern ( )
+ {
+ return
+ "(((include[ ]*\"[^\"]*\"([ ]*,[ ]*\"[^\"]*\")*)|(import[ ]*\"[^\"]*\"([ ]*,[ ]*\"[^\"]*\")*)|(importlib[ ]*[(][ ]*\"[^\"]*\"([ ]*,[ ]*\"[^\"]*\")*[ ]*[)]))[ ]*;)" ;
+ }
+
+ rule process ( target : matches * : binding )
+ {
+ local included = [ regex.transform $(matches) : "include[ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*;" : 1 3 ] ;
+ local imported = [ regex.transform $(matches) : "import[ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*;" : 1 3 ] ;
+ local imported_tlbs = [ regex.transform $(matches) : "importlib[ ]*[(][ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*[)][ ]*;" : 1 3 ] ;
+
+ # CONSIDER: the new scoping rule seem to defeat "on target" variables.
+ local g = [ on $(target) return $(HDRGRIST) ] ;
+ local b = [ NORMALIZE_PATH $(binding:D) ] ;
+
+ # Attach binding of including file to included targets.
+ # When target is directly created from virtual target
+ # this extra information is unnecessary. But in other
+ # cases, it allows to distinguish between two headers of the
+ # same name included from different places.
+ local g2 = $(g)"#"$(b) ;
+
+ included = $(included:G=$(g2)) ;
+ imported = $(imported:G=$(g2)) ;
+ imported_tlbs = $(imported_tlbs:G=$(g2)) ;
+
+ local all = $(included) $(imported) ;
+
+ INCLUDES $(target) : $(all) ;
+ DEPENDS $(target) : $(imported_tlbs) ;
+ NOCARE $(all) $(imported_tlbs) ;
+ SEARCH on $(included) = $(b) $(self.includes:G=) ;
+ SEARCH on $(imported) = $(b) $(self.includes:G=) ;
+ SEARCH on $(imported_tlbs) = $(b) $(self.includes:G=) ;
+
+ scanner.propagate c-scanner : $(included) : $(target) ;
+ scanner.propagate $(__name__) : $(imported) : $(target) ;
+ }
+}
+
+scanner.register midl-scanner : include ;
+type.set-scanner IDL : midl-scanner ;
+
+
+# Command line options
+feature midl-stubless-proxy : yes no : propagated ;
+feature midl-robust : yes no : propagated ;
+
+flags midl.compile.idl MIDLFLAGS <midl-stubless-proxy>yes : /Oicf ;
+flags midl.compile.idl MIDLFLAGS <midl-stubless-proxy>no : /Oic ;
+flags midl.compile.idl MIDLFLAGS <midl-robust>yes : /robust ;
+flags midl.compile.idl MIDLFLAGS <midl-robust>no : /no_robust ;
+
+generators.register-c-compiler midl.compile.idl : IDL : TLB H C(%_i) C(%_proxy) C(%_dlldata) ;
+
+actions compile.idl
+{
+ midl /nologo /U$(UNDEFS) /D$(DEFINES) $(MIDLFLAGS) /I"$(INCLUDES)" /tlb "$(<[1]:W)" /h "$(<[2]:W)" /iid "$(<[3]:W)" /proxy "$(<[4]:W)" /dlldata "$(<[5]:W)" "$(>:W)"
+}
diff -Naur BBv2.old/tools/msvc-config.jam BBv2.new/tools/msvc-config.jam
--- BBv2.old/tools/msvc-config.jam 2005-07-31 19:22:16.592136000 +0200
+++ BBv2.new/tools/msvc-config.jam 2005-08-03 21:27:17.046662400 +0200
@@ -6,9 +6,26 @@

import os ;
import toolset : using ;
+import path ;
+
+
+# Registers a single msvc toolset configuration
+rule register ( version : command * : options * )
+{
+ if --debug-configuration in [ modules.peek : ARGV ]
+ {
+ ECHO "notice:" using msvc ":" $(options) ;
+ }
+ using msvc : $(version) : $(command) : $(options) ;
+}
+

if [ os.name ] = NT
{
+ #
+ # Get installation paths from the registry
+ #
+
for local R in 8.0 7.1 7.0
{
local vc-path = [ W32_GETREG
@@ -18,11 +35,171 @@

if $(vc-path)
{
- if --debug-configuration in [ modules.peek : ARGV ]
+ vc-path = [ path.make $(vc-path) ] ;
+ vc-path = [ path.join $(vc-path) "bin" ] ;
+ vc-path = [ path.native $(vc-path) ] ;
+
+ .version-$(vc-version)-command = [ GLOB $(vc-path) : cl.exe ] ;
+ }
+ }
+
+
+ #
+ # Check environment and default instllation paths
+ #
+
+ local ProgramFiles = [ os.environ ProgramFiles ] ;
+ if ! $(ProgramFiles)
+ {
+ ProgramFiles = "C:\\Program Files" ;
+ }
+
+ local command = cl.exe ;
+
+ # 6.0
+ # Check the default installation path
+ if ! $(.version-6.0-command)
+ {
+ .version-6.0-command = [ GLOB $(ProgramFiles)"\\Microsoft Visual Studio\\VC98\\bin" : $(command) ] ;
+ }
+
+ # 7.0
+ # Check the default installation path
+ if ! $(.version-7.0-command)
+ {
+ .version-7.0-command = [ GLOB $(ProgramFiles)"\\Microsoft Visual Studio .NET\\VC7\\bin" : $(command) ] ;
+ }
+
+ # 7.1
+ # Check VS71COMNTOOLS
+ if ! $(.version-7.1-command)
+ {
+ local VS71COMNTOOLS = [ os.environ VS71COMNTOOLS ] ;
+ if $(VS71COMNTOOLS)
+ {
+ # VS71COMNTOOLS is set by VS .NET 2003 to <VSDIR>\Common7\Tools
+ local 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.join $(version-7.1-path) "bin" ] ;
+ version-7.1-path = [ path.native $(version-7.1-path) ] ;
+
+ .version-7.1-command = [ GLOB $(version-7.1-path) : $(command) ] ;
+ }
+ }
+
+ # Check VCToolkitInstallDir
+ if ! $(.version-7.1-command)
+ {
+ local VCToolkitInstallDir = [ os.environ VCToolkitInstallDir ] ;
+ if $(VCToolkitInstallDir)
+ {
+ # VCToolkitInstallDir is set by VC++ Toolkit to <VCToolkit>
+ local version-7.1-path = [ path.make "$(VCToolkitInstallDir)" ] ;
+ version-7.1-path = [ path.join $(version-7.1-path) "bin" ] ;
+ version-7.1-path = [ path.native $(version-7.1-path) ] ;
+
+ .version-7.1-command = [ GLOB $(version-7.1-path) : $(command) ] ;
+ }
+ }
+
+ # Check the default installation path (Visual Studio)
+ if ! $(.version-7.1-command)
+ {
+ .version-7.1-command = [ GLOB $(ProgramFiles)"\\Microsoft Visual Studio .NET 2003\\VC7\\bin" : $(command) ] ;
+ }
+
+ # Check the default installation path (VC++ Toolkit)
+ if ! $(.version-7.1-command)
+ {
+ .version-7.1-command = [ GLOB $(ProgramFiles)"\\Microsoft Visual C++ Toolkit 2003\\bin" : $(command) ] ;
+ }
+
+ # 8.0
+ # Check VS80COMNTOOLS
+ if ! $(.version-8.0-command)
+ {
+ local VS80COMNTOOLS = [ os.environ VS80COMNTOOLS ] ;
+ if $(VS80COMNTOOLS)
+ {
+ # VS80COMNTOOLS is set by VS .NET 2005 to <VSDIR>\Common7\Tools
+ local 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.join $(version-8.0-path) "bin" ] ;
+ version-8.0-path = [ path.native $(version-8.0-path) ] ;
+
+ .version-8.0-command = [ GLOB $(version-8.0-path) : $(command) ] ;
+ }
+ }
+
+ # Check the default installation path (Visual Studio)
+ if ! $(.version-8.0-command)
+ {
+ .version-8.0-command = [ GLOB $(ProgramFiles)"\\Microsoft Visual Studio 8\\VC\\bin" : $(command) ] ;
+ }
+
+
+ #
+ # Register all found versions
+ #
+
+ if $(.version-8.0-command)
+ {
+ register 8.0 : $(.version-8.0-command) : <arch>i386 ;
+ register 8.0 : $(.version-8.0-command) : <arch>amd64 ;
+ register 8.0 : $(.version-8.0-command) : <arch>ia64 ;
+ }
+
+ for local R in 7.1 7.0 6.0
+ {
+ if $(.version-$(R)-command)
+ {
+ register $(R) : $(.version-$(R)-command) ;
+ }
+ }
+}
+
+
+#
+# The 'init' rule additionally registers Platform SDK-based configurations
+#
+rule init (
+ # Platform SDK path (default is "C:\\Program Files\\Mircosoft Platform SDK")
+ psdk-path ?
+ )
+{
+ if [ os.name ] = NT
+ {
+ local ProgramFiles = [ os.environ ProgramFiles ] ;
+ if ! $(ProgramFiles)
+ {
+ ProgramFiles = "C:\\Program Files" ;
+ }
+
+ # Validate the path
+
+ psdk-path ?= $(ProgramFiles)"\\Microsoft Platform SDK" ;
+
+ if ! [ GLOB $(psdk-path) : SetEnv.Cmd ]
+ {
+ psdk-path = ;
+ }
+
+ if $(psdk-path)
+ {
+ for local R in 8.0 7.1 7.0 6.0
{
- ECHO "notice:" using msvc ":" $(vc-version) ":" "$(vc-path)\\bin\\cl.exe" ;
+ if $(.version-$(R)-command)
+ {
+ register $(R) : $(.version-$(R)-command) : <mspsdk>psdk <arch>i386 <psdk-path>$(psdk-path) ;
+ register $(R) : $(.version-$(R)-command) : <mspsdk>psdk <arch>amd64 <psdk-path>$(psdk-path) ;
+ register $(R) : $(.version-$(R)-command) : <mspsdk>psdk <arch>ia64 <psdk-path>$(psdk-path) ;
+ }
}
- using msvc : $(vc-version) : "$(vc-path)\\bin\\cl.exe" ;
}
}
}
+
diff -Naur BBv2.old/tools/msvc.jam BBv2.new/tools/msvc.jam
--- BBv2.old/tools/msvc.jam 2005-07-31 19:22:16.592136000 +0200
+++ BBv2.new/tools/msvc.jam 2005-08-03 21:24:16.386886400 +0200
@@ -13,8 +13,11 @@
import path ;
import sequence : unique ;
import common ;
+import regex ;

import rc ;
+import midl ;
+import mc ;

if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
@@ -30,94 +33,86 @@
# to be seen, though ;-)
;

+# Inherit MIDL flags
+toolset.inherit-flags msvc : midl ;
+
+# Inherit MC flags
+toolset.inherit-flags msvc : mc ;
+
RM = [ common.rm-command ] ;

-# Initialize the toolset for a specific version. As the result, path to
-# compiler and, possible, program names are set up, and will be used when
-# that version of compiler is requested. For example, you might have::
-#
-# using msvc : 6.5 : X:/some_dir ;
-# using msvc : 7.0 : Y:/some_dir ;
-# using msvc : : Z:/some_dir
-#
-# If you have "msvc-6.5" in build request, the version from X: drive will be used,
-# and if you put only "msvc", then drive "Z:" will be used. Note that it's not possible
-# the specify that by default, version 7.0 must be used --- you should use 'using'
-# without version number for that effect.
-#
-# version --
-# path --
-#
-# When invoking tools, we'll first run vcvars32.bat from the configured path and
-# then cl/link, without path.
-#
-# Note: for free VC7.1 tools, we don't correctly find vcvars32.bar when user
-# explicitly provides a path.
-rule init (
- version ? # the msvc version which is being configured. When omitted
- # the tools invoked when no explicit version is given will be configured.
- : command *
- # the command to invoke the compiler. If not specified:
- # - if version is given, default location for that version will be searched
- #
- # - if version is not given, default locations for 7.1, 7.0 and 6.* will
- # be searched
- #
- # - if compiler is not found in default locations, PATH will be searched.
- : options *
- # options can include <setup>, <compiler>, <linker> and <resource-compiler>
-)
-{
- # setup will be used iff a path has been specified. If setup is
- # not specified, vcvars32.bat will be used instead.
- setup = [ get-values <setup> : $(options) ] ;
- setup ?= vcvars32.bat ;
- compiler = [ get-values <compiler> : $(options) ] ;
- compiler ?= cl ;
- linker = [ get-values <linker> : $(options) ] ;
- linker ?= link ;
- resource-compiler = [ get-values <resource-compiler> : $(options) ] ;
- resource-compiler ?= rc ;
-
- local condition = [ common.check-init-parameters msvc :
- version $(version) ] ;
+#
+# toolset: msvc
+# toolset-version: 6.0, 7.0., 7.1, 8.0
+# toolset-arch: i386, amd64, ia64
+# toolset-mspsdk: psdk, studio
+#

- # 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) ] ;
-
- common.handle-options msvc : $(condition) : $(command) : $(options) ;
-
- if $(command)
- {
- command = [ common.get-absolute-tool-path $(command[-1]) ] ;
- }
- local root = $(command:D) ;
-
- setup = $(root)\\bin\\$(setup) ;
-
- # CONSIDER: What's the point of 'call'. Can we invoke the script directly?
- setup = "call \""$(setup)"\" > nul " ;
-
- if [ os.name ] = NT
- {
- setup = $(setup)"
-" ;
- }
- else
- {
- setup = "cmd /S /C "$(setup)" \"&&\" " ;
- }
+feature.subfeature toolset msvc : version
+ : 8.0 7.1 7.0 6.0
+ : propagated
+ ;
+
+feature.subfeature toolset msvc : arch
+ : i386 amd64 ia64
+ : propagated
+ ;
+
+feature.subfeature toolset msvc : mspsdk
+ : studio psdk
+ : propagated
+ ;
+
+
+rule init (
+ version ? :
+ command * :
+ options *
+ )
+{
+ internal-init <version>$(version) <msvc-command>$(command) $(options) ;
+}
+
+
+# Initialize the toolset for a specific version and cpu architecture.
+#
+# To successfully configure the toolset correct '<msvc-command>' (and optionally
+# '<psdk-path>') should be passed. For example:
+#
+# using msvc :
+# <version>8.0
+# <msvc-command>"C:\\Program Files\\Microsoft Visual Studio 8\\VC\\bin\\cl.exe" ;
+#
+# Full path is preffered. Below you will find the full list of allowed options.
+# The most important options are marked with '*'.
+#
+# Options:
+#
+# * <version> - the msvc version which is being configured (6.0, 7.0, 7.1, 8.0)
+# * <arch> - i386, amd64, ia64
+# * <mspsdk> - studio, psdk
+#
+# - <msvc-setup> - the msvc setup script name (vcvars32.bat)
+# * <msvc-command> - the command to invoke the compiler
+# - <psdk-setup> - the PSDK setup script name (SetEnv.Cmd)
+# * <psdk-path> - full path to Platform SDK installation
+#
+# - <compiler> - C/C++ compiler (cl)
+# - <linker> - linker (link)
+# - <resource-compiler> - resource compiler (rc)
+# - <idl-compiler> - MIDL compiler (midl)
+# - <mc-compiler> - message compiler (mc)
+#
+rule internal-init (
+ options *
+ )
+{
+ #
+ # Get unique toolset id: version, arch and mspsdk.
+ #
+
+ version = [ get-values <version> : $(options) ] ;

- # prefix with setup, or quoted path if any
- local prefix = $(setup) ;
-
- flags msvc.compile .CC $(condition) : $(prefix)$(compiler) ;
- flags msvc.compile .RC $(condition) : $(prefix)$(resource-compiler) ;
- flags msvc.link .LD $(condition) : $(prefix)$(linker) ;
- flags msvc.archive .LD $(condition) : $(prefix)$(linker) ;
-
if ! $(version)
{
# Even if version is not explicitly specified, try to detect the version
@@ -126,12 +121,12 @@
{
version = 8.0 ;
}
- else if [ MATCH "(\\.NET 2003\\VC7)" : $(command) ] ||
+ else if [ MATCH "(NET 2003[\/\\]VC7)" : $(command) ] ||
[ MATCH "(Microsoft Visual C\\+\\+ Toolkit 2003)" : $(command) ]
{
version = 7.1 ;
}
- else if [ MATCH "(.NET\\VC7)" : $(command) ]
+ else if [ MATCH "(.NET[\/\\]VC7)" : $(command) ]
{
version = 7.0 ;
}
@@ -140,81 +135,218 @@
version = 6.0 ;
}
}
-
- # Starting with versions 7.0, the msvc compiler have the /Zc:forScope
- # and /Zc:wchar_t options that improve C++ standard conformance, but
- # those options are off by default.
- # If we're sure that msvc version is at 7.*, add those options explicitly.
- # We can be sure either if user specified version 7.* explicitly,
- # or if the installation path contain 7.* (this is checked above).
- if [ MATCH ^(7\..*) : $(version) ]
+
+ arch = [ get-values <arch> : $(options) ] ;
+ arch ?= i386 ;
+
+ mspsdk = [ get-values <mspsdk> : $(options) ] ;
+ mspsdk ?= studio ;
+
+ local condition =
+ [ common.check-init-parameters msvc :
+ version $(version) :
+ arch $(arch) :
+ mspsdk $(mspsdk)
+ ] ;
+
+ if --debug-configuration in [ modules.peek : ARGV ]
{
- flags msvc.compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ;
+ ECHO "msvc toolset initialization: condition " $(condition) ;
}
-
- # 8.0 deprecates some of the options
- if ! [ MATCH ^([67].*) : $(version) ]
+
+
+ #
+ # Check validness of the selected parameters
+ #
+
+ local below-8.0 = [ MATCH ^([67]\\.) : $(version) ] ;
+
+ if ( $(arch) != i386 ) && ( $(mspsdk) = studio ) && $(below-8.0)
+ {
+ error
+ "msvc toolset initialization: an incompartible combination: "
+ "<toolset-msvc:arch>$(arch) <toolset-msvc:mspsdk>$(mspsdk)" ;
+ }
+
+ #
+ # Construct command prefix
+ #
+
+ msvc-setup = [ get-values <msvc-setup> : $(options) ] ;
+
+ if $(below-8.0)
{
- flags msvc.compile CFLAGS $(condition)/<optimization>speed : /O2 ;
- flags msvc.compile CFLAGS $(condition)/<optimization>space : /O1 ;
- flags msvc.link.dll MANIFEST : "mt -manifest " ;
- flags msvc.link.dll OUTPUTRESOURCE : "-outputresource:" ;
+ msvc-setup ?= vcvars32.bat ;
}
else
- {
- flags msvc.compile CFLAGS $(condition)/<optimization>speed : /Ogity /O2 /Gs ;
- flags msvc.compile CFLAGS $(condition)/<optimization>space : /Ogisy /O1 /Gs ;
- }
-}
+ {
+ msvc-setup ?= vcvarsall.bat ;
+ }

-rule default-paths ( version ? )
-{
- local possible-paths ;
-
- local ProgramFiles = [ os.environ ProgramFiles ] ;
- if ! $(ProgramFiles)
- {
- ProgramFiles = "c:\\Program Files" ;
+ msvc-command = [ get-values <msvc-command> : $(options) ] ;
+
+ if $(arch) = i386 && ! $(msvc-command)
+ {
+ error "msvc toolset initialization: <msvc-command> is required when <toolset-msvc:arch>i386 selected" ;
}

- 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 = [ modules.peek : VS71COMNTOOLS ] ;
- if $(VS71COMNTOOLS)
+ psdk-setup = [ get-values <psdk-setup> : $(options) ] ;
+ psdk-setup ?= SetEnv.Cmd ;
+
+ psdk-path = [ get-values <psdk-path> : $(options) ] ;
+
+ if $(mspsdk) = psdk && ! $(psdk-path)
{
- # VS71COMNTOOLS is set by VS .NET 2003 to <VSDIR>\Common7\Tools
- version-7.1-path = [ path.make "$(VS71COMNTOOLS:J= )" ] ;
- 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) ] ;
+ error "msvc toolset initialization: <psdk-path> is required when <toolset-msvc:mspsdk>psdk selected" ;
}
-
- local VCToolkitInstallDir = [ modules.peek : VCToolkitInstallDir ] ;
- if $(VCToolkitInstallDir)
+
+ if $(msvc-command)
+ {
+ msvc-command = [ common.get-absolute-tool-path $(msvc-command[-1]) ] ;
+
+ local parent = [ path.make $(msvc-command) ] ;
+ parent = [ path.parent $(parent) ] ;
+ parent = [ path.native $(parent) ] ;
+
+ # The vccars32.bat is actually in "bin" directory.
+ # (except for free VC7.1 tools)
+ msvc-setup = [ GLOB $(msvc-command) $(parent) : $(msvc-setup) ] ;
+
+ if ! $(msvc-setup)
+ {
+ error "msvc toolset initialization: Visual Studio setup script not found" ;
+ }
+
+ msvc-setup = "\""$(msvc-setup)"\"" ;
+
+ if ! $(below-8.0)
+ {
+ switch $(arch)
+ {
+ case i386 : msvc-setup = $(msvc-setup)" x86" ;
+ case amd64 : msvc-setup = $(msvc-setup)" x86_amd64" ;
+ case ia64 : msvc-setup = $(msvc-setup)" x86_ia64" ;
+ }
+ }
+
+ msvc-setup = "call "$(msvc-setup)" > nul 2>&1" ;
+ }
+ else
{
- version-7.1-path = [ path.make "$(VCToolkitInstallDir:J= )" ] ;
+ msvc-setup = ;
}
-
- if $(version)
+
+ if $(psdk-path)
{
- local v = [ MATCH ^(6|[^6].*) : $(version) ] ;
- possible-paths += $(version-$(v)-path) ;
+ psdk-setup = [ GLOB $(psdk-path) : $(psdk-setup) ] ;
+
+ if ! $(psdk-setup)
+ {
+ error "msvc toolset initialization: Platform SDK setup script not found" ;
+ }
+
+ psdk-setup = "\""$(psdk-setup)"\"" ;
+
+ switch $(arch)
+ {
+ case i386 : psdk-setup = $(psdk-setup)" /XP32" ;
+ case amd64 : psdk-setup = $(psdk-setup)" /XP64" ;
+ case ia64 : psdk-setup = $(psdk-setup)" /SRV64" ;
+ }
+
+ psdk-setup = "call "$(psdk-setup)" > nul 2>&1" ;
}
else
{
- possible-paths += $(version-8.0-path) $(version-7.1-path) $(version-7.0-path) $(version-6-path) ;
+ psdk-setup = ;
+ }
+
+ local command-separator = " \"&&\" " ;
+ if [ os.name ] = NT
+ {
+ command-separator = "
+" ;
+ }
+
+
+ local prefix ;
+
+ if $(msvc-setup)
+ {
+ prefix = $(msvc-setup)$(command-separator) ;
}
+
+ if $(psdk-setup)
+ {
+ prefix = $(prefix)$(psdk-setup)$(command-separator) ;
+ }
+
+ if [ os.name ] != NT
+ {
+ prefix = "cmd /S /C "$(prefix) ;
+ }
+
+ common.handle-options msvc : $(condition) : $(prefix) : $(options) ;
+
+ #
+ # Get tool names (if any) and finish setup
+ #

- # The vccars32.bat is actually in "bin" directory.
- # (except for free VC7.1 tools)
- possible-paths = $(possible-paths)\\bin $(possible-paths) ;
+ compiler = [ get-values <compiler> : $(options) ] ;
+ compiler ?= cl ;
+
+ linker = [ get-values <linker> : $(options) ] ;
+ linker ?= link ;
+
+ resource-compiler = [ get-values <resource-compiler> : $(options) ] ;
+ resource-compiler ?= rc ;
+
+ idl-compiler = [ get-values <idl-compiler> : $(options) ] ;
+ idl-compiler ?= midl ;
+
+ mc-compiler = [ get-values <mc-compiler> : $(options) ] ;
+ mc-compiler ?= mc ;

- return $(possible-paths) ;
+ #
+ # Register commands
+ #
+
+ if --debug-configuration in [ modules.peek : ARGV ]
+ {
+ ECHO "msvc toolset initialization: prefix " $(prefix) ;
+ }
+
+ flags msvc.compile .CC $(condition) : $(prefix)$(compiler) ;
+ flags msvc.compile .RC $(condition) : $(prefix)$(resource-compiler) ;
+ flags msvc.compile .IDL $(condition) : $(prefix)$(idl-compiler) ;
+ flags msvc.compile .MC $(condition) : $(prefix)$(mc-compiler) ;
+ flags msvc.link .LD $(condition) : $(prefix)$(linker) ;
+ flags msvc.archive .LD $(condition) : $(prefix)$(linker) ;
+
+
+ # Starting with versions 7.0, the msvc compiler have the /Zc:forScope
+ # and /Zc:wchar_t options that improve C++ standard conformance, but
+ # those options are off by default.
+ # If we're sure that msvc version is at 7.*, add those options explicitly.
+ # We can be sure either if user specified version 7.* explicitly,
+ # or if the installation path contain 7.* (this is checked above).
+ if ! [ MATCH ^(6\\.) : $(version) ]
+ {
+ flags msvc.compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ;
+ }
+
+ # 8.0 deprecates some of the options
+ if $(below-8.0)
+ {
+ flags msvc.compile CFLAGS $(condition)/<optimization>speed $(condition)/<optimization>space : /Ogiy /Gs ;
+ flags msvc.compile CFLAGS $(condition)/<optimization>speed : /Ot ;
+ flags msvc.compile CFLAGS $(condition)/<optimization>space : /Os ;
+ }
+ else
+ {
+ flags msvc.link MANIFEST $(condition) : "mt -nologo -manifest " ;
+ flags msvc.link OUTPUTRESOURCE $(condition) : "-outputresource:" ;
+ }
}

@@ -229,13 +361,26 @@
generators.register-archiver msvc.archive : OBJ : STATIC_LIB : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c++ : CPP : OBJ : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c : C : OBJ : <toolset>msvc ;
-generators.register-standard msvc.compile.rc : RC : OBJ(%_res) : <toolset>msvc ;
+
+# 'register-c-compiler' causes a build directory to be added to INCLUDES
+generators.register-c-compiler msvc.compile.rc : RC : OBJ(%_res) : <toolset>msvc ;
+
generators.override msvc.compile.rc : rc.resource-compile ;

+generators.register-c-compiler msvc.compile.idl : IDL : TLB H C(%_i) C(%_proxy) C(%_dlldata) : <toolset>msvc ;
+generators.override msvc.compile.idl : midl.compile.idl ;
+
+generators.register-standard msvc.compile.mc : MC : H RC : <toolset>msvc ;
+generators.override msvc.compile.mc : mc.compile ;
+
#
# Declare flags and action for compilation
#
feature.feature debug-store : object database : propagated ;
+
+flags msvc.compile CFLAGS <optimization>speed : /O2 ;
+flags msvc.compile CFLAGS <optimization>space : /O1 ;
+
flags msvc.compile CFLAGS <debug-symbols>on/<debug-store>object : /Z7 ;
flags msvc.compile CFLAGS <debug-symbols>on/<debug-store>database : /Zi ;
flags msvc.compile CFLAGS <optimization>off : /Od ;
@@ -254,9 +399,17 @@

flags msvc.compile CFLAGS <runtime-debugging>off/<runtime-link>static/<threading>single : /ML ;
flags msvc.compile CFLAGS <runtime-debugging>on/<runtime-link>static/<threading>single : /MLd ;
+
flags msvc.compile CFLAGS <runtime-debugging>off/<runtime-link>static/<threading>multi : /MT ;
flags msvc.compile CFLAGS <runtime-debugging>on/<runtime-link>static/<threading>multi : /MTd ;

+flags msvc.compile CFLAGS : /Zm800 ;
+
+# Add -GS (Buffer Security Check) for VC++ 7.0
+flags msvc.compile CFLAGS <toolset-msvc:version>7.0 : /GS ;
+
+flags msvc.compile.c++ C++FLAGS <toolset-msvc:arch>i386 : /wd4675 ;
+
flags msvc.compile USER_CFLAGS <cflags> : ;
flags msvc.compile.c++ USER_CFLAGS <cxxflags> : ;

@@ -266,16 +419,16 @@
flags msvc.compile UNDEFS <undef> ;
flags msvc.compile INCLUDES <include> ;

-flags msvc.compile.c++ C++FLAGS : /wd4675 ;
-
# The actions differ only by explicit selection of input language
actions compile.c bind RSP
{
- $(.CC) /Zm800 -nologo -TC -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) @"$(RSP:W)" -c -Fo"$(<[1]:W)" && $(RM) "$(RSP)"
+ $(.CONFIG_COMMAND)$(.CONFIG_PSDK)$(.SEPARATOR)
+
+ $(.CC) -nologo -TC -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) @"$(RSP:W)" -c -Fo"$(<[1]:W)" && $(RM) "$(RSP)"
}
actions compile.c++ bind RSP
{
- $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"$(RSP:W)" -c -Fo"$(<[1]:W)" && $(RM) "$(RSP)"
+ $(.CC) -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"$(RSP:W)" -c -Fo"$(<[1]:W)" && $(RM) "$(RSP)"
}

actions compile.rc
@@ -297,6 +450,8 @@
flags msvc LINKFLAGS <user-interface>native : /subsystem:native ;
flags msvc LINKFLAGS <user-interface>auto : /subsystem:posix ;

+flags msvc LINKFLAGS <toolset-msvc:arch>amd64/<toolset-msvc:mspsdk>psdk : bufferoverflowu.lib ;
+
flags msvc LINKFLAGS <main-target-type>LIB/<link>shared : /DLL ;

toolset.flags msvc.link USER_LINKFLAGS <linkflags> ;
@@ -354,9 +509,16 @@
# rebuilt every time. I'm not sure that incremental linking is
# such a great idea in general, but in this case I'm sure we
# don't want it.
+
+# Windows Manifests is a new way to specify dependencies
+# on managed DotNet assemblies and Windows native DLLs. The
+# manifests are embedded as resourses and are useful in
+# any PE targets (both DLL and EXE)
+
actions link bind DEF_FILE RSP
{
$(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /LIBPATH:"$(LINKPATH:W)" $(USER_LINKFLAGS) @"$(RSP:W)" && $(RM) "$(RSP)"
+ $(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);#2
}

actions link.dll bind DEF_FILE RSP
@@ -375,4 +537,17 @@
common.response-file $(targets) : $(sources) : $(targets[2]) : $(properties) ;
}

+flags msvc.compile.idl MIDLFLAGS <toolset-msvc:arch>i386 : /win32 ;
+flags msvc.compile.idl MIDLFLAGS <toolset-msvc:arch>amd64 : /x64 ;
+flags msvc.compile.idl MIDLFLAGS <toolset-msvc:arch>ia64 : /ia64 ;
+
+actions compile.idl
+{
+ $(.IDL) /nologo /U$(UNDEFS) /D$(DEFINES) $(MIDLFLAGS) /I"$(INCLUDES)" /tlb "$(<[1]:W)" /h "$(<[2]:W)" /iid "$(<[3]:W)" /proxy "$(<[4]:W)" /dlldata "$(<[5]:W)" "$(>:W)"
+}
+
+actions compile.mc
+{
+ $(.MC) $(MCFLAGS) -h "$(<[1]:DW)" -r "$(<[2]:DW)" "$(>:W)"
+}

diff -Naur BBv2.old/tools/rc.jam BBv2.new/tools/rc.jam
--- BBv2.old/tools/rc.jam 2005-07-31 19:22:16.622179200 +0200
+++ BBv2.new/tools/rc.jam 2005-07-29 17:25:39.363160000 +0200
@@ -58,7 +58,9 @@
# The reason we generate OBJ and not RES, is that gcc does not
# seem to like RES files, but works OK with OBJ.
# See http://article.gmane.org/gmane.comp.lib.boost.build/5643/
-generators.register-standard rc.resource-compile : RC : OBJ(%_res) ;
+#
+# 'register-c-compiler' causes a build directory to be added to INCLUDES
+generators.register-c-compiler rc.resource-compile : RC : OBJ(%_res) ;

# Register scanner for resources
class res-scanner : scanner
 --------------050905060409000409080404--


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