Boost logo

Boost-Build :

From: Jonathan Biggar (jon_at_[hidden])
Date: 2008-07-19 21:08:12


Jurko Gospodnetić wrote:
> Hi Jonathan.
>
>> The generate main target currently only works if you pass it a
>> <generating-rule> using the '@' construction. If you don't, it
>> silently just doesn't do anything.
>>
>> Here's a patch that cleans this up so that it properly gives an error
>> if it can't run the <generating-rule>, and also just tries to call the
>> rule via indirect.call if no '@' prefix is found, which allows people
>> to write wrapper rules that use generate.
>
> Thanks for the patch.
>
> I'll look at it but one thing I do not understand is what you mean by
> 'which allows people to write weapper rules that use generate'.

The idea was to be able to write a rule 'foo' in foo.jam file that uses
generate internally with the generating rule also declared in foo.jam.
The problem is that foo.jam isn't a project, so it can't use the '@'
syntax to specify a rule.

I've attached an example tarball that demonstrates what the patch allows
me to do. It defines cat.jam, which allows the user to create a rule
that catenates multiple files into a target. Without the patch to
generate.jam, the user would have to write this by hand.

I've also attached a new patch for generate.jam that fixes a typo in my
previous patch.

> So far when Boost Build wants to take a 'pointer to a rule' argument
> it consistently requires that you prefix the rule name with a @
> character. Why would this place be special and allow the user to skip
> the @ character?

Because the @ requires a project context, which isn't available if you
want to wrap generate in a .jam file.

> Also, Boost Build depends on such 'indirect' feature
> values begining with @ to do some processing on them in the
> property.translate-indirect to make sure those rules are processed in
> the context of the correct module.

Yes, translate-indirect recognizes '@' and translates it into an
indirect call. So there's no problem if the call is already indirect,
since it will call the correct rule anyway.

-- 
Jon Biggar
Floorboard Software
jon_at_[hidden]
jon_at_[hidden]

==== //depot/orb_main/corba/tools/build/v2/tools/generate.jam#1 - /home/corvette/jon/work/corba/tools/build/v2/tools/generate.jam ====
@@ -44,24 +44,35 @@
         local result ;
         local gr = [ $(property-set).get <generating-rule> ] ;
 
- # FIXME: this is copy-paste from virtual-target.jam. Must
- # have n utilty rule to call a rule like this.
- local rule-name = [ MATCH ^@(.*) : $(gr) ] ;
- if $(rule-name)
+ if ($gr)
         {
- if $(tag[2])
+ # FIXME: this is copy-paste from virtual-target.jam. Must
+ # have n utilty rule to call a rule like this.
+ local rule-name = [ MATCH ^@(.*) : $(gr) ] ;
+ if $(rule-name)
+ {
+ if $(gr[2])
+ {
+ errors.error "<generating-rule>@rulename is present but is not the only <generating-rule> feature" ;
+ }
+
+ result = [ indirect.call $(rule-name) $(self.project) $(name)
+ : $(property-set) : $(sources) ] ;
+ }
+ else
             {
- errors.error "<tag>@rulename is present but is not the only <tag> feature" ;
+ result = [ indirect.call $(gr) $(self.project) $(name) : $(property-set) : $(sources) ] ;
             }
 
- result = [ indirect.call $(rule-name) $(self.project) $(name)
- : $(property-set) : $(sources) ] ;
-
             if ! $(result)
             {
                 ECHO "warning: Unable to construct" [ full-name ] ;
             }
         }
+ else
+ {
+ errors.error "no <generating-rule> specified" ;
+ }
 
         local ur ;
         local targets ;



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