Boost logo

Boost-Build :

Subject: Re: [Boost-build] Generator woes
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-07-30 00:16:48


AMDG

On 07/29/2013 11:57 AM, Nogradi, Chris wrote:
> Hello I am having a difficult time making my 1st custom generator and was hoping someone more experienced would be able to guide me. I am currently using a standard generator to produce a C and an H file from a PREPROCESSED_C file:
>
> type.register MOCK_C : : C ;
> type.register MOCK_H : : H ;
>
> generators.register-standard mock.generate : PREPROCESSED_C : MOCK_C(mock_%) MOCK_H(mock_%) ;
>
> This generator is often invoked like this:
>
> mock-c mock : file1.c ;
> exe test : mock ;
>
> which correctly compiles and links the C file and ignores the H file. The H file is used elsewhere using <implicit-dependency>mock.
>
> Now I want to also add support for producing this set of C and H files from a set of H files. The chain needs to look something like this: h files -> c file -> preprocessed c file -> mock_c and mock_h. If I do this:
>
> generators.register-standard mock.generate_c : H : C ;
>
> Then rather than ignoring the produced MOCK_H file, in the exe target above, it tries to make a C file from it and then link it in also. This is not desired.
>
> So I am trying to do something like this:
>
> type.register HLIST_C ;
> generators.register-standard mock.generate_hlist : H : HLIST_C ;
>
> and then the chain looks like this: h files -> HLIST_C file -> preprocessed c file -> mock_c and mock_h but I cannot figure out how to coerce the HLIST_C file to be passed as input to the preprocessed_c generator without inheriting the C base file type. I tried creating a custom generator that would go from a set of H files to a PREPROCESSED_C file but still could not figure out how to convert an HLIST_C target to be a C target that could be consumed by a PREPROCESSED_C generator. I tried clone-with-different-type() but this caused duplicate targets.
>
> Any help with this is much appreciated.
>

You could try using register-composing instead of register-standard.
Composing generators can take multiple sources and can only be
run at the top level. The fact that they only run at the top
level should prevent it from being used when you don't want it.
You'll want to create an HLIST_C type that derives from C for
this to work. The result will look like this:

mock-c mock : [ hlist-c file1.h ] ;

If you want this to be

mock-c mock : file1.h ;

then you'll need to create a second generator that
just uses generators.construct-types to build the
whole chain explicitly.

In Christ,
Steven Watanabe


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