Boost logo

Boost-Build :

From: Eric Woodruff (eric.woodruff_at_[hidden])
Date: 2008-07-23 13:13:00


Can you explain why the indirect rule is needed? I was following your
example to create a rule to invoke an ant script and this seemed to work
for me an ant.jam:

rule ant ( name : script : properties * )
{
     FLAGS on $(name) += [ compute-ant-flags $(name) : $(properties) ] ;
     generate $(name) : $(script) : $(properties)
<generating-rule>@ant.do-ant ;
}

rule do-ant ( project name : property-set : sources * )
{
     local a = [
        new non-scanning-action $(sources) : ant.invoke :
$(property-set) ] ;

     return [ new file-target $(name) : [ $(sources[1]).type ] :
$(project) : $(a) ] ;
}

actions invoke
{
         ANT_HOME="$(.ant-home-dir)"
         "$(.ant-bin)" -f $(>) $(FLAGS)
}

Jonathan Biggar wrote:
> 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.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build


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