Skip to content
Snippets Groups Projects
Commit 0af284f4 authored by g0dil's avatar g0dil
Browse files

Restructure SENFSCons.Object helper

parent c5a7d137
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,11 @@ import SENFSCons, glob
###########################################################################
sources, includes = SENFSCons.Glob(env)
(sources, tests), includes = SENFSCons.Glob(env)
SENFSCons.Object(env, target='80211Bundle', sources=sources)
SENFSCons.Lib(env, sources=sources[0])
SENFSCons.Object(env, target='80211Bundle', sources=sources,
testSources = tests + [ '80211Bundle.o' ])
SENFSCons.Lib(env, sources=sources)
env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes)
......
......@@ -5,9 +5,10 @@ import SENFSCons, glob
###########################################################################
sources, includes = SENFSCons.Glob(env)
(sources, tests), includes = SENFSCons.Glob(env)
SENFSCons.Object(env, target = '80221Bundle', sources=sources)
SENFSCons.Lib(env, sources[0])
SENFSCons.Object(env, target = '80221Bundle', sources=sources,
testSources = tests + [ '80221Bundle.o' ])
SENFSCons.Lib(env, sources)
SConscript(glob.glob("*/SConscript"))
......@@ -5,10 +5,11 @@ import SENFSCons, glob
###########################################################################
sources, includes = SENFSCons.Glob(env)
(sources, tests), includes = SENFSCons.Glob(env)
SENFSCons.Object(env, target='DefaultBundle', sources=sources)
SENFSCons.Lib(env, sources[0])
SENFSCons.Object(env, target='DefaultBundle', sources=sources,
testSources=tests + [ 'DefaultBundle.o' ])
SENFSCons.Lib(env, sources)
env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes)
......
......@@ -5,9 +5,10 @@ import SENFSCons, glob
###########################################################################
sources, includes = SENFSCons.Glob(env)
(sources, tests), includes = SENFSCons.Glob(env)
SENFSCons.Object(env, target='MPEGDVBBundle', sources=sources)
SENFSCons.Lib(env, sources[0])
SENFSCons.Object(env, target='MPEGDVBBundle', sources=sources,
testSources = tests + [ 'MPEGDVBBundle.o' ])
SENFSCons.Lib(env, sources)
env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes)
......@@ -26,37 +26,28 @@ import SCons.Defaults
import os.path
import os
def BoostUnitTests(env, target, objects, test_sources=None, LIBS = [], OBJECTS = [], DEPENDS = [], **kw):
path, name = os.path.split(target)
if test_sources:
if type(test_sources) is not type([]):
test_sources = [ test_sources ]
else:
test_sources = []
testEnv = env.Clone(**kw)
testEnv.Prepend(_LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ')
testEnv.Prepend(LIBS = LIBS)
testEnv.Append(LIBS = env['TEST_EXTRA_LIBS'])
all_objects = []
if not objects:
objects = []
all_objects = objects + env.Object(test_sources) + OBJECTS
binName = os.path.join(path,'.' + name +'.bin')
testRunner = testEnv.Program(binName, all_objects)
stamp = os.path.join(path,'.' + os.path.splitext(name)[0]+'.stamp')
if DEPENDS:
env.Depends(testRunner, DEPENDS)
return env.Command([ stamp ], testRunner,
[ '$SOURCE $BOOSTTESTARGS',
'touch $TARGET' ])
def dispatcher(*arg,**kw):
return BoostUnitTests(*arg,**kw)
def BoostUnitTests(env, target=None, source=None, **kw):
target = env.arg2nodes(target)[0]
binnode = target.dir.File('.' + target.name + '.bin')
stampnode = target.dir.File('.' + target.name + '.stamp')
bin = env.Program(binnode, source,
LIBS = env['LIBS'] + [ '$TEST_EXTRA_LIBS' ],
_LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ' + env['_LIBFLAGS'],
**kw)
stamp = env.Command(stampnode, bin,
[ '$SOURCE $BOOSTTESTARGS',
'touch $TARGET' ],
**kw)
return env.Command(env.File(target), stamp, [ 'true' ])
def generate(env):
env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
env.__class__.BoostUnitTests = dispatcher
env['BUILDERS']['BoostUnitTests'] = BoostUnitTests
def exists(env):
return 1
......@@ -30,64 +30,36 @@ def Glob(env, exclude=[], subdirs=[]):
def LibPath(lib): return '${LOCALLIBDIR}/${LIBPREFIX}%s${LIBADDSUFFIX}${LIBSUFFIX}' % lib
def Test(env, sources, LIBS = [], OBJECTS = []):
test = [ env.BoostUnitTests(
target = 'test',
objects = [],
test_sources = sources,
LIBS = [ '$LIBSENF$LIBADDSUFFIX' ],
OBJECTS = OBJECTS,
DEPENDS = [ env.File(LibPath(env['LIBSENF'])) ]) ]
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:
test.extend(env.CompileCheck(source = compileTestSources))
env.Depends(test, env.CompileCheck(source = compileTestSources))
env.Alias('all_tests', test)
env.Command(env.File('test'), test, [ 'true' ])
return test
def Objects(env, sources, testSources = None, OBJECTS = []):
def Objects(env, sources, testSources = None):
if type(sources) == type(()):
testSources = sources[1]
sources = sources[0]
if type(sources) is not type([]):
sources = [ sources ]
objects = None
if sources:
obsources = [ source
for source in sources
if type(source) is type('') and not source.endswith('.o') ]
objects = [ source
for source in sources
if type(source) is not type('') or source.endswith('.o') ]
if obsources:
objects += env.Object(obsources)
objects = env.Object(sources)
if testSources:
test = [ env.BoostUnitTests(
target = 'test',
objects = objects,
test_sources = testSources,
LIBS = [ '$LIBSENF$LIBADDSUFFIX' ],
OBJECTS = OBJECTS,
DEPENDS = [ env.File(LibPath(env['LIBSENF'])) ]) ]
compileTestSources = [ src for src in testSources
if 'COMPILE_CHECK' in file(src).read() ]
if compileTestSources:
test.extend(env.CompileCheck(source = compileTestSources))
env.Alias('all_tests', test)
# Hmm ... here I'd like to use an Alias instead of a file
# however the alias does not seem to live in the subdirectory
# which breaks 'scons -u test'
env.Command(env.File('test'), test, [ 'true' ])
#env.Alias(env.File('test'), test)
Test(env, testSources)
return objects
## \brief Build documentation with doxygen
#
# \ingroup target
def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
# There is one small problem we need to solve with this builder: The Doxygen builder reads
# the Doxyfile and thus depends on the environment variables set by doclib/doxygen.sh. We
......@@ -151,20 +123,21 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
return doc
def Lib(env, sources, testSources = None, OBJECTS = []):
objects = Objects(env,sources,testSources,OBJECTS=OBJECTS)
objects = Objects(env,sources,testSources)
env.Append(ALLOBJECTS = objects)
return objects
def Object(env, target, sources, testSources = None, OBJECTS = []):
objects = Objects(env,sources,testSources,OBJECTS=OBJECTS)
ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects, "ld -r -o $TARGET $SOURCES")
objects = Objects(env,sources,testSources)
ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects+OBJECTS,
[ "ld -r -o $TARGET $SOURCES" ])
env.Default(ob)
env.Alias('default', ob)
env.Alias('install_all', env.Install("$OBJINSTALLDIR", ob))
return ob
def Binary(env, binary, sources, testSources = None, OBJECTS = []):
objects = Objects(env, sources, testSources, OBJECTS=OBJECTS)
objects = Objects(env, sources, testSources)
program = env.Program(target = binary,
source = objects+OBJECTS,
LIBS = [ '$LIBSENF$LIBADDSUFFIX' ] + env['LIBS'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment