From: g0dil Date: Thu, 20 Aug 2009 08:27:51 +0000 (+0000) Subject: Call CompileCheck builder from BoostUnitTest X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=2c5ee014ddfed45406e238029600346c99870229;p=senf.git Call CompileCheck builder from BoostUnitTest Fix CompileCheck failure git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1311 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConstruct b/SConstruct index c8e0d45..ebb1fab 100644 --- a/SConstruct +++ b/SConstruct @@ -17,7 +17,7 @@ env.Tool('PkgDraw', [ 'senfscons' ]) 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(""" @@ -53,7 +53,7 @@ env.Append( LIBPATH = [ '$LOCALLIBDIR' ], LIBS = [ 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB', '$BOOSTFSLIB' ], - TEST_EXTRA_LIBS = [ ], + TEST_EXTRA_LIBS = [ '$LIBSENF$LIBADDSUFFIX' ], PREFIX = '/usr/local', LIBINSTALLDIR = '$PREFIX/lib', diff --git a/senfscons/BoostUnitTests.py b/senfscons/BoostUnitTest.py similarity index 70% rename from senfscons/BoostUnitTests.py rename to senfscons/BoostUnitTest.py index 427dacf..2984fbe 100644 --- a/senfscons/BoostUnitTests.py +++ b/senfscons/BoostUnitTest.py @@ -26,8 +26,12 @@ import SCons.Defaults 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') @@ -42,12 +46,21 @@ def BoostUnitTests(env, target=None, source=None, **kw): '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 diff --git a/senfscons/CompileCheck.py b/senfscons/CompileCheck.py index 95358a1..5972bdf 100644 --- a/senfscons/CompileCheck.py +++ b/senfscons/CompileCheck.py @@ -19,7 +19,7 @@ def scanTests(f): 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) diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index 97d5c35..e385a94 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -28,24 +28,11 @@ def Glob(env, exclude=[], subdirs=[]): 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]