|
Boost-Build : |
Subject: Re: [Boost-build] generating a header file
From: Marek Balint (marek_at_[hidden])
Date: 2010-10-25 10:51:30
Vladimir Prus <ghost <at> cs.msu.su> writes:
>
> On Monday, October 18, 2010 18:19:50 Jonathan Brannan wrote:
>
> Hi Jonathan,
>
> > I'm trying to get a rule to generate header files with ruby code.
> > Optimally I'd like to be able to generate a header and/or a cpp, but for
> > now a header will be fine. Generation of just a cpp worked as explained
> > in the documentation, however I was unable to get the the action rule for
> > the header file to be called:
> >
> > I was attempting something like:
> > import type ;
> > type.register RBHPP : rbhpp ;
> > actions make-header
> > {
> > ...
> > }
> >
> > generators.register-standard rbconvert.make-header : RBHPP : HPP ;
>
> Good so far -- you've told Boost.Build that whenever it wants to create HPP
> from RBHPP, it can use the 'make-header' action.
>
> >
> > Then I have a
> > obj Foo.o : Foo.cpp : <dependency>Foo.rbhpp ;
>
> This tells that Foo.o depends on file Foo.rbhpp, however,
> nothing above tells Boost.Build that file Foo.hpp should
> be produced.
>
> > If i touch Foo.rbhpp, it will rebuild Foo.cpp. However it will never try
> > and and execute the actions.
> >
> > If is replace s/hpp/cpp. It works as expected (putting Foo.rbcpp in the
> > sources location).
> >
> >
> > Do I need to use a more advanced generator class to make the actions to
> > execute?
>
> Just:
>
> hpp Foo : Foo.rphpp ;
>
> should do the trick. Or, you can put both Foo.cpp and Foo.rbhpp in the
> sources of whatever metarget uses them now.
>
> HTH,
>
Hello,
I have a similar problem, which is not solved by this suggestion. My example
toy-project consists of only one directory, which contains these files:
main.cxx
hello1.hxx_t
hello1.ddl
hello1.cxx_t
hello2.hxx_t
hello2.ddl
hello2.cxx_t
It is no problem to create own generator, which will automatically produce CPP
files (*.cxx) from CXX_TEMPLATE files (*.cxx_t). The compilation will end up
with compiler error, though, because it will not be able to locate non-existent
files hello1.hxx and hello2.hxx. These files need to be also automatically
generated (hello1.hxx_t and hello1.ddl will produce hello1.hxx; hello2.hxx is
produced in the same way).
The question is, whether it is possible to make Boost.Build automatically detect
need for generating these files (I was looking into c-scanner inside
builtin.jam, but I am not very familiar with Boost.Jam language) and generate
them in similar way as it is done with CXX_TEMPLATE -> CPP transformation (this
one will be more complex as it needs to combine two files into one:
DDL,HXX_TEMPLATE -> HPP). It should be also noted that explicitely stating all
HXX_TEMPLATE/DDL files in target dependencies is not feasible (there are several
directories, containing hundreds of such files and very complex #include tree,
in my real project) and therefore build system must figure it out on its own,
based on #include hierarchy traversed in scanner.
Is it possible to do something like this? Thanks for an answer.
.mq.
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