2 # \brief BoostUnitTests build
4 ## \package senfscons.BoostUnitTests
5 # \brief Builder utilizing the <a href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a> unit-test framework
7 # The BoostUnitTests builder will build a unit-test executable using
9 # href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a>
10 # library. After building, the unit-test will be executed.
12 # This builder is used by the SENFSCons.Object() helper to build the
15 # \par Construction Envrionment Variables:
16 # <table class="senf">
17 # <tr><td>\c BOOSTTESTLIB</td><td>Name of the library to use, defaults to \c boost_unit_test_framework</td></tr>
18 # <tr><td>\c BOOSTTESTARGS</td><td>Command line arguments of the test, defaults to <tt>--build_info=yes --log_level=test_suite</tt></td></tr>
21 # \todo This is not really a builder. This should be rewritten as one
24 import SCons.Script.SConscript
29 # ARGH ... Why do they put a '+' in the module name ????????
30 SCons.Tool.cplusplus=getattr(__import__('SCons.Tool.c++', globals(), locals(), []).Tool, 'c++')
32 def BoostUnitTest(env, target=None, source=None, **kw):
33 target = env.arg2nodes(target)[0]
34 source = env.arg2nodes(source)
36 binnode = target.dir.File('.' + target.name + '.bin')
37 stampnode = target.dir.File('.' + target.name + '.stamp')
39 bin = env.Program(binnode, source,
40 LIBS = env['LIBS'] + [ '$TEST_EXTRA_LIBS' ],
41 _LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ' + env['_LIBFLAGS'],
44 stamp = env.Command(stampnode, bin,
45 [ '$SOURCE $BOOSTTESTARGS',
49 alias = env.Command(env.File(target), stamp, [ 'true' ])
51 compileTests = [ src for src in source
52 if src.suffix in SCons.Tool.cplusplus.CXXSuffixes \
54 and 'COMPILE_CHECK' in file(str(src)).read() ]
56 env.Depends(alias, env.CompileCheck(source = compileTests))
61 env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
62 env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
63 env['BUILDERS']['BoostUnitTest'] = BoostUnitTest