Boost logo

Boost-Build :

From: McMillan, Scott (scott.mcmillan_at_[hidden])
Date: 2007-01-24 11:13:06


All:

 

I have been banging my head against Boost Build V2 to do a seemingly
simple task (at least in the Make world it was).

 

Some background on CxxTest unit test framework:

 

In CxxTest you subclass from CxxTest base class to define a test suite
class (e.g., call it FooTS) and you preprocess the header file (FooTS.h)
using the cxxtestgen.pl Perl script to generate a C++ source file with
main() defined that will run the test (lets call this runner.cpp). You
then compile and link FooTS.cpp and runner.cpp into a runner executable.

 

If you have more than one test suite class (e.g. FooTS and BarTS) you
may want to create a single runner that runs both suites so you have to
pass FooTS.h and BarTS.h as inputs to a single invocation of
cxxtestgen.pl to generate a single runner.cpp. Then you compile and
link FooTS.cpp, BarTS.cpp, and runner.cpp into a runner executable.

 

I've tried to use generators (with minimal success if I am willing to
rename my header files and limit myself to a single test suite), custom
generators (no success), even brute force use of the "make" rule did not
work. Now I am trying to create a new main target rule with no success
and some guidance would be greatly appreciated because there seems to be
some fundamental concepts about Boost.build that I don't understand.

 

In Jam-speak I would like at least to be able to say the following in my
Jamfile and have it do the right thing:

 

cxxtest-exe runner : FooTS.h BarTS.h : FooTS.cpp BarTS.cpp <other
sources> ;

 

 

So I have created an action that calls the perl script and am trying to
write the cxxtest-exe rule to wrap the exe rule as follows:

 

# Creates a cpp source file by processing a bunch of C++ header files

actions gen-cxxtest-runner-cpp

{

   cxxtestgen.pl -o $(<) $(>)

}

 

rule cxxtest-exe ( target-name :

                   cxxtest-headers + :

                   sources + :

                   requirements * :

                   default-build * :

                   usage-requirements * )

{

   # I have tried invoking the implicit gen-cxxtest-runner-cpp rule here
as well

 

   exe $(target-name) :

       $(sources) [ gen-cxxtest-runner-cpp $(target-name).cpp :
$(cxxtest-headers) ]:

       $(requirements) :

       $(default-build) :

       $(usage-requirements) ;

}

   

I have tried MANY variations on this theme but I encounter many
different problems:

 

- I can't seem to get the rule to understand that runner.cpp will
be generated by the action

- in many cases I can't get the runner.cpp to be created in the
correct bin/... subdirectory (this point is important since we do
simultaneous cross-platform builds and each must generate its own
runner.cpp).

- I have tried to write a gen-cxxtest-runner-cpp RULE to help
without success.

 

I think my problem is that I don't know how to tell the build system
that I need to generate a CPP type target with a specific name from the
cxxtest headers. I have been reading all of the documentation I can
find, and reading through the last 6 months of posting, but there seems
to be fundamental concepts I am just not able to grasp. I would be
grateful if someone would help not only with this specific problem but
also by explaining how the solution works.

 

Thanks in advance for your help,

scott

 



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