|
Boost-Build : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-02-14 03:36:39
On Tuesday 14 February 2006 01:44, Daniel Einspanjer wrote:
> I have a generator closely based upon the one Volodya described in his
> response to this thread:
> http://thread.gmane.org/gmane.comp.lib.boost.build/11654
>
> One of the things I did was make a rule with the same name as the action
> that builds up the variable XSL_TOOL which is used by the action.
>
> I discovered that I couldn't declare that variable as local in the rule
> because then the action couldn't see it. What would be the proper way to
> scope that type of variable to reduce the possibility of collisions
> anywhere else? Is it automatically scoped to the class? (I'm assuming it
> isn't because the rule and actions statements are outside the class
> definition.)
You mean you have
rule whatever ( targets * : sources * : properties * )
{
.... XSL_TOOL = ....... ;
}
actions whatever
{
$(XSL_TOOL) ......
}
Then, you can scope 'XSL_TOOL' on target, like this:
rule whatever ( targets * : sources * : properties * )
{
XSL_TOOL on $(target[1]) = ....... ;
}
This variable will be visible only inside the action. If the xsl command is
the same for all actions, it might be easier to make it a global variable:
rule init ( ............. )
{
XSL_TOOL = ........ ;
}
If you need to handle more then one version of your xsl tool, you'd need more
complex mechanism, something like:
rule init ( version : command )
{
flags your-module.whatever XSL_TOOL <xsl-tool-version>$(version)
: $(command) ;
}
- 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