X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=site_scons%2Fsite_tools%2FBoost.py;h=7e20e2bbc1ce7a31d1763af0848d3ccaee91ddc5;hb=566fb4271b2aff5aa07943707f770b2a84c2738b;hp=2f12041b58515933b032781440f557a49466f211;hpb=41ac85f6c8a96bdefebdbee4e88193d7f23f50cf;p=senf.git diff --git a/site_scons/site_tools/Boost.py b/site_scons/site_tools/Boost.py index 2f12041..7e20e2b 100644 --- a/site_scons/site_tools/Boost.py +++ b/site_scons/site_tools/Boost.py @@ -51,7 +51,7 @@ def CompileCheck(target, source, env): print "Passed test '%s': %s" % (delay_name, message) delay_name = None continue - + filename = os.path.abspath(filename) if filename != source[0].abspath : continue @@ -87,7 +87,7 @@ def BoostUnitTest(env, target=None, source=None, **kw): binnode = target.dir.File('.' + target.name + '.bin') stampnode = target.dir.File('.' + target.name + '.stamp') - bin = env.Program(binnode, source, + bin = env.Program(binnode, source, LIBS = env['LIBS'] + [ '$TEST_EXTRA_LIBS' ], _LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ' + env['_LIBFLAGS'], **kw) @@ -98,7 +98,7 @@ def BoostUnitTest(env, target=None, source=None, **kw): alias = env.Command(env.File(target), stamp, [ env.NopAction() ] ) - compileTests = [ src for src in source + 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() ] @@ -106,7 +106,7 @@ def BoostUnitTest(env, target=None, source=None, **kw): env.Depends(alias, env.CompileCheck(source = compileTests)) _ALL_TESTS.append(alias) - + return alias def FindAllBoostUnitTests(env, target, source): @@ -121,20 +121,54 @@ def NopAction(env, target, source): ConfTest = CustomTests.ConfTest() @ConfTest -def CheckBoostVersion(context): - context.Message( "Checking boost version... " ) - ret = context.TryRun("#include \n" - "#include \n" - "int main(int, char **) { std::cout << BOOST_LIB_VERSION << std::endl; }", - ".cc")[-1].strip() +def CheckBoostVersion(context,fail=False,min=None,max=None): + """Check for boost includes. + +Will place the boost version number (BOOST_LIB_VERSION) into the +BOOST_VERSION environment variable. + +Options: + + min/max compare boost version against given range. + + fail if fail is set to True, the build will be terminated, + when no valid boost includes are found.""" + if min and max: + msg = ' in range %s to %s' % (min,max) + elif min: + msg = ' at least %s' % min + elif max: + msg = ' at most %s' % max + else: + msg = '' + context.Message( "Checking boost version%s... " % msg ) + if context.env.has_key('BOOST_VERSION'): + ret = context.env['BOOST_VERSION'] + else: + ret = context.TryRun("#include \n" + "#include \n" + "int main(int, char **)\n" + "{ std::cout << BOOST_LIB_VERSION << std::endl; }", + ".cc")[-1].strip() + if not ret: - context.Result("no boost includes found") - context.env.Replace( BOOST_VERSION = '' ) - return None + msg = "no boost includes found" + context.env.Replace( BOOST_VERSION = None ) else: - context.Result(ret) context.env.Replace( BOOST_VERSION = ret ) - return ret + msg = ret + if min or max: + try: version = map(int,ret.split('_')) + except ValueError: + msg = "[%s] invalid version syntax" % ret + ret = None + else: + if min : ret = ret and (version>=map(int,min.split('_'))) + if max : ret = ret and (version<=map(int,max.split('_'))) + msg = '[%s] %s' % (msg, ret and "yes" or "no") + context.Result(msg) + if fail and not ret : context.env.Fail('No valid boost includes found') + return ret @ConfTest def CheckBoostVariants(context, *variants):