From: g0dil Date: Thu, 20 Aug 2009 11:33:27 +0000 (+0000) Subject: Combine all boot build stuff in a single scons tool X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=6b43243d9b1a3b9720efdacc6f02364877ebe2aa Combine all boot build stuff in a single scons tool Remove and/or simplify most remaining SENFSCons stuff git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1312 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/MCSniffer/SConscript b/Examples/MCSniffer/SConscript index d7814c2..9d517a2 100644 --- a/Examples/MCSniffer/SConscript +++ b/Examples/MCSniffer/SConscript @@ -1,7 +1,10 @@ +# -*- python -*- + Import('env') import SENFSCons ########################################################################### -SENFSCons.Binary(env, 'mcsniffer', SENFSCons.GlobSources(env), - OBJECTS = [ '#/Packets/DefaultBundle/DefaultBundle.o' ]); +sources, tests, includes = SENFSCons.Glob(env) + +env.Default(env.Program('mcsniffer', sources + [ '#/Packets/DefaultBundle/DefaultBundle.o' ])) diff --git a/Examples/MultiMCLoop/SConscript b/Examples/MultiMCLoop/SConscript index 6715a54..f599edf 100644 --- a/Examples/MultiMCLoop/SConscript +++ b/Examples/MultiMCLoop/SConscript @@ -3,4 +3,4 @@ import SENFSCons ########################################################################### -SENFSCons.Binary(env, 'multimcloop', [ 'MultiMCLoop.cc' ]) +env.Default(env.Program('multimcloop', [ 'MultiMCLoop.cc' ])) diff --git a/Examples/RateStuffer/SConscript b/Examples/RateStuffer/SConscript index e576fb5..b00267b 100644 --- a/Examples/RateStuffer/SConscript +++ b/Examples/RateStuffer/SConscript @@ -3,7 +3,10 @@ import SENFSCons ########################################################################### -SENFSCons.Binary(env, 'ratestuffer', SENFSCons.GlobSources(env)); +sources, tests, includes = SENFSCons.Glob(env) + +env.Default(env.Program('ratestuffer', sources)) + SENFSCons.Doxygen(env, extra_sources=[ env.Dia2Png('ratestuffer.dia') ]) diff --git a/Examples/Sniffer/SConscript b/Examples/Sniffer/SConscript index 61d91e1..a398943 100644 --- a/Examples/Sniffer/SConscript +++ b/Examples/Sniffer/SConscript @@ -1,11 +1,14 @@ +# -*- python -*- + Import('env') import SENFSCons ########################################################################### -SENFSCons.Binary(env, 'sniffer', SENFSCons.GlobSources(env), - OBJECTS = [ '#/Packets/DefaultBundle/DefaultBundle.o', - '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o', - '#/Packets/80221Bundle/80221Bundle.o', - '#/Packets/80211Bundle/80211Bundle.o' ] ); +sources, tests, includes = SENFSCons.Glob(env) + +env.Program('sniffer', sources + [ '#/Packets/DefaultBundle/DefaultBundle.o', + '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o', + '#/Packets/80221Bundle/80221Bundle.o', + '#/Packets/80211Bundle/80211Bundle.o' ] ) SENFSCons.Doxygen(env) diff --git a/Examples/TCPClientServer/SConscript b/Examples/TCPClientServer/SConscript index 203c81d..78d4eca 100644 --- a/Examples/TCPClientServer/SConscript +++ b/Examples/TCPClientServer/SConscript @@ -3,5 +3,5 @@ import SENFSCons ########################################################################### -SENFSCons.Binary(env, 'client', 'client.cc'); -SENFSCons.Binary(env, 'server', 'server.cc'); +env.Program('client', 'client.cc') +env.Program('server', 'server.cc') diff --git a/Examples/UDPClientServer/SConscript b/Examples/UDPClientServer/SConscript index cd426a8..b683c5b 100644 --- a/Examples/UDPClientServer/SConscript +++ b/Examples/UDPClientServer/SConscript @@ -3,6 +3,7 @@ import SENFSCons ########################################################################### -SENFSCons.Binary(env, 'udpClient', 'udpClient.cc'); -SENFSCons.Binary(env, 'udpServer', 'udpServer.cc',); +env.Default(env.Program('udpClient', 'udpClient.cc')) +env.Default(env.Program('udpServer', 'udpServer.cc')) + SENFSCons.Doxygen(env) diff --git a/PPI/SConscript b/PPI/SConscript index c0aedb7..50962cd 100644 --- a/PPI/SConscript +++ b/PPI/SConscript @@ -1,3 +1,5 @@ +# -*- python -*- + Import('env') import SENFSCons, glob @@ -9,12 +11,15 @@ SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if f not in ('all_includes.hh','PPI.hh') \ and not f.endswith('.test.hh') ]) -sources, includes = SENFSCons.Glob(env, subdirs=[ 'detail' ]) +sources, tests, includes = SENFSCons.Glob(env, subdirs=[ 'detail' ]) + +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) -SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env, extra_sources=[ env.Dia2Png('scenario.dia'), env.Dia2Png('classes.dia'), env.Dia2Png('ratestuffer.dia'), ]) -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) + +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Packets/80211Bundle/SConscript b/Packets/80211Bundle/SConscript index 66f97a4..ee66d7c 100644 --- a/Packets/80211Bundle/SConscript +++ b/Packets/80211Bundle/SConscript @@ -5,12 +5,13 @@ import SENFSCons, glob ########################################################################### -(sources, tests), includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Object(env, target='80211Bundle', sources=sources, - testSources = tests + [ '80211Bundle.o' ]) -SENFSCons.Lib(env, sources=sources) +objects = env.Object(sources) +cobject = env.CombinedObject('80211Bundle', objects) +env.Append(ALLOBJECTS = objects) +env.BoostUnitTest('test', tests + cobject) -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) SConscript(glob.glob("*/SConscript")) diff --git a/Packets/80221Bundle/SConscript b/Packets/80221Bundle/SConscript index 0cbf20a..121b491 100644 --- a/Packets/80221Bundle/SConscript +++ b/Packets/80221Bundle/SConscript @@ -5,10 +5,13 @@ import SENFSCons, glob ########################################################################### -(sources, tests), includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Object(env, target = '80221Bundle', sources=sources, - testSources = tests + [ '80221Bundle.o' ]) -SENFSCons.Lib(env, sources) +objects = env.Object(sources) +env.Install('$OBJINSTALLDIR', env.Default( env.CombinedObject('80221Bundle', objects) )) +env.Append(ALLOBJECTS = objects) +env.BoostUnitTest('test', tests + ['80221Bundle.o']) + +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) SConscript(glob.glob("*/SConscript")) diff --git a/Packets/DefaultBundle/SConscript b/Packets/DefaultBundle/SConscript index bfafdac..037cafc 100644 --- a/Packets/DefaultBundle/SConscript +++ b/Packets/DefaultBundle/SConscript @@ -5,12 +5,13 @@ import SENFSCons, glob ########################################################################### -(sources, tests), includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Object(env, target='DefaultBundle', sources=sources, - testSources=tests + [ 'DefaultBundle.o' ]) -SENFSCons.Lib(env, sources) +objects = env.Object(sources) +cobject = env.CombinedObject('DefaultBundle', objects) +env.Append(ALLOBJECTS = objects) +env.BoostUnitTest('test', tests + cobject) -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) SConscript(glob.glob("*/SConscript")) diff --git a/Packets/DefaultBundle/extra_tests/SConscript b/Packets/DefaultBundle/extra_tests/SConscript index f3b2df8..320bffd 100644 --- a/Packets/DefaultBundle/extra_tests/SConscript +++ b/Packets/DefaultBundle/extra_tests/SConscript @@ -5,4 +5,4 @@ import SENFSCons, glob ########################################################################### -SENFSCons.Test(env, sources = glob.glob("*.test.cc")) +env.BoostUnitTest('test', glob.glob("*.test.cc")) diff --git a/Packets/MPEGDVBBundle/SConscript b/Packets/MPEGDVBBundle/SConscript index dafcda7..f9359ac 100644 --- a/Packets/MPEGDVBBundle/SConscript +++ b/Packets/MPEGDVBBundle/SConscript @@ -5,10 +5,11 @@ import SENFSCons, glob ########################################################################### -(sources, tests), includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Object(env, target='MPEGDVBBundle', sources=sources, - testSources = tests + [ 'MPEGDVBBundle.o' ]) -SENFSCons.Lib(env, sources) +objects = env.Object(sources) +cobject = env.CombinedObject('MPEGDVBBundle', objects) +env.Append(ALLOBJECTS = objects) +env.BoostUnitTest('test', tests + cobject) -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Packets/SConscript b/Packets/SConscript index 69d353b..41d317a 100644 --- a/Packets/SConscript +++ b/Packets/SConscript @@ -5,9 +5,11 @@ import SENFSCons, glob ########################################################################### -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) + +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) -SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png("structure.dia"), env.Dia2Png("80221Bundle/TLV.dia"), @@ -58,7 +60,7 @@ SENFSCons.Doxygen(env, extra_sources = [ env.PkgDraw("MPEGDVBBundle/TransportPacket.hh"), ]) -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) SConscript(glob.glob("*/SConscript")) diff --git a/SConstruct b/SConstruct index ebb1fab..7cf0362 100644 --- a/SConstruct +++ b/SConstruct @@ -14,11 +14,11 @@ env = Environment() env.Tool('Doxygen', [ 'senfscons' ]) env.Tool('Dia2Png', [ 'senfscons' ]) env.Tool('PkgDraw', [ 'senfscons' ]) +env.Tool('InstallSubdir', [ 'senfscons' ]) env.Tool('CopyToDir', [ 'senfscons' ]) -env.Tool('CompileCheck', [ 'senfscons' ]) env.Tool('Boost', [ 'senfscons' ]) -env.Tool('BoostUnitTest', [ 'senfscons' ]) -env.Tool('InstallSubdir', [ 'senfscons' ]) +env.Tool('CombinedObject', [ 'senfscons' ]) +env.Tool('PhonyTarget', [ 'senfscons' ]) env.Help(""" Additional top-level build targets: @@ -44,6 +44,10 @@ class BuildTypeOptions: type = env['final'] and "final" or env['debug'] and "debug" or "normal" return env[self._var + "_" + type] +env.Replace( + PKGDRAW = 'doclib/pkgdraw', +) + env.Append( ENV = { 'PATH' : os.environ.get('PATH') }, CLEAN_PATTERNS = [ '*~', '#*#', '*.pyc', 'semantic.cache', '.sconsign*', '.sconsign' ], @@ -51,9 +55,9 @@ env.Append( CPPPATH = [ '#/include' ], LOCALLIBDIR = '#', LIBPATH = [ '$LOCALLIBDIR' ], - LIBS = [ 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB', - '$BOOSTFSLIB' ], - TEST_EXTRA_LIBS = [ '$LIBSENF$LIBADDSUFFIX' ], + LIBS = [ '$LIBSENF$LIBADDSUFFIX', 'rt', '$BOOSTREGEXLIB', + '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB', '$BOOSTFSLIB' ], + TEST_EXTRA_LIBS = [ ], PREFIX = '/usr/local', LIBINSTALLDIR = '$PREFIX/lib', @@ -113,17 +117,9 @@ if not os.path.exists("Doxyfile.local"): if not env.GetOption('clean') and not os.path.exists("local_config.hh"): Execute(Touch("local_config.hh")) -########################################################################### -# Define build targets - -# Before defining any targets, check wether this is the first build in -# pristine directory tree. If so, call 'scons prepare' so the dependencies -# created later are correct (yes, this is a hack :-( ) - if not env.GetOption('clean') and not os.path.exists(".prepare-stamp") \ and not os.environ.get("SCONS") and COMMAND_LINE_TARGETS != [ 'prepare' ]: env.Execute([ "scons prepare" ]) -env.Clean('all', '.prepare-stamp') # Load SConscripts. Need to load some first (they change the global environment) initSConscripts = [ @@ -138,29 +134,30 @@ if os.path.exists('SConscript.local'): SConscript(list(set(glob.glob("*/SConscript")) - set(initSConscripts))) -# Define the main targets -env.Alias('all', [ 'default', 'all_tests', 'all_docs' ]) +########################################################################### +# Define build targets +#### doc env.Depends(SENFSCons.Doxygen(env), env.Value(env['ENV']['REVISION'])) +#### libsenf.a libsenf = env.Library(env.subst("$LIBSENF$LIBADDSUFFIX"), env['ALLOBJECTS']) env.Default(libsenf) -env.Clean('all', libsenf) -env.Alias('default', libsenf) env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = [ 'config.hh' ]) +env.Install('$LIBINSTALLDIR', libsenf) -env.Alias('install_all', env.Install('$LIBINSTALLDIR', libsenf)) - -if env.GetOption('clean'): - env.Clean('all', [ os.path.join(path,f) - for path, subdirs, files in os.walk('.') - for pattern in env['CLEAN_PATTERNS'] - for f in fnmatch.filter(files,pattern) ]) +#### install_all, default, all_tests, all +env.Alias('install_all', env.FindInstalledFiles()) +env.Alias('default', DEFAULT_TARGETS) +env.Alias('all_tests', env.FindAllBoostUnitTests()) +env.Alias('all', [ 'default', 'all_tests', 'all_docs' ]) -SENFSCons.PhonyTarget(env, 'prepare', [ 'true' ]) +#### prepare +env.PhonyTarget('prepare', [], []) -SENFSCons.PhonyTarget(env, 'valgrind', [ """ +#### valgrind +env.PhonyTarget('valgrind', [ 'all_tests' ], [ """ find -name .test.bin | while read test; do echo; @@ -170,7 +167,18 @@ SENFSCons.PhonyTarget(env, 'valgrind', [ """ $$test $BOOSTTESTARGS; [ $$? -ne 99 ] || exit 1; done -""".replace("\n"," ") ], [ 'all_tests' ]) +""".replace("\n"," ") ]) + +#### clean +env.Clean('all', '.prepare-stamp') +env.Clean('all', libsenf) +env.Clean('all', 'linklint') + +if env.GetOption('clean'): + env.Clean('all', [ os.path.join(path,f) + for path, subdirs, files in os.walk('.') + for pattern in env['CLEAN_PATTERNS'] + for f in fnmatch.filter(files,pattern) ]) if not env.GetOption('clean') and not os.path.exists(".prepare-stamp"): Execute(Touch(".prepare-stamp")) diff --git a/Scheduler/SConscript b/Scheduler/SConscript index 6113f90..a91f80a 100644 --- a/Scheduler/SConscript +++ b/Scheduler/SConscript @@ -5,9 +5,9 @@ import SENFSCons ########################################################################### -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Socket/Protocols/DVB/SConscript b/Socket/Protocols/DVB/SConscript index 6f982f3..e1c3df4 100644 --- a/Socket/Protocols/DVB/SConscript +++ b/Socket/Protocols/DVB/SConscript @@ -10,8 +10,8 @@ SConscript(glob.glob("*/SConscript")) SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if f not in ('all_includes.hh','DVB.hh') and not f.endswith('.test.hh') ]) -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Socket/Protocols/INet/SConscript b/Socket/Protocols/INet/SConscript index 9e27f8b..9de80d5 100644 --- a/Socket/Protocols/INet/SConscript +++ b/Socket/Protocols/INet/SConscript @@ -10,8 +10,8 @@ SConscript(glob.glob("*/SConscript")) SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if f not in ('all_includes.hh','INet.hh') and not f.endswith('.test.hh') ]) -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Socket/Protocols/Raw/SConscript b/Socket/Protocols/Raw/SConscript index 83b578b..5f6b223 100644 --- a/Socket/Protocols/Raw/SConscript +++ b/Socket/Protocols/Raw/SConscript @@ -10,8 +10,8 @@ SConscript(glob.glob("*/SConscript")) SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if f not in ('all_includes.hh','Raw.hh') and not f.endswith('.test.hh') ]) -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Socket/Protocols/SConscript b/Socket/Protocols/SConscript index 3346cec..a55a9e0 100644 --- a/Socket/Protocols/SConscript +++ b/Socket/Protocols/SConscript @@ -7,7 +7,8 @@ import SENFSCons, glob SConscript(glob.glob("*/SConscript")) -sources, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) +sources, tests, includes = SENFSCons.Glob(env) -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Socket/Protocols/UN/SConscript b/Socket/Protocols/UN/SConscript index 6c79bf3..6366cfd 100644 --- a/Socket/Protocols/UN/SConscript +++ b/Socket/Protocols/UN/SConscript @@ -10,8 +10,8 @@ SConscript(glob.glob("*/SConscript")) SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if f not in ('all_includes.hh','UN.hh') and not f.endswith('.test.hh') ]) -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib( env, sources) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Socket/SConscript b/Socket/SConscript index 5206292..aac2ec5 100644 --- a/Socket/SConscript +++ b/Socket/SConscript @@ -10,9 +10,10 @@ SConscript(glob.glob("*/SConscript")) SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if f not in ('all_includes.hh','Socket.hh') and not f.endswith('.test.hh') ]) -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources = sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png('SocketLibrary-classes.dia'), env.Dia2Png('FhHierarchy.dia'), @@ -20,5 +21,4 @@ SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png('Protocols.dia'), env.Dia2Png('Handle.dia'), ]) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Utils/Console/SConscript b/Utils/Console/SConscript index 5303f1a..dfcac7b 100644 --- a/Utils/Console/SConscript +++ b/Utils/Console/SConscript @@ -5,11 +5,10 @@ import SENFSCons ########################################################################### -sources, includes = SENFSCons.Glob(env, exclude=['testServer.cc']) +sources, tests, includes = SENFSCons.Glob(env, exclude=['testServer.cc']) -SENFSCons.Lib(env, sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) - -SENFSCons.Binary(env, "testServer", ['testServer.cc']) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +env.Program('testServer', ['testServer.cc']) diff --git a/Utils/Daemon/SConscript b/Utils/Daemon/SConscript index 77967ed..9c34fd8 100644 --- a/Utils/Daemon/SConscript +++ b/Utils/Daemon/SConscript @@ -5,9 +5,9 @@ import SENFSCons, glob ########################################################################### -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Utils/Logger/SConscript b/Utils/Logger/SConscript index bb4f897..af32a01 100644 --- a/Utils/Logger/SConscript +++ b/Utils/Logger/SConscript @@ -9,9 +9,9 @@ SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") if ( f not in ('all_includes.hh','Logger.hh','SenfLog.hh') and not f.endswith('.test.hh') ) ]) -sources, includes = SENFSCons.Glob(env) +sources, tests, includes = SENFSCons.Glob(env) -SENFSCons.Lib(env, sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/Utils/SConscript b/Utils/SConscript index ef0872c..7181097 100644 --- a/Utils/SConscript +++ b/Utils/SConscript @@ -5,11 +5,11 @@ import SENFSCons, glob, os.path ########################################################################### -sources, includes = SENFSCons.Glob(env, subdirs=[ 'impl' ]) +sources, tests, includes = SENFSCons.Glob(env, subdirs=[ 'impl' ]) -SENFSCons.Lib(env, sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) SConscript(glob.glob("*/SConscript")) diff --git a/Utils/Termlib/SConscript b/Utils/Termlib/SConscript index 5f77839..9ec4988 100644 --- a/Utils/Termlib/SConscript +++ b/Utils/Termlib/SConscript @@ -5,11 +5,10 @@ import SENFSCons ########################################################################### -sources, includes = SENFSCons.Glob(env, exclude=[ 'telnetServer.cc']) +sources, tests, includes = SENFSCons.Glob(env, exclude=[ 'telnetServer.cc']) -SENFSCons.Lib(env, sources) +env.Append(ALLOBJECTS = env.Object(sources)) +env.BoostUnitTest('test', tests) SENFSCons.Doxygen(env) - -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) - -SENFSCons.Binary(env, "telnetServer", ['telnetServer.cc']) +env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +env.Program('telnetSserver', ['telnetServer.cc']) diff --git a/debian/SConscript b/debian/SConscript index 7069259..548c560 100644 --- a/debian/SConscript +++ b/debian/SConscript @@ -88,19 +88,19 @@ env.Replace( BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot $DPKG_IGNORED_FILES_OPTS", ) -SENFSCons.PhonyTarget(env, 'deb', [ +env.PhonyTarget('deb', [], [ checkLocalConf, updateRevision, "$BUILDPACKAGE_COMMAND", "fakeroot ./debian/rules debclean" ]) -SENFSCons.PhonyTarget(env, 'debsrc', [ +env.PhonyTarget('debsrc', [], [ updateRevision, "$BUILDPACKAGE_COMMAND -S", ]) -SENFSCons.PhonyTarget(env, 'debbin', [ +env.PhonyTarget('debbin', [], [ checkLocalConf, updateRevision, "$BUILDPACKAGE_COMMAND -b", diff --git a/doclib/SConscript b/doclib/SConscript index 696fc27..9fbf7d9 100644 --- a/doclib/SConscript +++ b/doclib/SConscript @@ -283,7 +283,7 @@ env.Replace( DOXYGENCOM = "doclib/doxygen.sh $DOXYOPTS $SOURCE", ) -SENFSCons.PhonyTarget(env, 'linklint', [ +env.PhonyTarget('linklint', [], [ 'rm -rf linklint', 'linklint -doc linklint -limit 99999999 `find -type d -name html -printf "/%P/@ "`', '[ ! -r linklint/errorX.html ] || python doclib/linklint_addnames.py linklint/errorX.html.new', @@ -293,9 +293,7 @@ SENFSCons.PhonyTarget(env, 'linklint', [ 'echo -e "\\nLokal link check results: linklint/index.html\\nRemote link check results: linklint/urlindex.html\\n"', ]) -env.Clean('all', env.Dir('linklint')) - -SENFSCons.PhonyTarget(env, 'fixlinks', [ +env.PhonyTarget('fixlinks', [], [ 'python doclib/fix-links.py -v -s .svn -s linklint -s debian linklint/errorX.txt linklint/errorAX.txt', ]) diff --git a/senfscons/Boost.py b/senfscons/Boost.py index 058efc5..4e07ac3 100644 --- a/senfscons/Boost.py +++ b/senfscons/Boost.py @@ -1,4 +1,113 @@ -# Provide environment variables for boost libraries +import SCons.Script +import SCons.Script.SConscript +import SCons.Defaults +import os.path +import os +import sys +import tempfile +import SCons.Scanner.C + +# ARGH ... Why do they put a '+' in the module name ???????? +SCons.Tool.cplusplus=getattr(__import__('SCons.Tool.c++', globals(), locals(), []).Tool, 'c++') + +_ALL_TESTS = [] + +def scanTests(f): + tests = {} + name = start = None + linenr= 0 + for line in f: + linenr += 1 + if line.startswith('COMPILE_FAIL(') and ')' in line: + name = line.split('(',1)[-1].split(')',1)[0] + start = linenr + elif line.startswith('}') and name and start: + tests[name] = (start, linenr) + return tests + +def CompileCheck(target, source, env): + tests = scanTests(file(source[0].abspath)) + cenv = env.Clone() + cenv.Append( CPPDEFINES = [ 'COMPILE_CHECK' ] ) + out = tempfile.TemporaryFile() + cenv['SPAWN'] = lambda sh, escape, cmd, args, env, pspawn=cenv['PSPAWN'], out=out: \ + pspawn(sh, escape, cmd, args, env, out, out) + SCons.Script.Action('$CXXCOM').execute(target, source, cenv) + passedTests = {} + delay_name = None + out.seek(0) + for error in out.read().splitlines(): + elts = error.split(':',2) + if len(elts) != 3 : continue + filename, line, message = elts + if not os.path.exists(filename) : continue + try: line = int(line) + except ValueError : continue + message = message.strip() + + if delay_name and not message.startswith('instantiated from '): + print "Passed test '%s': %s" % (delay_name, message) + delay_name = None + continue + + filename = os.path.abspath(filename) + if filename != source[0].abspath : continue + + for name,lines in tests.iteritems(): + if line >= lines[0] and line <= lines[1]: + passedTests[name] = 1 + if message.startswith('instantiated from '): + delay_name = name + else: + print "Passed test '%s': %s" % (name, message) + if delay_name: + print "Passed test '%s': " % delay_name + failedTests = set(tests.iterkeys()) - set(passedTests.iterkeys()) + if failedTests: + for test in failedTests: + print "Test '%s' FAILED" % test + print + print "*** %d tests FAILED" % len(failedTests) + if os.path.exists(target[0].abspath): + os.unlink(target[0].abspath) + return 1 + file(target[0].abspath,"w").close() + return 0 + +CompileCheck = SCons.Script.Action(CompileCheck) + +def BoostUnitTest(env, target=None, source=None, **kw): + target = env.arg2nodes(target)[0] + source = env.arg2nodes(source) + + 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) + + alias = env.Command(env.File(target), stamp, []) + + 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() ] + if compileTests: + env.Depends(alias, env.CompileCheck(source = compileTests)) + + _ALL_TESTS.append(alias) + + return alias + +def FindAllBoostUnitTests(env, target, source): + return _ALL_TESTS def generate(env): env.SetDefault( @@ -9,7 +118,19 @@ def generate(env): BOOSTFSLIB = 'boost_filesystem$BOOST_VARIANT', BOOSTIOSTREAMSLIB = 'boost_iostreams$BOOST_VARIANT', BOOSTSIGNALSLIB = 'boost_signals$BOOST_VARIANT', + + BOOSTTESTARGS = [ '--build_info=yes', '--log_level=test_suite' ], ) + env['BUILDERS']['BoostUnitTest'] = BoostUnitTest + env['BUILDERS']['FindAllBoostUnitTests'] = FindAllBoostUnitTests + env['BUILDERS']['CompileCheck'] = env.Builder( + action = CompileCheck, + suffix = '.checked', + src_suffix = '.cc', + source_scanner = SCons.Scanner.C.CScanner(), + single_source=1 + ) + def exists(env): return True diff --git a/senfscons/BoostUnitTest.py b/senfscons/BoostUnitTest.py deleted file mode 100644 index 2984fbe..0000000 --- a/senfscons/BoostUnitTest.py +++ /dev/null @@ -1,66 +0,0 @@ -## \file -# \brief BoostUnitTests build - -## \package senfscons.BoostUnitTests -# \brief Builder utilizing the Boost.Test unit-test framework -# -# The BoostUnitTests builder will build a unit-test executable using -# the Boost.Test -# library. After building, the unit-test will be executed. -# -# This builder is used by the SENFSCons.Object() helper to build the -# unit test. -# -# \par Construction Envrionment Variables: -# -# -# -#
\c BOOSTTESTLIBName of the library to use, defaults to \c boost_unit_test_framework
\c BOOSTTESTARGSCommand line arguments of the test, defaults to --build_info=yes --log_level=test_suite
-# -# \todo This is not really a builder. This should be rewritten as one -# \ingroup builder - -import SCons.Script.SConscript -import SCons.Defaults -import os.path -import os - -# ARGH ... Why do they put a '+' in the module name ???????? -SCons.Tool.cplusplus=getattr(__import__('SCons.Tool.c++', globals(), locals(), []).Tool, 'c++') - -def BoostUnitTest(env, target=None, source=None, **kw): - target = env.arg2nodes(target)[0] - source = env.arg2nodes(source) - - 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) - - alias = env.Command(env.File(target), stamp, [ 'true' ]) - - 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() ] - if compileTests: - env.Depends(alias, env.CompileCheck(source = compileTests)) - - return alias - -def generate(env): - env['BOOSTTESTLIB'] = 'boost_unit_test_framework' - env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ] - env['BUILDERS']['BoostUnitTest'] = BoostUnitTest - -def exists(env): - return 1 diff --git a/senfscons/CombinedObject.py b/senfscons/CombinedObject.py new file mode 100644 index 0000000..eaf3ce1 --- /dev/null +++ b/senfscons/CombinedObject.py @@ -0,0 +1,16 @@ + +def generate(env): + + builder = env.Builder( + action = [ '$LDCOMBINECOM $TARGET $SOURCES' ], + suffix = '.o', + ensure_suffix = 1, + src_suffix = '.o', + src_builder = 'Object') + + env['BUILDERS']['CombinedObject'] = builder + + env.SetDefault(LDCOMBINECOM = 'ld -r -o') + +def exists(env): + return True diff --git a/senfscons/CompileCheck.py b/senfscons/CompileCheck.py deleted file mode 100644 index 5972bdf..0000000 --- a/senfscons/CompileCheck.py +++ /dev/null @@ -1,83 +0,0 @@ -import os, os.path, sys -import tempfile -from SCons.Script import * -import SCons.Scanner.C - -def scanTests(f): - tests = {} - name = start = None - linenr= 0 - for line in f: - linenr += 1 - if line.startswith('COMPILE_FAIL(') and ')' in line: - name = line.split('(',1)[-1].split(')',1)[0] - start = linenr - elif line.startswith('}') and name and start: - tests[name] = (start, linenr) - return tests - -def CompileCheck(target, source, env): - tests = scanTests(file(source[0].abspath)) - cenv = env.Clone() - cenv.Append( CPPDEFINES = [ 'COMPILE_CHECK' ] ) - out = tempfile.TemporaryFile() - cenv['SPAWN'] = lambda sh, escape, cmd, args, env, pspawn=cenv['PSPAWN'], out=out: \ - pspawn(sh, escape, cmd, args, env, out, out) - Action('$CXXCOM').execute(target, source, cenv) - passedTests = {} - delay_name = None - out.seek(0) - for error in out.read().splitlines(): - elts = error.split(':',2) - if len(elts) != 3 : continue - filename, line, message = elts - if not os.path.exists(filename) : continue - try: line = int(line) - except ValueError : continue - message = message.strip() - - if delay_name and not message.startswith('instantiated from '): - print "Passed test '%s': %s" % (delay_name, message) - delay_name = None - continue - - filename = os.path.abspath(filename) - if filename != source[0].abspath : continue - - for name,lines in tests.iteritems(): - if line >= lines[0] and line <= lines[1]: - passedTests[name] = 1 - if message.startswith('instantiated from '): - delay_name = name - else: - print "Passed test '%s': %s" % (name, message) - if delay_name: - print "Passed test '%s': " % delay_name - failedTests = set(tests.iterkeys()) - set(passedTests.iterkeys()) - if failedTests: - for test in failedTests: - print "Test '%s' FAILED" % test - print - print "*** %d tests FAILED" % len(failedTests) - if os.path.exists(target[0].abspath): - os.unlink(target[0].abspath) - return 1 - file(target[0].abspath,"w").close() - return 0 - -CompileCheck = Action(CompileCheck) - -def generate(env): - - builder = env.Builder( - action = CompileCheck, - suffix = '.checked', - src_suffix = '.cc', - source_scanner = SCons.Scanner.C.CScanner(), - single_source=1 - ) - - env.Append(BUILDERS = { 'CompileCheck': builder }) - -def exists(env): - return True diff --git a/senfscons/CopyToDir.py b/senfscons/CopyToDir.py index 7f001ef..c55d1de 100644 --- a/senfscons/CopyToDir.py +++ b/senfscons/CopyToDir.py @@ -10,11 +10,15 @@ import os.path import SCons.Builder, SCons.Defaults def emitter(source, target, env): - return ([ os.path.join(str(target[0]),source[0].name) ], source) + source = env.arg2nodes(source, env.fs.File) + target = env.arg2nodes(target, env.fs.Dir) + return ([ target[0].File(src.name) for src in source ], source) + +def generator(source, target, env, for_signature): + return [ SCons.Defaults.Copy(t, s) for s, t in zip(source, target) ] CopyToDir = SCons.Builder.Builder(emitter = emitter, - action = SCons.Defaults.Copy("$TARGET","$SOURCE"), - single_source = True) + generator = generator) def generate(env): env['BUILDERS']['CopyToDir'] = CopyToDir diff --git a/senfscons/PhonyTarget.py b/senfscons/PhonyTarget.py new file mode 100644 index 0000000..3b9fbca --- /dev/null +++ b/senfscons/PhonyTarget.py @@ -0,0 +1,9 @@ + +def PhonyTarget(env, target, source = None, action = None): + return env.AlwaysBuild(env.Alias(target, source, env.Action(action))) + +def generate(env): + env['BUILDERS']['PhonyTarget'] = PhonyTarget + +def exists(env): + return True diff --git a/senfscons/PkgDraw.py b/senfscons/PkgDraw.py index 38cc49d..5cd0989 100644 --- a/senfscons/PkgDraw.py +++ b/senfscons/PkgDraw.py @@ -27,7 +27,7 @@ PkgDraw = SCons.Builder.Builder( def generate(env): env['BUILDERS']['PkgDraw'] = PkgDraw - env['PKGDRAW'] = "doclib/pkgdraw" + env['PKGDRAW'] = "pkgdraw" env['PKGDRAWCOM'] = "$PKGDRAW $SOURCE $TARGET $PKGDRAWPACKETS -- $CPPFLAGS $_CPPINCFLAGS $_CPPDEFFLAGS" env['PKGDRAWPACKETS'] = '' diff --git a/senfscons/SConstruct.template b/senfscons/SConstruct.template deleted file mode 100644 index ae815e6..0000000 --- a/senfscons/SConstruct.template +++ /dev/null @@ -1,20 +0,0 @@ -import sys, glob -sys.path.append('senfscons') -import SENFSCons - -########################################################################### - -SENFSCons.UseBoost(); -SENFSCons.UseSTLPort(); -env = SENFSCons.MakeEnvironment(); - -env.Append( - CPPPATH = [ '#' ] -) - -Export('env') - -SConscript(glob.glob("*/SConscript")) - -SENFSCons.StandardTargets(env) -SENFSCons.GlobalTargets(env) diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index e385a94..bdb44f0 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -3,16 +3,13 @@ import SCons.Options, SCons.Environment, SCons.Script.SConscript, SCons.Node.FS import SCons.Defaults, SCons.Action from SCons.Script import * -def GlobSources(env, exclude=[], subdirs=[]): +def Glob(env, exclude=[], subdirs=[]): testSources = glob.glob("*.test.cc") sources = [ x for x in glob.glob("*.cc") if x not in testSources and x not in exclude ] for subdir in subdirs: testSources += glob.glob(os.path.join(subdir,"*.test.cc")) sources += [ x for x in glob.glob(os.path.join(subdir,"*.cc")) if x not in testSources and x not in exclude ] - return (sources, testSources) - -def GlobIncludes(env, exclude=[], subdirs=[]): includes = [] for d in [ '.' ] + subdirs: for f in os.listdir(d): @@ -22,30 +19,7 @@ def GlobIncludes(env, exclude=[], subdirs=[]): and ext not in env['CPP_EXCLUDE_EXTENSIONS'] \ and p not in exclude: includes.append(p) - return includes - -def Glob(env, exclude=[], subdirs=[]): - return ( GlobSources(env, exclude, subdirs), - GlobIncludes(env, exclude, subdirs) ) - -def Test(env, sources): - test=env.BoostUnitTest( target = 'test', source = sources ) - env.Alias('all_tests', test) - return test - -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 = env.Object(sources) - - if testSources: - Test(env, testSources) - - return objects + return ( sources, testSources, includes ) def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): # There is one small problem we need to solve with this builder: The Doxygen builder reads @@ -57,8 +31,8 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): # Module name is derived from the doxyfile path # Utils/Console/Doxyfile -> Utils_Console - module = doxyfile.dir.abspath[len(env.Dir('#').abspath)+1:].replace('/','_') - if not module : module = "Main" + module = doxyfile.dir.get_path(env.Dir('#')).replace('/','_') + if module == '.' : module = "Main" # Rule to generate tagfile # (need to exclude the 'clean' case, otherwise we'll have duplicate nodes) @@ -92,15 +66,11 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): # (need to exclude the 'clean' case otherwise there are multiple ways to clean the copies) if not env.GetOption('clean'): if extra_sources: - env.Depends(doc, - [ env.CopyToDir( source=source, target=doc[0].dir ) - for source in extra_sources ]) + env.Depends(doc, env.CopyToDir(doc[0].dir, extra_sources)) # Install documentation into DOCINSTALLDIR l = len(env.Dir('#').abspath) - env.Alias('install_all', - env.Command('$DOCINSTALLDIR' + doc[0].dir.abspath[l:], doc[0].dir, - [ SCons.Defaults.Copy('$TARGET','$SOURCE') ])) + env.Install(env.Dir('$DOCINSTALLDIR').Dir(doc[0].dir.get_path('#')), doc[0].dir) # Useful aliases env.Alias('all_docs', doc) @@ -109,36 +79,9 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): return doc -def Lib(env, sources, testSources = None, 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) - 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) - program = env.Program(target = binary, - source = objects+OBJECTS, - LIBS = [ '$LIBSENF$LIBADDSUFFIX' ] + env['LIBS']) - env.Default(program) - env.Alias('default', program) - env.Alias('install_all', env.Install('$BININSTALLDIR', program)) - return program - def AllIncludesHH(env, headers): headers.sort() target = env.File("all_includes.hh") file(target.abspath,"w").write("".join([ '#include "%s"\n' % f for f in headers ])) env.Clean('all', target) - -def PhonyTarget(env, target, action, sources=[]): - env.AlwaysBuild(env.Alias(target, sources, env.Action(action))) diff --git a/senfscons/functions.xsl b/senfscons/functions.xsl deleted file mode 100644 index b711cc3..0000000 --- a/senfscons/functions.xsl +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - ERROR: EXSLT - Functions implementation of str:split relies on exsl:node-set(). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: function implementation of str:replace() relies on exsl:node-set(). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/senfscons/xrefhtml.xslt b/senfscons/xrefhtml.xslt deleted file mode 100644 index b9c6e7c..0000000 --- a/senfscons/xrefhtml.xslt +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - -
-

- - - - - - - - - -

Open s

-
- - -

module

-
- -
-
-
-
-
-
-
- - -
- - - - -
-
- -
-
- - -

-
- - - - - - - _1_1 - _2 - - - - - - - - - - - - - - - - - ../..//doc/html/.html - - -
diff --git a/senfscons/xrefxtract.xslt b/senfscons/xrefxtract.xslt deleted file mode 100644 index 8a79414..0000000 --- a/senfscons/xrefxtract.xslt +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -