From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-07-08 02:51:41
> I'm having a hard time trying to do a very simple build rule. I've been
> evaluating boost.jam for a few days now and like it a lot. However,
> documentation and examples are very terse and I haven't found any explicit
> examples of what I'm trying to do.
I'd suggest that you always start with a generator when you need a new tool,
like described in
> I then try to create a rule to generate the lexer.cpp and parser.cpp:
> rule antlr ( lexer parser : grammar )
> Depends $(lexer) $(parser) : $(grammar) ;
It looks like you come with Classic Jam background, no? In V2, user never has
to write explicit Depends.
> actions antlr
> java -cp antlr/antlr-2.7.3/antlr.jar antlr.Tool -o src/antlr $(<)
> # apply the antlr rule to lexer.cpp and parser.cpp
> antlr src/antlr/lexer.cpp src/antlr/parser.cpp : antlr/csl.g ;
Here's the problem. This invocation creates Jam target called src/antlr
> The generated cpp files belong in a library.
> lib mylib
> : src/antlr/lexer.cpp
But this creates Boost.Build target "mylib". To clarify things, I might even
say "Boost.Build metatarget", because depending on build properties,
different Jam targets will be created. The sources should also be Boost.Build
targets, but you try to pass ordinary Jam target as source, and that does not
> I tried making a generator but it is not suitable for what I want. Even if
> the generator could generate two files
It sure can:
: VERBATIM : CPP(%_parser) CPP(%_lexer) ;
> I need the generated files to placed
> in src/antlr not in the build-dir tree.
Why is it needed for you? If you place then to build-dir, Boost.Build will
have no problems picking them up. Even if you really need to place them
elsewhere, we can arrange this using generators.
To help you get started with generators, I attach a toolset file for Whale, a
parser generator that I use. Hope this helps.
--Boundary-00=_N0P7A48dKTa1oUy Content-Type: text/plain;
# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears in
# all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
# Support for Whale/Dolphin/WD parser/lexer tools.
import type ;
import generators ;
import path ;
rule init ( path # path the Whale/Dolphin/WD binaries
errors.error "Attempt to reconfigure Whale support" ;
.configured = true ;
.whale = [ path.join $(path) whale ] ;
.dolphin = [ path.join $(path) dolphin ] ;
.wd = [ path.join $(path) wd ] ;
type.register WHL : whl ;
type.register DLP : dlp ;
type.register WHL_LR0 : lr0 ;
type.register WD : wd ;
generators.register-standard whale.whale : WHL : CPP H H(%_symbols) WHL_LR0 ;
generators.register-standard whale.dolphin : DLP : CPP H ;
generators.register-standard whale.wd : WD : WHL(%_parser) DLP(%_lexer) ;
rule whale ( targets * : sources * : properties * )
$(.whale) -d $(<:D) $(>)
rule dolphin ( targets * : source * : properties * )
$(.dolphin) -d $(<:D) $(>)
rule wd ( targets * : source * : properties * )
$(.wd) -d $(<:D) -g $(>)
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