env.EnsureSConsVersion(1,2)
# Load all the local SCons tools
-env.Tool('Doxygen')
-env.Tool('Dia2Png')
-env.Tool('PkgDraw')
-env.Tool('InstallSubdir')
-env.Tool('CopyToDir')
-env.Tool('Boost')
-env.Tool('CombinedObject')
-env.Tool('PhonyTarget')
-env.Tool('InstallDir')
-env.Tool('CreateFile')
+senfutil.loadTools(env)
env.Help("""
Additional top-level build targets:
fixlinks Fix broken links in doxygen documentation
all_valgrinds Run all tests under valgrind/memcheck
lcov Generate test coverage output in doc/lcov and lcov.info
+
+You may execute targets on a remote host (if the directory layout is the same)
+by calling
+
+ scons <target>@[<user>@]<host>
""")
env.Append(
- ENV = { 'PATH' : os.environ.get('PATH'), 'HOME' : os.environ.get('HOME') },
+ ENV = { 'PATH' : os.environ.get('PATH'),
+ 'HOME' : os.environ.get('HOME'),
+ 'SSH_AGENT_PID': os.environ.get('SSH_AGENT_PID'),
+ 'SSH_AUTH_SOCK': os.environ.get('SSH_AUTH_SOCK') },
CLEAN_PATTERNS = [ '*~', '#*#', '*.pyc', 'semantic.cache', '.sconsign*' ],
- BUILDDIR = '#',
+ BUILDDIR = '${FLAVOR and "#/build/$FLAVOR" or "#"}',
CPPPATH = [ '$BUILDDIR', '#' ],
LOCALLIBDIR = '$BUILDDIR',
LIBPATH = [ '$LOCALLIBDIR' ],
- LIBS = [ '$LIBSENF$LIBADDSUFFIX', 'rt', '$BOOSTREGEXLIB',
- '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB', '$BOOSTFSLIB' ],
+ LIBS = [ '$LIBSENF$LIBADDSUFFIX', '$EXTRA_LIBS' ],
+ EXTRA_LIBS = [ 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
+ '$BOOSTFSLIB' ],
TEST_EXTRA_LIBS = [ ],
VALGRINDARGS = [ '--num-callers=50' ],
LCOV = "lcov",
GENHTML = "genhtml",
SCONSBIN = env.File("#/tools/scons"),
- SCONS = "@$SCONSBIN -Q -j$CONCURRENCY_LEVEL",
+ SCONSARGS = [ '-Q', '-j$CONCURRENCY_LEVEL', 'debug=$debug', 'final=$final' ],
+ SCONS = "@$SCONSBIN $SCONSARGS",
CONCURRENCY_LEVEL = env.GetOption('num_jobs') or 1,
TOPDIR = env.Dir('#').abspath,
+ LIBADDSUFFIX = '${FLAVOR and "_$FLAVOR" or ""}',
+ OBJADDSUFFIX = '${LIBADDSUFFIX}',
+ FLAVOR = '',
)
# Set variables from command line
BoolVariable('final', 'Build final (optimized) build', False),
BoolVariable('debug', 'Link in debug symbols', False),
BoolVariable('syslayout', 'Install in to system layout directories (lib/, include/ etc)', False),
+ BoolVariable('sparse_tests', 'Link tests against object files and not the senf lib', False)
)
+if env.has_key('only_tests') : env['sparse_tests'] = True
Export('env')
# Create Doxyfile.local otherwise doxygen will barf on this non-existent file
SConscript("debian/SConscript")
SConscriptChdir(1)
if os.path.exists('SConscript.local') : SConscript('SConscript.local')
-if env['BUILDDIR'] == '#':
+if env['sparse_tests']:
+ import SparseTestHack
+ SparseTestHack.setup(env)
+if env.subst('$BUILDDIR') == '#':
SConscript("SConscript")
else:
- SConscript("SConscript", variant_dir=env['BUILDDIR'], src_dir='#', duplicate=False)
+ SConscript("SConscript", variant_dir=env.subst('$BUILDDIR'), src_dir='#', duplicate=False)
SConscript("Examples/SConscript")
SConscript("HowTos/SConscript")
SConscript("doclib/SConscript")
+if env['sparse_tests']:
+ SparseTestHack.build(env)
###########################################################################
# Define build targets
### lcov
env.PhonyTarget('lcov', [], [
- '$SCONS debug=1 BUILDDIR="#/lcov-build" CCFLAGS+="-fprofile-arcs -ftest-coverage" LIBS+="gcov" all_tests',
- '$LCOV --follow --directory $TOPDIR/lcov-build/senf --capture --output-file /tmp/senf_lcov.info --base-directory $TOPDIR',
+ '$SCONS debug=1 BUILDDIR="#/build/lcov" CCFLAGS+="-fprofile-arcs -ftest-coverage" LIBS+="gcov" all_tests',
+ '$LCOV --follow --directory $TOPDIR/build/lcov/senf --capture --output-file /tmp/senf_lcov.info --base-directory $TOPDIR',
'$LCOV --output-file lcov.info --remove /tmp/senf_lcov.info "*/include/*" "*/boost/*" "*.test.*" ',
'$GENHTML --output-directory doc/lcov --title all_tests lcov.info',
'rm /tmp/senf_lcov.info' ])
for path, subdirs, files in os.walk('.')
for pattern in ('*.gcno', '*.gcda', '*.gcov')
for f in fnmatch.filter(files,pattern) ] +
- [ 'lcov.info', env.Dir('doc/lcov'), env.Dir('lcov-build') ])
+ [ 'lcov.info', env.Dir('doc/lcov'), env.Dir('build/lcov') ])
#### clean
-env.Clean('all', ('.prepare-stamp', env.Dir('dist')))
+env.Clean('all', ('.prepare-stamp', env.Dir('dist'), env.Dir('build')))
if env.GetOption('clean') : env.Depends('all', ('lcov', 'all_valgrinds'))
-if env.GetOption('clean') and 'all' in BUILD_TARGETS:
+if env.GetOption('clean') and 'all' in BUILD_TARGETS:
env.Clean('all', [ os.path.join(path,f)
for path, subdirs, files in os.walk('.')
for pattern in env['CLEAN_PATTERNS']
if not env.GetOption('clean') and not os.path.exists(".prepare-stamp"):
Execute(Touch(".prepare-stamp"))
+
+### execute targets on remote hosts
+for target in COMMAND_LINE_TARGETS:
+ if '@' in target:
+ realtarget, host = target.split('@',1)
+ cwd=env.GetLaunchDir()
+ home=os.environ['HOME']+'/'
+ if cwd.startswith(home) : cwd = cwd[len(home):]
+ args = [ '$SCONSARGS' ]
+ if env.GetLaunchDir() != os.getcwd():
+ args.append('-u')
+ env.PhonyTarget(target, [], [ "ssh $HOST scons $SCONSARGS -C $DIR $RTARGET" ],
+ HOST=host, RTARGET=realtarget, DIR=cwd, SCONSARGS=args)