Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-11-12 01:22:42

David Abrahams wrote:
> I don't understand what's going on here, even with the comment:
> # Each element should have the form
> # type["(" name-pattern ")"]
> # for example, obj(%_x). Name of generated target will be found
> # by replacing % with the name of source, provided explicit name
> # was not specified.
> ...
> for local e in $(target-types-and-names)
> {
> local m = [ MATCH ([^\\(]*)(\\((.*)%(.*)\\))? : $(e) ] ;
> += $(m[1]) ;
>$(m[1]) = $(m[3]) $(m[4]) ;
> }

The situation is this. Generator takes a list of sources. It can also
optionally given the name for generated target. If the name is specified,
then names of sources are just ignored. For example, this happens for linking.
The name is actually *basename*, without suffix. So, if a name is specified and
two targets are produced, they'll have the same basename, but different suffixes.
For example, link generator for borland might be passed name "hello". It will
created two targets "hello.exe" and "hello.tds".

In other case, you should somehow guess the basename for generated targets.
For this, I require that all sources have the same name. (Most of the time,
multiple sources occur for generators like link, where explicit name is already

First version was taking name of sources as basename for generated targets.
I.e. gcc.compile, when taking a.cpp returns a.o. However, this is not enough.
In my example, asm.wd must be converted in asm_parser.whl and asm_lexer.dlp.
Name pattern is a was to achive that. Here's what I have for wd/whl/dlp:

generators.register-standard whale.wd : WD : WHL(%_parser) DLP(%_lexer) ;

The generator first finds basenames for sources, for example "asm". It then
notices that both generated targets have name patterns, and generates basenames
by replacing % in patterns with source basename. It given asm_parser and asm_lexer.
Suffixes for those targets are determined from their types, which gives
asm_parser.whl and asm_lexer.dlp.

> What if there are multiple sources? Is the purpose of this to allow
> make-style rules which do %.o <- %.c ? If so, why doesn't the comment
> say "obj(%.o)"?

Mmm.. no. Make-style rules are implicit: they match every request to
build *.o. The purpose of name patterns is to allow basenames of generated
targets to be different from basename of source.

Have I explained this satisfactory?

- Volodya


Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at