|
Boost-Build : |
Subject: [Boost-build] Programmatically setting multiple requirements
From: Anthony Foglia (AFoglia_at_[hidden])
Date: 2010-05-18 18:57:16
I have another question about creating static libraries linking to
dynamically to system-wide libraries. In this case, we have three
variants, in two of which, we want to link to third-party libraries
dynamically, and in the third, we want to link statically.
Because of the problem Gevorg Voskanyan outlined in this post
<http://old.nabble.com/Handling-of-conflict-between-target's-requirements-and-its-dependencies'-usage-requirements-td28567264.html>,
these need to be set up in the rules for each library that refers to the
system file.
The rule for the system-wide library is in a file called sysdef.jam,
defined as such:
lib rogue-wave-math #FOR: RW Math library
: rogue-wave-linear-alg
rogue-wave-lapack
: <name>mth69 <search>$(rogue-wave-base)/lib
<dll-path>$(rogue-wave-base)/lib
<tag>@tag_rw
:
: <include>$(rogue-wave-base)
;
(And similar rules for rogue-wave-linear-alg and rogue-wave-lapack.)
Our current rule for the library:
lib Math
: [ glob src/*.cpp ]
/sysdefs//rogue-wave-math
: <include>./include
<link>static
:
: <include>./include
;
which links (only statically).
The obvious solution is to make the /sysdefs//rogue-wave-math dependency
conditional like so:
lib ASAMath
: [ glob src/*.cpp ]
: <include>./include
<link>static
<variant>debug:<library>/sysdefs//rogue-wave-math/<link>shared
<variant>release:<library>/sysdefs//rogue-wave-math/<link>shared
<variant>production:<library>/sysdefs//rogue-wave-math/<link>static
:
: <include>./include
;
This works, but we use these libraries in more than one place, and the
simpler I can make this more likely other people will follow this
convention. So I thought I could make a rule :
rule variant-link-rule ( library )
{
local result = "" ;
result += <variant>debug:<library>$(library)/<link>shared ;
result += <variant>release:<library>$(library)/<link>shared ;
result += <variant>production:<library>$(library)/<link>static ;
ECHO "Variant link rule: $(library) -->" ;
ECHO $(result) ;
return "" $(result) ;
}
lib ASAMath
: [ glob src/*.cpp ]
: <include>./include
<link>static
[ variant-link-rule /sysdefs//rogue-wave-math ]
:
: <include>./include
;
This is fails with the error:
$ bjam release -a -d+2
Variant link rule: /sysdefs//rogue-wave-math -->
<variant>debug:<library>/sysdefs//rogue-wave-math/<link>shared
<variant>release:<library>/sysdefs//rogue-wave-math/<link>shared
<variant>production:<library>/sysdefs//rogue-wave-math/<link>static
/usr/share/boost-build/build/property.jam:320: in property.make from
module property
error: '' is not a valid for property specification
/usr/share/boost-build/build/property-set.jam:390: in
property-set.create-from-user-input from module property-set
/usr/share/boost-build/build/property-set.jam:446: in
property-set.refine-from-user-input from module property-set
/usr/share/boost-build/build/targets.jam:1477: in
targets.main-target-requirements from module targets
/usr/share/boost-build/tools/builtin.jam:532: in lib from module builtin
../../../lib/math/Jamfile:41: in modules.load from module
Jamfile</home/AFoglia/projects/asa/trunk/lib/math>
/usr/share/boost-build/build/project.jam:312: in load-jamfile from
module project
/usr/share/boost-build/build/project.jam:68: in project.load from module
project
/usr/share/boost-build/build/project.jam:718: in project.use from module
project
/usr/share/boost-build/build/project.jam:94: in load-used-projects from
module project
/usr/share/boost-build/build/project.jam:79: in load from module project
/usr/share/boost-build/build/project.jam:120: in load-parent from module
project
/usr/share/boost-build/build/project.jam:447: in initialize from module
project
/usr/share/boost-build/build/project.jam:301: in load-jamfile from
module project
/usr/share/boost-build/build/project.jam:68: in load from module project
/usr/share/boost-build/build/project.jam:170: in project.find from
module project
/usr/share/boost-build/build-system.jam:248: in load from module
build-system
/usr/share/boost-build/kernel/modules.jam:261: in import from module modules
/usr/share/boost-build/kernel/bootstrap.jam:132: in boost-build from module
/home/AFoglia/projects/asa/trunk/boost-build.jam:7: in module scope from
module
What am I doing wrong? Or is what I'm trying not possible?
-- Anthony Foglia Princeton Consultants (609) 987-8787 x233
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