Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-07-25 02:39:57


On Monday 24 July 2006 14:30, Klaus Nowikow wrote:

> type.register RCTPL : rc_t ;
> type.register CPPTPL : cpp_t ;
>
> generators.register-standard template.rc : RCTPL : RC ;
> generators.register-standard template.cpp : CPPTPL : CPP ;
...
> rule template.rc ( target : sources * : properties * )
> {
> process-template $(target) : $(sources[1]) ;
> }
>
> rule template.cpp ( target : sources * : properties * )
> {
> process-template $(target) : $(sources[1]) ;
> }
>
> actions process-template
> {
> python template.py -i$(>:W) -o$(<:W) -I"$(INCLUDES:W)"
> "$(SUBSTITUTES)" }
> </code>
>
......
> I searched through the sources a bit and found that "rule register" in
> generators.jam adds the new generator to a list of generators for the
> respective target types ( <code>
> for local t in [ sequence.unique [ $(g).target-types ] ]
> {
> .generators.$(t) += $(g) ;
> }
> </code>), which is then used to determine the correct generator for a given
> source/target type pair. And this implies that the source/target type pair
> must be known when register is called.
> So I don't think that would be easily doable. Or is it?

Hi Klaus,
it is right that each instance of 'generator' class (or a derived type), has a
certain set of target type, and that set is queried in the code above.
On the other hand, that's generator instance, and it's possible to make two
generator instances use one 'action'. Something like that should work:

  generators.register-standard template.process-template : RCTPL : RC ;
  generators.register-standard template.process-template : CPPTPL : CPP ;

 actions process-template
 {
      python template.py -i$(>:W) -o$(<:W) -I"$(INCLUDES:W)"
      "$(SUBSTITUTES)"
 }

I have not tested this, so report any issues you run into.

- Volodya

-- 
Vladimir Prus
http://vladimir_prus.blogspot.com
Boost.Build V2: http://boost.org/boost-build2

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