Boost logo

Boost-Build :

From: McMillan, Scott (scott.mcmillan_at_[hidden])
Date: 2007-01-09 17:56:21

I am new to Boost.Build V2 and have been struggling for a while to get
just a basic understanding I am finally making some progress in
evaluating this to replace our current Imake/make build system.


Right now I am trying to figure out how to replicate builds for CxxTest
files. The basic idea is that you define a class, e.g. FooTS, derived
from CxxTest::TestSuite. You place the declaration in FooTS.h and the
definition in FooTS.cpp. In order to build the test driver you call a
perl script to generate a FooTS_runner.cpp (our in-house convention): <options> -o FooTS_runner.cpp FooTS.h


Then FooTS_runner.cpp and FooTS.cpp get compiled in to an executable
(linking other libs).


I tried the following:


- renamed FooTS.h to FooTS_runner.cxh

- defined a new type CXXTEST_H associated with a new extension

- defined an action that invoked the script
appropriate to convert the .cxh file to a .cpp file

- registered a standard generator that calls the action to
perform the conversion.



In cxxtest.jam I have:


type.register CXXTEST_H : cxh ;

generators.register-standard cxxtest.gencxx-file : CXXTEST_H : CPP ;

action cxxgentest

{ -o $(<) $(>)



This resulted in the following in my Jamfile (after importing cxxtest)


exe FooTS_runner : FooTS.cpp FooTS_runner.cxh : /* other requirements */
... ;


Notice that I had to add the "_runner" to the cxh file so that there
would not be two FooTS.o files (one from FooTS.cpp and one from
processing FooTS.cxh and compiling the result).


It is unsatisfying to rename the header file this way because we have a
filenaming convention where the definition and declaration of the FooTS
class should be in FooTS.h and FooTS.cpp respectively.


I have two questions to hopefully improve my understanding:


1) If I wanted to continue with the .cxh approach, is writing a custom
generator the way to process FooTS.cxh into FooTS_runner.cpp. If so
could someone please help me as it is neither clear what method to
override (generate-targets?) nor how to do it to accomplish this task.


2) Ultimately I would like to get back to something closer I have with
our current Imakefile system which was to define a new rule that took
FooTS as the argument (I would settle for a rule that had to take
FooTS.h and FooTS.cpp as arguments), generates FooTS_runner.cpp from
FooTS.h and compiled and linked FooTS.cpp and FooTS_runner.cpp into an
executable called FooTS_runner.


Any help would be greatly appreciated,



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