.test.bin
.test.stamp
.test-valgrind.stamp
+.sconf_temp/
+config.log
# Local files (files in this directory)
/SConscript.local
# -*- python -*-
+from __future__ import with_statement
+
import sys, os.path, fnmatch
-import SENFSCons, senfutil
+import SENFSCons, senfutil, senfconf
+
###########################################################################
# Load utilities and setup libraries and configure build
CLEAN_PATTERNS = [ '*~', '#*#', '*.pyc', 'semantic.cache', '.sconsign*' ],
BUILDDIR = '${FLAVOR and "#/build/$FLAVOR" or "#"}',
- CPPPATH = [ '$BUILDDIR', '#' ],
+ CPPPATH = [ '#', '$BUILDDIR',
+ '${NEED_BOOST_EXT and "#/boost_ext" or None}' ],
LOCALLIBDIR = '$BUILDDIR',
LIBPATH = [ '$LOCALLIBDIR' ],
- LIBS = [ '$LIBSENF$LIBADDSUFFIX', '$EXTRA_LIBS' ],
- EXTRA_LIBS = [ 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
- '$BOOSTFSLIB' ],
+ LIBS = [ '$EXTRA_LIBS' ],
+ EXTRA_LIBS = [ 'rt' ],
TEST_EXTRA_LIBS = [ ],
VALGRINDARGS = [ '--num-callers=50' ],
LIBSENF = "senf",
LCOV = "lcov",
GENHTML = "genhtml",
+ VALGRIND = "valgrind",
SCONSBIN = env.File("#/tools/scons"),
SCONSARGS = [ '-Q', '-j$CONCURRENCY_LEVEL', 'debug=$debug', 'final=$final' ] + \
[ '%s=%s' % (k,v) for k,v in ARGUMENTS.iteritems() ],
FLAVOR = '',
)
-# ugly hack for ubuntu karmic
-# ToDo: auto-configure alike support
-if os.path.exists('/usr/lib/libboost_regex-mt.so'):
- env.Append( BOOST_VARIANT = '-mt' )
-
# Set variables from command line
senfutil.parseArguments(
env,
if env.has_key('only_tests') : env['sparse_tests'] = True
Export('env')
+###########################################################################
+# Configure
+
+# Default configuration (boost stuff)
+senfutil.Configure(env)
+
+@senfconf.Test
+def CheckValgrind(context):
+ context.Message( "Checking for valgrind... " )
+ ret = context.TryAction(['valgrind --version >$TARGET'])
+ context.Result( ret[1].strip() or False )
+ return ret[0]
+
+@senfconf.Test
+def CheckValgrindWildcards(context):
+ context.Message( "Checking whether valgrind supports '...' wildcards in suppressions... " )
+ ret = context.TryAction(['valgrind --suppressions=$SOURCE /bin/true'],
+ "{\n test_suppression\n Memcheck:Addr4\n ...\n fun:foo\n}\n",
+ ".sup")
+ context.Result( ret[0] )
+ return ret[0]
+
+conf = env.Configure(clean=False, help=False, custom_tests = senfconf.Tests())
+env.Replace(
+ HAVE_VALGRIND = conf.CheckValgrind() and conf.CheckValgrindWildcards()
+)
+conf.Finish()
+
+# Only add this here, after all configure checks have run
+
+env.Append(LIBS = '$LIBSENF$LIBADDSUFFIX',
+ EXTRA_LIBS = [ '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
+ '$BOOSTFSLIB' ])
+
+###########################################################################
+
# Create Doxyfile.local otherwise doxygen will barf on this non-existent file
# Create it even when cleaning, to silence the doxygen builder warnings
if not os.path.exists("doclib/Doxyfile.local"):
env.PhonyTarget('prepare', [], [])
#### valgrind
-for test in env.FindAllBoostUnitTests():
- stamp = env.Command(test[0].dir.File('.test-valgrind.stamp'),
- [ test[0].dir.File('.test.bin'), 'tools/valgrind.sup' ],
- [ """valgrind --tool=memcheck
- --error-exitcode=99
- --suppressions=${SOURCES[1]}
- $VALGRINDARGS
- ${SOURCES[0]} $BOOSTTESTARGS;
- [ $$? -ne 99 ] || exit 1""".replace("\n"," "),
- Touch("$TARGET") ])
- alias = env.Command(test[0].dir.File('valgrind'), stamp, [ env.NopAction() ])
- env.Alias('all_valgrinds', alias)
+env.Alias('all_valgrinds')
+if env['HAVE_VALGRIND']:
+ for test in env.FindAllBoostUnitTests():
+ stamp = env.Command(test[0].dir.File('.test-valgrind.stamp'),
+ [ test[0].dir.File('.test.bin'), 'tools/valgrind.sup' ],
+ [ """$VALGRIND --tool=memcheck
+ --error-exitcode=1
+ --suppressions=${SOURCES[1]}
+ $VALGRINDARGS
+ ${SOURCES[0]} --result_code=no $BOOSTTESTARGS
+ """.replace("\n"," "),
+ Touch("$TARGET") ])
+ alias = env.Command(test[0].dir.File('valgrind'), stamp, [ env.NopAction() ])
+ env.Alias('all_valgrinds', alias)
### lcov
env.PhonyTarget('lcov', [], [
--- /dev/null
+from __future__ import with_statement
+
+_configTests = {}
+
+def Tests():
+ global _configTests
+ return _configTests
+
+def Test(func):
+ global _configTests
+ _configTests[func.__name__] = func
+
+class TemporaryContext:
+ def __init__(self, context):
+ self._context = context
+ self._env = self._context.env.Clone()
+
+ def __enter__(self):
+ return None
+
+ def __exit__(self,*args):
+ self._context.env.Replace(**self._env.Dictionary())
+ return False
+
+@Test
+def CheckBoostVersion(context):
+ context.Message( "Checking boost version... " )
+ ret = context.TryRun("#include <boost/version.hpp>\n"
+ "#include <iostream>\n"
+ "int main(int, char **) { std::cout << BOOST_LIB_VERSION << std::endl; }",
+ ".cc")[1].strip()
+ if not ret:
+ context.Result("no boost includes found")
+ return None
+ else:
+ context.Result(ret)
+ return ret
+
+@Test
+def CheckBoostVariants(context, *variants):
+ useVariant = None
+ with TemporaryContext(context):
+ for variant in variants:
+ if variant : variantStr = "'%s'" % variant
+ else : variantStr = "default"
+ context.Message( "Checking boost %s variant... " % variantStr )
+ context.env.Replace( BOOST_VARIANT=variant )
+ context.env.Append( _LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic' )
+ ret = context.TryLink("#define BOOST_AUTO_TEST_MAIN\n"
+ "#include <boost/test/auto_unit_test.hpp>\n"
+ "#include <boost/test/test_tools.hpp>\n"
+ "BOOST_AUTO_TEST_CASE(test) { BOOST_CHECK(true); }\n",
+ ".cc")
+ context.Result( ret )
+ if ret and useVariant is None:
+ useVariant = variant
+ if useVariant is not None and not context.env.GetOption('no_progress'):
+ print "Using %s boost variant." % (
+ useVariant and "'%s'" % useVariant or "default")
+ return useVariant
import os.path, glob, site_tools.Yaptu
from SCons.Script import *
+import senfconf
senfutildir = os.path.dirname(__file__)
# This looks much more complicated than it is: We do three things here:
# a) switch between final or debug options
# b) parse the LOGLEVELS parameter into the correct SENF_LOG_CONF syntax
-# c) check for a local SENF, set options accordingly and update that SENF if needed
+# c) check for a local SENF, set options accordingly
+# d) check, wether the boost extensions are needed
def SetupForSENF(env, senf_path = []):
global senfutildir
loadTools(env)
env.Append(
- LIBS = [ 'senf', 'rt', '$BOOSTREGEXLIB',
- '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
- '$BOOSTFSLIB' ],
+ LIBS = [ 'rt' ],
CXXFLAGS = [ '-Wno-long-long', '$CXXFLAGS_' ],
CXXFLAGS_ = BuildTypeOptions('CXXFLAGS'),
if not env.GetOption('no_progress'):
print "\nSENF library not found .. trying build anyway !!\n"
+ Configure(env)
+
+ # Only add senf after all configure checks have run
+ env.Append(
+ CPPPATH = '${NEED_BOOST_EXT and "$SENFDIR/boost_ext" or None}',
+ LIBS = [ 'senf', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
+ '$BOOSTFSLIB' ],
+ )
+
env.Alias('all', '#')
LINKFLAGS_normal = [ '-Wl,-S' ],
LINKFLAGS_debug = [ '-g' ],
)
- # ugly hack for ubuntu karmic
- # ToDo: auto-configure alike support
- if os.path.exists('/usr/lib/libboost_regex-mt.so'):
- env.Append( BOOST_VARIANT = '-mt' )
def Glob(env, exclude=[], subdirs=[]):
testSources.sort()
return (sources, testSources)
+
+def Configure(env):
+ conf = env.Configure(clean=False, help=False, custom_tests = senfconf.Tests())
+ env.Replace(
+ BOOST_VERSION = conf.CheckBoostVersion(),
+ BOOST_VARIANT = conf.CheckBoostVariants( '', 'mt' ),
+ NEED_BOOST_EXT = not conf.CheckCXXHeader("boost/bimap.hpp"),
+ )
+ conf.Finish()
+
+
tagfiles = None
def Doxygen(env, doxyheader=None, doxyfooter=None, doxycss=None, mydoxyfile=False, senfdoc_path=[],
def generate(env):
env.SetDefault(
BOOST_VARIANT = '',
+ _BOOST_VARIANT = '${BOOST_VARIANT and "-" or None}$BOOST_VARIANT',
- BOOSTTESTLIB = 'boost_unit_test_framework$BOOST_VARIANT',
- BOOSTREGEXLIB = 'boost_regex$BOOST_VARIANT',
- BOOSTFSLIB = 'boost_filesystem$BOOST_VARIANT',
- BOOSTIOSTREAMSLIB = 'boost_iostreams$BOOST_VARIANT',
- BOOSTSIGNALSLIB = 'boost_signals$BOOST_VARIANT',
+ BOOSTTESTLIB = 'boost_unit_test_framework$_BOOST_VARIANT',
+ BOOSTREGEXLIB = 'boost_regex$_BOOST_VARIANT',
+ BOOSTFSLIB = 'boost_filesystem$_BOOST_VARIANT',
+ BOOSTIOSTREAMSLIB = 'boost_iostreams$_BOOST_VARIANT',
+ BOOSTSIGNALSLIB = 'boost_signals$_BOOST_VARIANT',
BOOSTTESTARGS = [ '--build_info=yes', '--log_level=test_suite' ],
)