diff --git a/msvc.jam b/msvc.jam index 31f9e4b1f..05a67d062 100755 --- a/msvc.jam +++ b/msvc.jam @@ -28,9 +28,6 @@ feature.subfeature toolset msvc : vendor # link-incompatible ; -.version-configured = ; -.versionless-configured = ; - # Initialize the toolset rule init ( version ? : path ? : vendor ? : setup ? compiler ? linker ? ) { @@ -47,33 +44,18 @@ rule init ( version ? : path ? : vendor ? : setup ? compiler ? linker ? ) local condition = -$(vendor)$(version) ; condition ?= "" ; condition = msvc$(condition) ; - + # setup will be used iff a path has been specified. If setup is # not specified, vcvars32.bat will be used instead. setup ?= vcvars32.bat ; if ! $(path) && ! $(vendor) { - local v = [ MATCH ^(6|[^6].*) : $(version) ] ; - local version-6-path = "c:\\Program Files\\Microsoft Visual Studio\\VC98" ; - local version-7-path = "c:\\Program Files\\Microsoft Visual Studio .NET\\VC7" ; - local version-7.0-path = $(version-7-path) ; - local version-7.1-path = "c:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7" ; - local default-path = $(version-$(v)-path) ; - - # look for the setup program in both the system PATH and in - # its default installation location based on version - local env-PATH = [ modules.peek : PATH Path path ] ; - local PATH-setup = [ GLOB $(env-PATH) : $(setup) ] ; - local default-setup = [ GLOB $(default-path)\\bin : $(setup) ] ; - - if $(default-setup) && $(PATH-setup) != $(default-setup) - { - path = $(default-path) ; - } + path = [ locate $(version) ] ; compiler = $(compiler) ; + local env-PATH = [ modules.peek : PATH Path path ] ; if ! [ GLOB [ path.native [ path.join $(path) "bin" ] ] $(env-PATH) : $(compiler:E=CL).EXE ] { error toolset msvc $(vendor) $(version) initialization: : @@ -82,7 +64,9 @@ rule init ( version ? : path ? : vendor ? : setup ? compiler ? linker ? ) : PATH= \"$(env-PATH)\" ; } } - + + # FIXME? The 'path' can be empty here, which will give us + # empty 'setup'. See comment in 'locate' below. setup = "call \""$(path)\\bin\\$(setup)"\" > nul" ; if [ os.name ] = NT @@ -94,8 +78,6 @@ rule init ( version ? : path ? : vendor ? : setup ? compiler ? linker ? ) { setup = "cmd /S /C "$(setup)" \"&&\" " ; } - - flags msvc SETUP $(condition) : $(setup:E="") ; # prefix with setup, or quoted path if any local prefix = $(setup) ; @@ -103,7 +85,7 @@ rule init ( version ? : path ? : vendor ? : setup ? compiler ? linker ? ) prefix ?= "" ; compiler ?= cl ; linker ?= link ; - + flags msvc.compile .CC $(condition) : $(prefix)$(compiler) ; flags msvc.link .LD $(condition) : $(prefix)$(linker) ; flags msvc.archive .LD $(condition) : $(prefix)$(linker) ; @@ -111,6 +93,38 @@ rule init ( version ? : path ? : vendor ? : setup ? compiler ? linker ? ) .CC = cl ; .LD = LINK ; + + +# Attempts to find the directory where the compiler is located, and returns it. +# If there are several possibilities, returns arbitrary one, after issuing a +# warning message. +local rule locate ( version ) +{ + local v = [ MATCH ^(6|[^6].*) : $(version) ] ; + local version-6-path = "c:\\Program Files\\Microsoft Visual Studio\\VC98" ; + local version-7-path = "c:\\Program Files\\Microsoft Visual Studio .NET\\VC7" ; + local version-7.0-path = $(version-7-path) ; + local version-7.1-path = "c:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7" ; + local default-path = $(version-$(v)-path) ; + + # look for the setup program in both the system PATH and in + # its default installation location based on version + local env-PATH = [ modules.peek : PATH Path path ] ; + local PATH-setup = [ GLOB $(env-PATH) : $(setup) ] ; + local default-setup = [ GLOB $(default-path)\\bin : $(setup) ] ; + + # CONSIDER: what's the intentions here? Probably, it's meant that if + # setup script found in path is the same as setup script found + # in default location, we can invoke this script without full path. + # This probably does not work --- if we return empty path, the setup + # script won't be called at all. + if $(default-setup) && $(PATH-setup) != $(default-setup) + { + return $(default-path) ; + } +} + + # Declare generators