Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-12-26 17:43:04


On Monday 11 December 2006 20:32, Phillip Seaver wrote:

[personal cc for convenience, please reply to list]

> I'd like to make a target that would work something like this:
>
> endian foo : <endian-little>IS_LITTLE_ENDIAN <endian-bin>IS_BIG_ENDIAN ;
>
>
> It would generate a header file that would be like this:
>
> #ifndef _BJAM_FOO_CONFIG_H_
> #define _BJAM_FOO_CONFIG_H_
> #ifdef __APPLE__
> # ifdef __BIG_ENDIAN__
> # define IS_BIG_ENDIAN 1
> # elif defined(__LITTLE_ENDIAN__)
> # define IS_LITTLE_ENDIAN 1
> # endif
> #endif
> #endif /* _BJAM_FOO_CONFIG_H_ */
>
>
> The target would have <dependency>bjam_foo_config.h,
> <implicit-dependency>bjam_foo_config.h, and
> <forced-include>bjam_foo_config.h in its usage requirements so that a
> target that put it in its sources would build it and include it while
> compiling source files.

I suspect that you don't need both <dependency> and <implicit-dependency>.
The former unconditionally sets up a dependency, so the latter does not
adds anything.

> The <forced-include> would translate to the -include option for gcc and
> the -FI option for msvc, both of which make the compiler act is if the
> header file were included on the first line of each file compiled.

Did you implement such feature?

> It also helps with my goal of modifying third-party library
> distributions as little as possible. :-)
>
> I've been looking through some of the other .jam files in the tools
> directory to see if I can find what I need, but I'm not sure what to
> override in a new target, how to get the output filename for use in the
> usage requirements, where to determine the usage requirements, etc.
>
> If someone could give me some pointers, I'd really appreciate it.

Start with example/generator. Make the 'run' method just call the base method
and return the result.

After that, modify the method so that it:

        1. Takes first element returned by the base method -- which should be a target.
        2. Creates a property-set with

                        <dependency> $(that-target-returned-by-base-rule)

        3. Return

                $(property-set-created-in-2) $(targets-returned-in-the-base-method)

Once you implement <force-include> -- which should be a dependency feature,
and the extender manual describes how to add those -- you should also
create <force-include> in (2).

To clarify, if the first element in the return value of then run method is a property-set,
it is taken to contain extra usage requirements this generator wants to return
to dependents.

Hope this help. Ask if something is not clear.

- Volodya


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