Boost logo

Boost-Build :

From: McMillan, Scott (scott.mcmillan_at_[hidden])
Date: 2007-01-26 10:49:10


> But when I try to put this into a cxxtest.jam file in the Boost.build
> tools directory and import it into the Jamfile things stop working.
It
> complains that it does not know what the run-cxxtest rule is.
>
> 1) Could someone please clarify the steps needed to turn this into a
> tool I can import into any Jamfile (note that I did include an empty
> init rule but that did not help)? The documentation in this area
would
> be greatly improved with some concrete examples.

I have solved this first problem by including an IMPORT line. Here's
the entire contents of my cxxtest.jam (critiques welcome, and there may
be typos as I had to fat-finger this in):

rule init ( ) { }

import testing ;

#----------------------------------------------
# Empty rule needed to get 'make' to work
rule gen-cxxtest-runner ( target : sources + : properties * )
{
}

#----------------------------------------------
# Takes a set of one or more cxxtest header files as $(>)
# and creates a C++ source file in $(<)
#
# Still need to provide a way for user to specify the
# desired flags
#
actions gen-cxxtest-runner
{
   cxxtestgen.pl --abort-on-fail --have-eh --have-std --error-printer -o
$(<) $(>)
}

#----------------------------------------------
# Create a test executable but don't run it
#
rule cxxtest-exe ( target-name :
                   cxxtest-headers + :
                   sources * :
                   requirements * :
                   default-build * :
                   usage-requirements * )
{
   exe $(target-name) :
       $(sources) $(target-name)_runner.cpp :
       $(requirements) : $(default-build) : $(usage-requirements) ;

   make $(target-name)_runner.cpp : $(cxxtest-headers) :
gen-cxxtest-runner ;
}

#----------------------------------------------
rule run-cxxtest ( target-name :
                   cxxtest-headers + :
                   sources * :
                   requirements * :
                   #default-build * :
                   #usage-requirements *
                  )
{
   make $(target-name)_runner.cpp : $(cxxtest-headers) :
gen-cxxtest-runner ;

   unit-test $(target-name) :
             $(target-name)_runner.cpp $(sources) :
             $(requirements) ;
}

#----------------------------------------------
IMPORT $(__name__) : cxxtest-exe run-cxxtest gen-cxxtest-runner
  : : cxxtest-exe run-cxxtest gen-cxxtest-runner ;


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