env.Tool('CopyToDir', [ 'senfscons' ])
env.Tool('CompileCheck', [ 'senfscons' ])
env.Tool('Boost', [ 'senfscons' ])
-env.Tool('BoostUnitTests', [ 'senfscons' ])
+env.Tool('BoostUnitTest', [ 'senfscons' ])
env.Tool('InstallSubdir', [ 'senfscons' ])
env.Help("""
LIBPATH = [ '$LOCALLIBDIR' ],
LIBS = [ 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
'$BOOSTFSLIB' ],
- TEST_EXTRA_LIBS = [ ],
+ TEST_EXTRA_LIBS = [ '$LIBSENF$LIBADDSUFFIX' ],
PREFIX = '/usr/local',
LIBINSTALLDIR = '$PREFIX/lib',
import os.path
import os
-def BoostUnitTests(env, target=None, source=None, **kw):
+# ARGH ... Why do they put a '+' in the module name ????????
+SCons.Tool.cplusplus=getattr(__import__('SCons.Tool.c++', globals(), locals(), []).Tool, 'c++')
+
+def BoostUnitTest(env, target=None, source=None, **kw):
target = env.arg2nodes(target)[0]
+ source = env.arg2nodes(source)
binnode = target.dir.File('.' + target.name + '.bin')
stampnode = target.dir.File('.' + target.name + '.stamp')
'touch $TARGET' ],
**kw)
- return env.Command(env.File(target), stamp, [ 'true' ])
+ alias = env.Command(env.File(target), stamp, [ 'true' ])
+
+ compileTests = [ src for src in source
+ if src.suffix in SCons.Tool.cplusplus.CXXSuffixes \
+ and src.exists() \
+ and 'COMPILE_CHECK' in file(str(src)).read() ]
+ if compileTests:
+ env.Depends(alias, env.CompileCheck(source = compileTests))
+
+ return alias
def generate(env):
env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
- env['BUILDERS']['BoostUnitTests'] = BoostUnitTests
+ env['BUILDERS']['BoostUnitTest'] = BoostUnitTest
def exists(env):
return 1
def CompileCheck(target, source, env):
tests = scanTests(file(source[0].abspath))
cenv = env.Clone()
- cenv.Append( CPPDEFINES = { 'COMPILE_CHECK': '' } )
+ cenv.Append( CPPDEFINES = [ 'COMPILE_CHECK' ] )
out = tempfile.TemporaryFile()
cenv['SPAWN'] = lambda sh, escape, cmd, args, env, pspawn=cenv['PSPAWN'], out=out: \
pspawn(sh, escape, cmd, args, env, out, out)
return ( GlobSources(env, exclude, subdirs),
GlobIncludes(env, exclude, subdirs) )
-def LibPath(lib): return '${LOCALLIBDIR}/${LIBPREFIX}%s${LIBADDSUFFIX}${LIBSUFFIX}' % lib
-
def Test(env, sources):
- test = env.BoostUnitTests( target = 'test',
- source = sources,
- TEST_EXTRA_LIBS = [ '$LIBSENF$LIBADDSUFFIX'
- ] + env['TEST_EXTRA_LIBS'])
-
- compileTestSources = [ src for src in sources
- if 'COMPILE_CHECK' in file(src).read() ]
- if compileTestSources:
- env.Depends(test, env.CompileCheck(source = compileTestSources))
-
+ test=env.BoostUnitTest( target = 'test', source = sources )
env.Alias('all_tests', test)
-
return test
-
def Objects(env, sources, testSources = None):
if type(sources) == type(()):
testSources = sources[1]