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 ...@@ -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.Object(env, target='80211Bundle', sources=sources,
SENFSCons.Lib(env, sources=sources[0]) testSources = tests + [ '80211Bundle.o' ])
SENFSCons.Lib(env, sources=sources)
env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes)
......
...@@ -5,9 +5,10 @@ import SENFSCons, glob ...@@ -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.Object(env, target = '80221Bundle', sources=sources,
SENFSCons.Lib(env, sources[0]) testSources = tests + [ '80221Bundle.o' ])
SENFSCons.Lib(env, sources)
SConscript(glob.glob("*/SConscript")) SConscript(glob.glob("*/SConscript"))
...@@ -5,10 +5,11 @@ import SENFSCons, glob ...@@ -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.Object(env, target='DefaultBundle', sources=sources,
SENFSCons.Lib(env, sources[0]) testSources=tests + [ 'DefaultBundle.o' ])
SENFSCons.Lib(env, sources)
env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes)
......
...@@ -5,9 +5,10 @@ import SENFSCons, glob ...@@ -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.Object(env, target='MPEGDVBBundle', sources=sources,
SENFSCons.Lib(env, sources[0]) testSources = tests + [ 'MPEGDVBBundle.o' ])
SENFSCons.Lib(env, sources)
env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes)
...@@ -26,37 +26,28 @@ import SCons.Defaults ...@@ -26,37 +26,28 @@ import SCons.Defaults
import os.path import os.path
import os import os
def BoostUnitTests(env, target, objects, test_sources=None, LIBS = [], OBJECTS = [], DEPENDS = [], **kw): def BoostUnitTests(env, target=None, source=None, **kw):
path, name = os.path.split(target) target = env.arg2nodes(target)[0]
if test_sources:
if type(test_sources) is not type([]): binnode = target.dir.File('.' + target.name + '.bin')
test_sources = [ test_sources ] stampnode = target.dir.File('.' + target.name + '.stamp')
else:
test_sources = [] bin = env.Program(binnode, source,
testEnv = env.Clone(**kw) LIBS = env['LIBS'] + [ '$TEST_EXTRA_LIBS' ],
testEnv.Prepend(_LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ') _LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ' + env['_LIBFLAGS'],
testEnv.Prepend(LIBS = LIBS) **kw)
testEnv.Append(LIBS = env['TEST_EXTRA_LIBS'])
all_objects = [] stamp = env.Command(stampnode, bin,
if not objects: [ '$SOURCE $BOOSTTESTARGS',
objects = [] 'touch $TARGET' ],
all_objects = objects + env.Object(test_sources) + OBJECTS **kw)
binName = os.path.join(path,'.' + name +'.bin')
testRunner = testEnv.Program(binName, all_objects) return env.Command(env.File(target), stamp, [ 'true' ])
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 generate(env): def generate(env):
env['BOOSTTESTLIB'] = 'boost_unit_test_framework' env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ] env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
env.__class__.BoostUnitTests = dispatcher env['BUILDERS']['BoostUnitTests'] = BoostUnitTests
def exists(env): def exists(env):
return 1 return 1
...@@ -30,64 +30,36 @@ def Glob(env, exclude=[], subdirs=[]): ...@@ -30,64 +30,36 @@ def Glob(env, exclude=[], subdirs=[]):
def LibPath(lib): return '${LOCALLIBDIR}/${LIBPREFIX}%s${LIBADDSUFFIX}${LIBSUFFIX}' % lib def LibPath(lib): return '${LOCALLIBDIR}/${LIBPREFIX}%s${LIBADDSUFFIX}${LIBSUFFIX}' % lib
def Test(env, sources, LIBS = [], OBJECTS = []): def Test(env, sources):
test = [ env.BoostUnitTests( test = env.BoostUnitTests( target = 'test',
target = 'test', source = sources,
objects = [], TEST_EXTRA_LIBS = [ '$LIBSENF$LIBADDSUFFIX'
test_sources = sources, ] + env['TEST_EXTRA_LIBS'])
LIBS = [ '$LIBSENF$LIBADDSUFFIX' ],
OBJECTS = OBJECTS,
DEPENDS = [ env.File(LibPath(env['LIBSENF'])) ]) ]
compileTestSources = [ src for src in sources compileTestSources = [ src for src in sources
if 'COMPILE_CHECK' in file(src).read() ] if 'COMPILE_CHECK' in file(src).read() ]
if compileTestSources: if compileTestSources:
test.extend(env.CompileCheck(source = compileTestSources)) env.Depends(test, env.CompileCheck(source = compileTestSources))
env.Alias('all_tests', test) 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(()): if type(sources) == type(()):
testSources = sources[1] testSources = sources[1]
sources = sources[0] sources = sources[0]
if type(sources) is not type([]): if type(sources) is not type([]):
sources = [ sources ] sources = [ sources ]
objects = None objects = env.Object(sources)
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)
if testSources: if testSources:
test = [ env.BoostUnitTests( Test(env, testSources)
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)
return objects return objects
## \brief Build documentation with doxygen
#
# \ingroup target
def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
# There is one small problem we need to solve with this builder: The Doxygen builder reads # 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 # 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 = []): ...@@ -151,20 +123,21 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
return doc return doc
def Lib(env, sources, testSources = None, OBJECTS = []): def Lib(env, sources, testSources = None, OBJECTS = []):
objects = Objects(env,sources,testSources,OBJECTS=OBJECTS) objects = Objects(env,sources,testSources)
env.Append(ALLOBJECTS = objects) env.Append(ALLOBJECTS = objects)
return objects return objects
def Object(env, target, sources, testSources = None, OBJECTS = []): def Object(env, target, sources, testSources = None, OBJECTS = []):
objects = Objects(env,sources,testSources,OBJECTS=OBJECTS) objects = Objects(env,sources,testSources)
ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects, "ld -r -o $TARGET $SOURCES") ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects+OBJECTS,
[ "ld -r -o $TARGET $SOURCES" ])
env.Default(ob) env.Default(ob)
env.Alias('default', ob) env.Alias('default', ob)
env.Alias('install_all', env.Install("$OBJINSTALLDIR", ob)) env.Alias('install_all', env.Install("$OBJINSTALLDIR", ob))
return ob return ob
def Binary(env, binary, sources, testSources = None, OBJECTS = []): 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, program = env.Program(target = binary,
source = objects+OBJECTS, source = objects+OBJECTS,
LIBS = [ '$LIBSENF$LIBADDSUFFIX' ] + env['LIBS']) 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