Boost logo

Boost-Build :

From: Chris Hoeppler (hoeppler_at_[hidden])
Date: 2006-02-02 13:15:55


Hi Volodya

> > Assume, I have some source files a.src and b.src. Invoking a converter with
> > all of the source files as input (i.e. "my_converter --flags
> > -doutput_directory a.src b.src") generates header and C-files a.h, a.c, b.h
> > and b.c in output_directory. From these an exe is built.

> If that's not feasible, you can create your own target type, say
> "MY_CONVERTED_CPP", derived from CPP. Then you can define a custom generator
> for your type, and:
>
> - mark the generator as 'composing'
> - make the generator produce a pair of target for each source

Okay. I tried that, but unfortunately I don't yet understand enough of what's
going on to solve one remaining puzzle. Keeping with the names above, in my
src.jam file I have now:

import type ;
type.register SRC : src ;
type.register MY_CONVERTED_CPP : : CPP ;

actions convert {
    echo my_converter called with target: $(<) source: $(>)
}

import generators ;
import "class" : new ;

class my-src-generator : generator {

    import utility ;
    rule __init__ ( * : * )
    {
        generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) :
$(8) : $(9) ;
        self.composing = true ;
    }
    rule generated-targets ( sources + : property-set : project name ? )
    {
        # Create generated targets for source file
        local targets ;
        for local s in $(sources)
        {
            targets += [ generator.generated-targets $(sources)
                    : $(property-set) : $(project) [ utility.basename [
$(s).name ] ] ] ;
        }
        return $(targets) ;
    }
}
generators.register [ new my-src-generator src.convert : SRC :
MY_CONVERTED_CPP ] ;

> Then, Jamfile will look like:
>
> lib mylib : src.cpp ;
> exe myprog : my_processed mylib ;
> my_converted_cpp my_processed : a.src b.src ;

my-src-generator manages to register a.cpp and b.cpp as targets and both a.cpp
and b.cpp are passed as sources to my_converter, as required. However,
my_converter is called n times if there are n *.src files for my_processed.
What do I need to do so that my_converter is called only once? I.e. I'd like to
achive the following actions:

mylib is built
my_converter a.src b.src ==> gemerates targets a.cpp a.h b.cpp b.h in one step
myprog is built with mylib a.cpp b.cpp

Chris


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