427dacf9d6e4a5aa5b56ffe94a8cfcd0e5fbe808
[senf.git] / senfscons / BoostUnitTests.py
1 ## \file
2 # \brief BoostUnitTests build
3
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
6 #
7 # The BoostUnitTests builder will build a unit-test executable using
8 # the <a
9 # href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a>
10 # library. After building, the unit-test will be executed.
11 #
12 # This builder is used by the SENFSCons.Object() helper to build the
13 # unit test.
14 #
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>
19 # </table>
20 #
21 # \todo This is not really a builder. This should be rewritten as one
22 # \ingroup builder
23
24 import SCons.Script.SConscript
25 import SCons.Defaults
26 import os.path
27 import os
28
29 def BoostUnitTests(env, target=None, source=None,  **kw):
30     target = env.arg2nodes(target)[0]
31
32     binnode = target.dir.File('.' + target.name + '.bin')
33     stampnode = target.dir.File('.' + target.name + '.stamp')
34
35     bin = env.Program(binnode, source, 
36                       LIBS = env['LIBS'] + [ '$TEST_EXTRA_LIBS' ],
37                       _LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ' + env['_LIBFLAGS'],
38                       **kw)
39
40     stamp = env.Command(stampnode, bin,
41                         [ '$SOURCE $BOOSTTESTARGS',
42                           'touch $TARGET' ],
43                         **kw)
44
45     return env.Command(env.File(target), stamp, [ 'true' ])
46
47 def generate(env):
48     env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
49     env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
50     env['BUILDERS']['BoostUnitTests'] = BoostUnitTests
51
52 def exists(env):
53     return 1