Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Darwin @xxx placeholders in dll-path #335

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/build/property.jam
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;
}

Comment on lines +555 to +560
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this globally has some serious side effects (see the comment in translate rule). There's a better way to achieve a similar "global" effect with toolset.add-requirements but without the drawbacks.

# Equivalent to a calling all of:
# translate-path
# translate-indirect
Expand All @@ -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 "^<translate-path>[@](.*)$" : "$(properties)" ] ;
translate-path-rules += [ MATCH "^<translate-path>[@](.*)$" : "$(properties)" ] ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this be global will have the effect of a compounding effect of multiple redundant translate rules being added. The rules could also not be related to the particular targets as they are global and will be run for all target and toolsets, not just the darwin one, if one happens to build with multiple toolsets at once. Hence this needs to be a plain local translate-path-rules = ....

local result ;
for local p in $(properties)
{
Expand Down Expand Up @@ -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.
Comment on lines +619 to +629
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine.

if ! $(value)
{
value = [ translate-path-value $(property:G=) : $(project-location) ] ;
Expand Down
35 changes: 35 additions & 0 deletions src/tools/darwin.jam
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import common ;
import generators ;
import path : basename ;
import version ;
import property ;
import property-set ;
import regex ;
import errors ;
Expand Down Expand Up @@ -451,6 +452,40 @@ flags darwin.link FORCE_LOAD <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 <dll-path>
# 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) = "<dll-path>"
{
# 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 ;

Comment on lines +483 to +488
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This you need to replace with an appropriate call to toolset.add-requirement in the rule init of the darwin toolset. In particular it should add a conditional (on the toolset $(condition)) that evaluates to a <translate-path>@darwin.at-placeholder-translate-path-rule. Search for toolset.add-requirements to see examples of how it should be called.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, scratch all that.. I see now how toolset-add-requirements will not work for this.

# set up the -F option to include the paths to any frameworks used.
local rule prepare-framework-path ( target + )
{
Expand Down
3 changes: 3 additions & 0 deletions src/tools/features/translate-path-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand Down