Subject: Re: [Boost-build] How to use generators to CPP and LIB
From: Duncan Rance (gmane_at_[hidden])
Date: 2009-01-30 13:08:45
Alexander Sack wrote:
> On Fri, Jan 30, 2009 at 11:10 AM, Vladimir Prus <ghost_at_[hidden]> wrote:
>> On Thursday 29 January 2009 15:09:33 Duncan Rance wrote:
>>> Hi there,
>>> I am trying to do something with generators but I'm stuck. I'd really
>>> appreciate some help.
>>> What I've got so far is, in a module called resources.jam, something
>>> like this:
>>> type.register RESTXT : txt ;
>>> generators.register-standard resources.genenumh : RESTXT : H ;
>>> generators.register-standard resources.pkgdata : RESTXT : LIB ;
>>> What I need to do is use a .txt file to produce a header file and a
>>> static library. The header file is to be used in a few places,
>>> including the code used to create the LIB. But there's more to go in
>>> the LIB than just the header. If you're interested, I'm using ICU's
>>> resource bundling tools
>>> As you can probably imagine, there is an ambiguity between
>>> builtin.lib-generator and resources.pkgdata.
>>> How can I do this in boost build?
>> I don't think there's a way to resolve this ambiguity without introducing
>> custom generator class.
>> I suggest you resolve the ambiguity using generators.override, in
>> favour of your new generator. Your generator, however, should
>> check if the source type is RESTXT. If so, it should build whatever you
>> need. If the source type is different, it should call generators.construct
>> for LIB target again, so that builtin generator does his job.
>> I also recommend using some more specific extension than .txt
> After reading Volodya's email, I just realized is you are trying to
> register one generator for two types! Well one work around is the
> name the same file with two different extensions which would allow two
> different simpler generators no?
Well actually I originally had two generators, but I've been through
I'm going to have try generators.override etc. in a while, but perhaps
it might be clearer if I'm say more about what I'm doing (I've been
trying to keep it simple!)
Check out this lot:
type.register RESRBS : rbs ;
type.register RESTXT : txt ;
type.register RESOUT : res ;
type.register RESDAT : dat ;
generators.register-standard resources.gensrc : RESRBS : RESTXT ;
generators.register-standard resources.genenumh : RESTXT : H ;
generators.register-standard resources.genenumc : H : CPP ;
generators.register-standard resources.genrb : RESTXT : RESOUT ;
generators.register-composing resources.icupkg : RESOUT : RESDAT ;
generators.register-composing resources.pkgdata : RESOUT : LIB ;
I start with root.rbs. That gets converted into a txt file (in the ICU
project's resource-bundling format -- they chose txt but I guess I
could change it.)
genenumh creates a big C++ enum declaration in a header file (I want
it to be called resourcesEnum.h). genenumc creates the enum's
definition, ideally in resourcesEnum.cpp.
I've got some dat file targets that are supposed to use gensrc ->
genrb -> icupkg.
Then there is the libroot.a, which is supposed to come from gensrc ->
genrb -> pkgdata.
The ambiguity comes about because RESRBS -> RESTXT -> H -> CPP -> OBJ
-> LIB clashes with RESRBS -> RESTXT -> RESOUT -> LIB.
Hopefully this makes more sense!
I'm unsure about the file names. It tries to create a root.h &
root.cpp etc., but I don't want it to. And I've got no source at all
with resourcesEnum in the name, so perhaps I'm just doing totally the
As I say, I'll have a look at the override thing.
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