diff --git a/src/tools/gcc.jam b/src/tools/gcc.jam index 800d3f2b2..406a69768 100644 --- a/src/tools/gcc.jam +++ b/src/tools/gcc.jam @@ -434,41 +434,39 @@ class gcc-linking-generator : unix-linking-generator local generated-targets = [ unix-linking-generator.run $(project) $(name) : $(property-set) : $(sources) ] ; - # If more than one target was generated, throw out the - # last one, which on windows just leaves the import - # library. Most generators on windows simply don't accept - # shared libraries as input, but being able to link - # directly to a shared library without an import library - # is an important capability of GCC. Therefore, we remove - # the target after the action sees it so that dependent - # targets don't try to link to both the import library and - # the DLL. - if [ $(property-set).get ] = true - { - return $(generated-targets[0]) $(generated-targets[-1]) ; - } - else - { - return $(generated-targets[1-2]) ; - } + return $(generated-targets) ; } } } -generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE - : gcc ] ; - .IMPLIB-COMMAND = ; -.IMPLIB-TYPE = ; if [ os.on-windows ] { .IMPLIB-COMMAND = "-Wl,--out-implib," ; - .IMPLIB-TYPE = IMPORT_LIB ; + generators.register + [ new gcc-linking-generator gcc.link + : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB + : EXE + : gcc ] ; + generators.register + [ new gcc-linking-generator gcc.link.dll + : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB + : IMPORT_LIB SHARED_LIB + : gcc ] ; +} +else +{ + generators.register + [ new gcc-linking-generator gcc.link + : LIB OBJ + : EXE + : gcc ] ; + generators.register + [ new gcc-linking-generator gcc.link.dll + : LIB OBJ + : SHARED_LIB + : gcc ] ; } - -generators.register - [ new gcc-linking-generator gcc.link.dll : LIB OBJ : $(.IMPLIB-TYPE) SHARED_LIB - : gcc ] ; # Declare flags for linking # First, the common flags diff --git a/src/tools/testing.jam b/src/tools/testing.jam index 946ca4bc6..4a5a24764 100644 --- a/src/tools/testing.jam +++ b/src/tools/testing.jam @@ -354,7 +354,7 @@ toolset.flags testing.capture-output LAUNCHER ; # - if 'none', does not remove anything, ever # - if empty, removes 'source' # - if non-empty and not 'none', contains a list of sources to remove. -rule capture-output ( target : source : properties * : targets-to-remove ? ) +rule capture-output ( target : source : properties * : targets-to-remove * ) { output-file on $(target) = $(target:S=.output) ; LOCATE on $(target:S=.output) = [ on $(target) return $(LOCATE) ] ; diff --git a/src/tools/vacpp.jam b/src/tools/vacpp.jam index b275a5ea8..6a4741c4b 100644 --- a/src/tools/vacpp.jam +++ b/src/tools/vacpp.jam @@ -70,12 +70,13 @@ if [ os.name ] = AIX flags vacpp.link LINKFLAGS static : -qtwolink ; # Run-time linking - flags vacpp.link EXE-LINKFLAGS shared : -brtl ; + flags vacpp.link EXE-LINKFLAGS shared : -brtl -qtwolink ; } else { # Linux PPC flags vacpp.compile CFLAGS shared : -qpic ; + flags vacpp FINDLIBS : rt ; } # Profiling diff --git a/src/util/os.jam b/src/util/os.jam index c0d9bf5bc..71c10e0a4 100644 --- a/src/util/os.jam +++ b/src/util/os.jam @@ -5,6 +5,7 @@ # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) import modules ; +import string ; # Return the value(s) of the given environment variable(s) at the time # bjam was invoked. @@ -17,51 +18,79 @@ rule environ ( variable-names + ) .platform = [ modules.peek : OSPLAT ] ; .version = [ modules.peek : OSVER ] ; -local rule constant ( c ) +local rule constant ( c : os ? ) { + os ?= $(.name) ; # First look for platform-specific name, then general value - local variables = .$(c)-$(.name) .$(c) ; + local variables = .$(c)-$(os) .$(c) ; local result = $($(variables)) ; return $(result[1]) ; } -rule get-constant ( ) +rule get-constant ( os ? ) { # Find the name of the constant being accessed, which is # equal to the name used to invoke us. local bt = [ BACKTRACE 1 ] ; local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ; - return [ constant $(rulename) ] ; + return [ constant $(rulename) : $(os) ] ; } # export all the common constants -.constants = name platform version shared-library-path-variable path-separator ; +.constants = name platform version shared-library-path-variable path-separator executable-path-variable executable-suffix ; for local constant in $(.constants) { IMPORT $(__name__) : get-constant : $(__name__) : $(constant) ; } EXPORT $(__name__) : $(.constants) ; -.shared-library-path-variable-NT = PATH ; +.executable-path-variable-NT = PATH ; +# On Windows the case and capitalization of PATH is not always +# predictable, so let's find out what variable name was really set. +if $(.name) = NT +{ + for local n in [ VARNAMES .ENVIRON ] + { + if $(n:L) = path + { + .executable-path-variable-NT = $(n) ; + } + } +} + +# Specific constants for various platforms. There's no need to define +# any constant whose value would be the same as the default, below. +.shared-library-path-variable-NT = $(.executable-path-variable-NT) ; .path-separator-NT = ";" ; .expand-variable-prefix-NT = % ; .expand-variable-suffix-NT = % ; +.executable-suffix-NT = .exe ; .shared-library-path-variable-CYGWIN = PATH ; -.path-separator-CYGWIN = ":" ; -.expand-variable-prefix-CYGWIN = $ ; -.expand-variable-suffix-CYGWIN = "" ; .shared-library-path-variable-MACOSX = DYLD_LIBRARY_PATH ; .shared-library-path-variable-AIX = LIBPATH ; +# Default constants .shared-library-path-variable = LD_LIBRARY_PATH ; .path-separator = ":" ; .expand-variable-prefix = $ ; .expand-variable-suffix = "" ; +.executable-path-variable = PATH ; +.executable-suffix = "" ; +# Return a list of the directories in the PATH. Yes, that information +# is (sort of) available in the global module, but jam code can change +# those values, and it isn't always clear what case/capitalization to +# use when looking. This rule is a more reliable way to get there. +rule executable-path ( ) +{ + return [ string.words [ environ [ constant executable-path-variable ] ] + : [ constant path-separator ] ] ; +} + if $(.name) = NT { local home = [ environ HOMEDRIVE HOMEPATH ] ; diff --git a/src/util/sequence.jam b/src/util/sequence.jam index 00a60c5aa..8cbd1e8fb 100644 --- a/src/util/sequence.jam +++ b/src/util/sequence.jam @@ -46,6 +46,16 @@ rule transform ( function + : sequence * ) return $(result) ; } +rule reverse ( s * ) +{ + local r ; + for local x in $(s) + { + r = $(x) $(r) ; + } + return $(r) ; +} + rule less ( a b ) { @@ -304,5 +314,7 @@ local rule __test__ ( ) assert.result e-3 h-3 : sequence.select-highest-ranked e-1 e-3 h-3 m-2 : 1 3 3 2 ; + + assert.result 7 6 5 4 3 2 1 : sequence.reverse 1 2 3 4 5 6 7 ; } }