diff --git a/src/build/property.jam b/src/build/property.jam index b36586a3e7..cd76d0f15a 100644 --- a/src/build/property.jam +++ b/src/build/property.jam @@ -552,6 +552,12 @@ rule translate-indirect-value ( rulename : context-module ) } +local translate-path-rules ; +rule add-toolset-translate-path-rule ( tpr ) +{ + translate-path-rules += $(tpr) ; +} + # Equivalent to a calling all of: # translate-path # translate-indirect @@ -561,7 +567,7 @@ rule translate-indirect-value ( rulename : context-module ) # rule translate ( properties * : project-id : project-location : context-module ) { - local translate-path-rule = [ MATCH "^[@](.*)$" : "$(properties)" ] ; + translate-path-rules += [ MATCH "^[@](.*)$" : "$(properties)" ] ; local result ; for local p in $(properties) { @@ -610,10 +616,17 @@ rule translate ( properties * : project-id : project-location : context-module ) { if path in $(attributes) { - if $(translate-path-rule) + # Iterate through each translate path rule in turn, + # until one returns a successful translation. + for local tpr in $(translate-path-rules) { - value = [ $(translate-path-rule) $(feature) $(property:G=) : $(properties) : $(project-id) : $(project-location) ] ; + value = [ $(tpr) $(feature) $(property:G=) : $(properties) : $(project-id) : $(project-location) ] ; + if $(value) + { + break ; + } } + # If no translate path rule intervened, continue with usual translation. if ! $(value) { value = [ translate-path-value $(property:G=) : $(project-location) ] ; diff --git a/src/tools/darwin.jam b/src/tools/darwin.jam index 222d00ba8a..231b87e8e2 100644 --- a/src/tools/darwin.jam +++ b/src/tools/darwin.jam @@ -17,6 +17,7 @@ import common ; import generators ; import path : basename ; import version ; +import property ; import property-set ; import regex ; import errors ; @@ -451,6 +452,40 @@ flags darwin.link FORCE_LOAD ; # uncomment to see what libtool is doing under the hood #~ flags darwin.link.dll OPTIONS : -Wl,-v ; +# Darwin specific translate-rule; +# ------------------------------- +# Catch the Darwin-specific "@xxx" placeholders (see 'man dyld') in +# properties, and return them as they are. +# (I.e. signal to caller to NOT translate them to the filesystem.) +# For all other values return nothing. +# (I.e. signal to caller to continue with translation as usual.) +# This is called from 'property.translate' - See documentation for 'translate-path' feature. +rule at-placeholder-translate-path-rule ( feature value : properties * : project-id : project-location ) +{ + local rv ; + + if $(feature) = "" + { + # These '@xxx' placeholders are specified and processed by 'dyld'; + # (See 'man dyld'). + # As each of these is to be replaced by 'dyld' with a root path, + # they are only expected - and therefore tested here - as root paths. + switch $(value) + { + case @executable_path* : rv = $(value) ; + case @loader_path* : rv = $(value) ; + case @rpath* : rv = $(value) ; + } + } + + return $(rv) ; +} +# Import the 'at-placeholder-translate-path-rule' into the global namespace +# as 'darwin.at-placeholder-translate-path-rule'. +IMPORT $(__name__) : at-placeholder-translate-path-rule : : darwin.at-placeholder-translate-path-rule ; +# Add the above exported name to the list of translate path rules for property.translate. +property.add-toolset-translate-path-rule darwin.at-placeholder-translate-path-rule ; + # set up the -F option to include the paths to any frameworks used. local rule prepare-framework-path ( target + ) { diff --git a/src/tools/features/translate-path-feature.jam b/src/tools/features/translate-path-feature.jam index c99f4655d3..6607a394d1 100644 --- a/src/tools/features/translate-path-feature.jam +++ b/src/tools/features/translate-path-feature.jam @@ -26,6 +26,9 @@ the path property value, target properties, the target project ID, and the target project location. It should return the translated path value. Or return nothing if it doesn't do path translation. Leaving it do the default path translation. ++ +The feature is additive -- i.e. multiple `translate-path` rules can be called, +in order -- until the first one to return a value. |# # end::doc[]