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.ht
ml#id2577795
HTH,
Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
a>
|