|
Boost-Build : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-02-07 07:54:30
On Sunday 05 February 2006 14:31, Jaroslav Gresula wrote:
> Could someone advise me how to retrieve value of a feature within a
> rule? I followed an example from the docs which uses the toolset.flags
> rule but with no luck.
>
> Below is my attempt, but the TOOLSET variable expands to an empty string.
>
> ---
> local rule this-module-rule ( ) { return [ CALLER_MODULE ] ; }
> local this-module = [ this-module-rule ] ;
>
> import toolset ;
> toolset.flags $(this-module).print-toolset TOOLSET : <toolset> ;
>
> rule print-toolset ( )
> {
> ECHO $(TOOLSET) ;
> }
>
> alias main : : [ print-toolset ] ;
This code is executed during Jamfile parsing stage. It calls the rule
'print-toolset', that immediately executes "ECHO", but the value of
$(TOOLSET) is empty, because it's only set when bjam starts executing
actions, and only if 'print-toolset' is the updating action for some target.
Try this:
import notfile ;
import toolset ;
import feature ;
notfile test : @print-toolset ;
rule print-toolset ( targets * : sources * : properties * )
{
ECHO "Toolset = " [ feature.get-values <toolset> : $(properties) ] ;
}
Note that if you run "bjam" with two different toolsets, say:
bjam gcc intel
you'll see two "Toolset = " lines, one for each time "test" is built.
You might also want to check the newly added FAQ item:
http://boost.org/boost-build2/doc/html/bbv2/faq.html#id2577795
HTH,
Volodya
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