From: Christopher Currie (codemonkey_at_[hidden])
Date: 2004-07-08 15:49:52
I struggled with this problem for another tool, RogueWave's XML
ObjectLink, which generates multiple C++ sources from an XML schema. The
approach I took requires that you name an intermediate target, and pass
that to your library. Using your case as an example, it would look
something like this:
antlr grammar : grammar.g : lexer.cpp parser.cpp ;
lib mylib : grammar [ : etc. ... ] ;
The reason this is necessary, is because when a .cpp file is a generated
target, you can't just refer to it by name any more, because BBv2 still
tries to resolve the name using a local file, but generated files should
actually live somewhere in the bin tree. So you need the placeholder
target to act as a "source" for the library.
I posted the code I developed here:
You may be able to adapt this to your needs.
Hope this helps,
Thomas Rolfs wrote:
> 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'm using a tool called ANTLR. It's like lex and yacc in that it
> generates lexer and parser code from a grammar file:
> grammar.g ---> lexer.cpp parser.cpp
> I then try to create a rule to generate the lexer.cpp and parser.cpp:
> rule antlr ( lexer parser : grammar )
> Depends $(lexer) $(parser) : $(grammar) ;
> 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 ;
> The generated cpp files belong in a library.
> lib mylib
> : src/antlr/lexer.cpp
> : <link>static
> However, when I build the library it says:
> error: Unable to resolve target-id src/antlr/lexer.cpp
> I tried making a generator but it is not suitable for what I want. Even
> if the generator could generate two files I need the generated files to
> placed in src/antlr not in the build-dir tree.
> I'm using Boost.Build V2 (M9.1) Boost.Jam 03.01.08 on windows.
> Any pointers on how to get this to work would be greatly appreciated.
> - Tommy.
> *Yahoo! Groups Links*
> * To visit your group on the web, go to:
> * To unsubscribe from this group, send an email to:
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
-- Christopher Currie <codemonkey_at_[hidden]>
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