Subject: Re: [Boost-build] Generating random number string in b2
From: Edward Diener (eldiener_at_[hidden])
Date: 2016-10-10 14:24:38
On 10/10/2016 11:38 AM, Steven Watanabe wrote:
> On 10/10/2016 09:07 AM, Edward Diener wrote:
>> Is there a way to generate a random number string in b2 ?
>> I have a rule which may be invoked more than once with the same
>> parameters from a jam file. The rule creates build targets based on the
>> parameters and I need to give each build target a unique name. Of course
>> it would be nice if the end-user invoked the rule with the same
>> parameters only once in a jamfile and saved the result in a local
>> variable but I cannot force that usage. Therefore I want to generate a
>> uniquely named build target even when the parameters to the rule are the
>> same. I am using configure.builds with the build target so as long as my
>> uniquely named build target matches what is passed to configure.builds I
>> am OK.
> The usual method is to use a counter.
> .target-id = 0 ;
> rule get-next-id ( )
> .target-id = [ CALC $(.target-id) + 1 ] ;
> return $(.target-id) ;
Thanks, Steve. Works beautifully. I had thought along these lines but
did not know when and how often a variable such as .target-id gets
initially set. I assume it gets set each time the jam file it is in gets
"loaded", but I am not sure when this happens in the Boost Build system.
> In Christ,
> Steven Watanabe
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