|
Boost-Build : |
From: Mark Evans (evans_mark_at_[hidden])
Date: 2006-02-14 23:30:05
Experts - I figured out "a way" to do what I want. I couldn't figure out in how to get a handle on the target corresponding to the sources passed to generated-targets. So I gave up on doing DEPENDS inside of generated-targets and just pass the sources list unchanged to unix-linking-generator.generated-targets. Later in the link actions rule, I discriminate the include-whole archive sources based on the presence of <include-library-whole> or whatever I called it entries in the properties list.
Thus I end up with a command line like:
link -include_whole path/libfoo.a ...
instead of
link -include_whole path/libfoo.a path/libfoo.a ...
FWIW - the generated-targets code now looks as follows:
class hptns-linking-generator : unix-linking-generator
{
# Provides special handling for <hptns-include-whole> archives
rule generated-targets ( sources + : property-set : project name ? )
{
local properties2 = [ $(property-set).raw ] ;
for local s in $(sources)
{
if [ type.is-derived [ $(s).type ] STATIC_LIB ]
{
local a = [ $(s).action ] ;
local ps ;
local psraw ;
if $(a)
{
ps = [ $(a).properties ] ;
if $(ps)
{
psraw = [ $(ps).raw ] ;
}
}
if <hptns-include-whole>yes in $(psraw)
{
local actual-name = [ $(s).actual-name ] ; # Gristed name
properties2 += <hptns-include-whole-arch>$(actual-name) ;
}
}
}
local spawn = [ unix-linking-generator.generated-targets $(sources)
: [ property-set.create $(properties2) ] : $(project) $(name) ] ;
return $(spawn) ;
}
}
# Helper rule for rule link is where I remove include-whole archives
# from normal library list.
rule handle-libraries ( targets * : sources * : properties * )
{
local sources2 ;
local whole-archs ;
for local p in $(properties)
{
if $(p:G) = <hptns-include-whole-arch>
{
whole-archs += $(p:G=) ;
}
}
for local s in $(sources)
{
local suffix = $(s:S) ;
# Discriminate LIB types from OBJ types via well-known suffixes (Ugh)
if $(suffix) = .so || $(suffix) = .srl || $(suffix) = .a
{
if ! $(s) in $(whole-archs)
{
LIBS on $(targets) += $(s) ;
}
# else omit $(s) from LIBS list - the archive will get
# included via flags binding for <hptns-include-whole-arch>
}
else
{
sources2 += $(s) ;
}
}
OBJS on $(targets) += $(sources2) ;
}
FWIW (2c) - Mark
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