From: David Abrahams (dave_at_[hidden])
Date: 2002-11-12 10:26:49
Vladimir Prus <ghost_at_[hidden]> writes:
> 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) ] ;
>> self.target-types += $(m) ;
>> self.name-pre-post.$(m) = $(m) $(m) ;
> 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".
I understand how that case works.
> In other case, you should somehow guess the basename for generated
It's this case for which I'd like an example.
> For this, I require that all sources have the same name.
Do you mean that there must be only one source file? Otherwise, how
can they all have the same name? They're in different directories?
> (Most of the time, multiple sources occur for generators like link,
> where explicit name is already present).
I'm already familiar with athat case.
> 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.
OK, I understand what it's doing now.
I guess I'd rather do name generation with an overridable method in
the generator; this strikes me as a feature many generators won't
use. However, I could be wrong about that.
>> 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?
Yes, but you need to leave comments in the source so that next time
I'm confused about this I'll know where to find answers.
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
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