From: g0dil Date: Fri, 21 Aug 2009 15:13:11 +0000 (+0000) Subject: Add SENFSCons.AutoRules and SENFSCons.AutoPacketBundle macro-like functions X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=f61cca07c36ee2571ed19ef5d33142c537396a6d;p=senf.git Add SENFSCons.AutoRules and SENFSCons.AutoPacketBundle macro-like functions git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1324 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/SConscript b/senf/PPI/SConscript index d74fc60..6d5dcac 100644 --- a/senf/PPI/SConscript +++ b/senf/PPI/SConscript @@ -1,23 +1,13 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -SConscript(glob.glob("*/SConscript")) - SENFSCons.AllIncludesHH(env, exclude = ['PPI.hh']) - -sources, tests, includes = SENFSCons.Glob(env, subdirs=[ 'detail' ]) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) - -SENFSCons.Doxygen(env, extra_sources=[ - env.Dia2Png('scenario.dia'), - env.Dia2Png('classes.dia'), - env.Dia2Png('ratestuffer.dia'), +SENFSCons.AutoRules(env, subdirs=['detail'], doc_extra_sources=[ + env.Dia2Png('scenario.dia'), + env.Dia2Png('classes.dia'), + env.Dia2Png('ratestuffer.dia'), ]) - -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/senf/Packets/80211Bundle/SConscript b/senf/Packets/80211Bundle/SConscript index 67f430b..9f77b74 100644 --- a/senf/Packets/80211Bundle/SConscript +++ b/senf/Packets/80211Bundle/SConscript @@ -1,20 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -objects = env.Object(sources) -cobject = env.CombinedObject('80211Bundle', objects) -env.Default(cobject) -env.Append(ALLOBJECTS = objects) -env.Append(PACKET_BUNDLES = cobject) -env.BoostUnitTest('test', tests + cobject) - -env.Install('$OBJINSTALLDIR', cobject) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) - -SConscript(glob.glob("*/SConscript")) +SENFSCons.AutoPacketBundle(env, '80211Bundle') diff --git a/senf/Packets/80221Bundle/SConscript b/senf/Packets/80221Bundle/SConscript index f58e4ec..7372e6c 100644 --- a/senf/Packets/80221Bundle/SConscript +++ b/senf/Packets/80221Bundle/SConscript @@ -1,20 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -objects = env.Object(sources) -cobject = env.CombinedObject('80221Bundle', objects) -env.Default(cobject) -env.Append(ALLOBJECTS = objects) -env.Append(PACKET_BUNDLES = cobject) -env.BoostUnitTest('test', tests + cobject) - -env.Install('$OBJINSTALLDIR', cobject) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) - -SConscript(glob.glob("*/SConscript")) +SENFSCons.AutoPacketBundle(env, '80221Bundle') diff --git a/senf/Packets/DefaultBundle/SConscript b/senf/Packets/DefaultBundle/SConscript index ac477bd..71fef2c 100644 --- a/senf/Packets/DefaultBundle/SConscript +++ b/senf/Packets/DefaultBundle/SConscript @@ -1,20 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -objects = env.Object(sources) -cobject = env.CombinedObject('DefaultBundle', objects) -env.Default(cobject) -env.Append(ALLOBJECTS = objects) -env.Append(PACKET_BUNDLES = cobject) -env.BoostUnitTest('test', tests + cobject) - -env.Install('$OBJINSTALLDIR', cobject) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) - -SConscript(glob.glob("*/SConscript")) +SENFSCons.AutoPacketBundle(env, 'DefaultBundle') diff --git a/senf/Packets/DefaultBundle/extra_tests/SConscript b/senf/Packets/DefaultBundle/extra_tests/SConscript index 320bffd..e926ea5 100644 --- a/senf/Packets/DefaultBundle/extra_tests/SConscript +++ b/senf/Packets/DefaultBundle/extra_tests/SConscript @@ -1,8 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -env.BoostUnitTest('test', glob.glob("*.test.cc")) +SENFSCons.AutoRules(env) diff --git a/senf/Packets/MPEGDVBBundle/SConscript b/senf/Packets/MPEGDVBBundle/SConscript index dc1151d..976c1c0 100644 --- a/senf/Packets/MPEGDVBBundle/SConscript +++ b/senf/Packets/MPEGDVBBundle/SConscript @@ -5,14 +5,4 @@ import SENFSCons, glob ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -objects = env.Object(sources) -cobject = env.CombinedObject('MPEGDVBBundle', objects) -env.Default(cobject) -env.Append(ALLOBJECTS = objects) -env.Append(PACKET_BUNDLES = cobject) -env.BoostUnitTest('test', tests + cobject) - -env.Install('$OBJINSTALLDIR', cobject) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoPacketBundle(env, 'MPEGDVBBundle') diff --git a/senf/Packets/SConscript b/senf/Packets/SConscript index 41d317a..290af21 100644 --- a/senf/Packets/SConscript +++ b/senf/Packets/SConscript @@ -1,16 +1,11 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) - -SENFSCons.Doxygen(env, extra_sources = [ +SENFSCons.AutoRules(env, doc_extra_sources = [ env.Dia2Png("structure.dia"), env.Dia2Png("80221Bundle/TLV.dia"), env.PkgDraw("MPEGDVBBundle/DTCPPacket.hh"), @@ -60,7 +55,3 @@ SENFSCons.Doxygen(env, extra_sources = [ env.PkgDraw("MPEGDVBBundle/TransportPacket.hh"), ]) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) - -SConscript(glob.glob("*/SConscript")) - diff --git a/senf/Scheduler/SConscript b/senf/Scheduler/SConscript index a91f80a..e926ea5 100644 --- a/senf/Scheduler/SConscript +++ b/senf/Scheduler/SConscript @@ -5,9 +5,4 @@ import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Socket/Protocols/DVB/SConscript b/senf/Socket/Protocols/DVB/SConscript index abbb591..46a1024 100644 --- a/senf/Socket/Protocols/DVB/SConscript +++ b/senf/Socket/Protocols/DVB/SConscript @@ -1,16 +1,9 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -SConscript(glob.glob("*/SConscript")) - SENFSCons.AllIncludesHH(env, exclude=['DVB.hh']) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Socket/Protocols/INet/SConscript b/senf/Socket/Protocols/INet/SConscript index 4ef2133..af008b9 100644 --- a/senf/Socket/Protocols/INet/SConscript +++ b/senf/Socket/Protocols/INet/SConscript @@ -5,12 +5,5 @@ import SENFSCons, glob ########################################################################### -SConscript(glob.glob("*/SConscript")) - SENFSCons.AllIncludesHH(env, exclude=['INet.hh']) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Socket/Protocols/Raw/SConscript b/senf/Socket/Protocols/Raw/SConscript index a75c754..245f102 100644 --- a/senf/Socket/Protocols/Raw/SConscript +++ b/senf/Socket/Protocols/Raw/SConscript @@ -1,16 +1,9 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -SConscript(glob.glob("*/SConscript")) - SENFSCons.AllIncludesHH(env, exclude=['Raw.hh']) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Socket/Protocols/SConscript b/senf/Socket/Protocols/SConscript index a55a9e0..e926ea5 100644 --- a/senf/Socket/Protocols/SConscript +++ b/senf/Socket/Protocols/SConscript @@ -1,14 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -SConscript(glob.glob("*/SConscript")) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Socket/Protocols/UN/SConscript b/senf/Socket/Protocols/UN/SConscript index 33e12ac..092a64c 100644 --- a/senf/Socket/Protocols/UN/SConscript +++ b/senf/Socket/Protocols/UN/SConscript @@ -1,16 +1,9 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -SConscript(glob.glob("*/SConscript")) - SENFSCons.AllIncludesHH(env, exclude=['UN.hh']) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Socket/SConscript b/senf/Socket/SConscript index 2e9bd62..caf98a0 100644 --- a/senf/Socket/SConscript +++ b/senf/Socket/SConscript @@ -1,23 +1,15 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -SConscript(glob.glob("*/SConscript")) - SENFSCons.AllIncludesHH(env, exclude=['Socket.hh']) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env, extra_sources = [ +SENFSCons.AutoRules(env, doc_extra_sources = [ env.Dia2Png('SocketLibrary-classes.dia'), env.Dia2Png('FhHierarchy.dia'), env.Dia2Png('SocketPolicy.dia'), env.Dia2Png('Protocols.dia'), env.Dia2Png('Handle.dia'), ]) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) diff --git a/senf/Utils/Console/SConscript b/senf/Utils/Console/SConscript index dfcac7b..b2a85f3 100644 --- a/senf/Utils/Console/SConscript +++ b/senf/Utils/Console/SConscript @@ -5,10 +5,5 @@ import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env, exclude=['testServer.cc']) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env, exclude=['testServer.cc']) env.Program('testServer', ['testServer.cc']) diff --git a/senf/Utils/Daemon/SConscript b/senf/Utils/Daemon/SConscript index 9c34fd8..e926ea5 100644 --- a/senf/Utils/Daemon/SConscript +++ b/senf/Utils/Daemon/SConscript @@ -1,13 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Utils/Logger/SConscript b/senf/Utils/Logger/SConscript index dd2bd23..c3eba01 100644 --- a/senf/Utils/Logger/SConscript +++ b/senf/Utils/Logger/SConscript @@ -1,15 +1,9 @@ # -*- python -*- Import('env') -import SENFSCons, glob +import SENFSCons ########################################################################### SENFSCons.AllIncludesHH(env, exclude=['Logger.hh','SenfLog.hh']) - -sources, tests, includes = SENFSCons.Glob(env) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env) diff --git a/senf/Utils/SConscript b/senf/Utils/SConscript index 7181097..a8076fa 100644 --- a/senf/Utils/SConscript +++ b/senf/Utils/SConscript @@ -1,15 +1,8 @@ # -*- python -*- Import('env') -import SENFSCons, glob, os.path +import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env, subdirs=[ 'impl' ]) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) - -SConscript(glob.glob("*/SConscript")) +SENFSCons.AutoRules(env, subdirs=['impl']) diff --git a/senf/Utils/Termlib/SConscript b/senf/Utils/Termlib/SConscript index 9d1978a..2768772 100644 --- a/senf/Utils/Termlib/SConscript +++ b/senf/Utils/Termlib/SConscript @@ -5,10 +5,5 @@ import SENFSCons ########################################################################### -sources, tests, includes = SENFSCons.Glob(env, exclude=[ 'telnetServer.cc']) - -env.Append(ALLOBJECTS = env.Object(sources)) -env.BoostUnitTest('test', tests) -SENFSCons.Doxygen(env) -env.InstallSubdir('$INCLUDEINSTALLDIR', includes) +SENFSCons.AutoRules(env, exclude=[ 'telnetServer.cc']) env.Program('telnetServer', ['telnetServer.cc']) diff --git a/site_scons/SENFSCons.py b/site_scons/SENFSCons.py index 6c4bdb3..87e0bbd 100644 --- a/site_scons/SENFSCons.py +++ b/site_scons/SENFSCons.py @@ -90,3 +90,41 @@ def AllIncludesHH(env, exclude=[]): file(target.abspath,"w").write("".join([ '#include "%s"\n' % f for f in headers ])) env.Clean('all', target) + +########################################################################### +# The following functions serve as simple macros for most SConscript files +# +# If you need to customize these rules, copy-and-paste the code into the +# SConscript file and adjust at will (don't to forget to replace the +# parameters with their actual value. Parameters are marked with ((name)) ) + +def AutoRules(env, exclude=[], subdirs=[], doc_extra_sources = []): + import SENFSCons, glob, os.path + + sources, tests, includes = SENFSCons.Glob(env, exclude=((exclude)), subdirs=((subdirs)) ) + subscripts = glob.glob("*/SConscript") + + if sources : env.Append(ALLOBJECTS = env.Object(sources)) + if tests : env.BoostUnitTest('test', tests) + if includes : env.InstallSubdir('$INCLUDEINSTALLDIR', includes) + if os.path.exists("Doxyfile") : SENFSCons.Doxygen(env, extra_sources=((doc_extra_sources)) ) + if subscripts : SConscript(glob.glob("*/SConscript")) + + +def AutoPacketBundle(env, name, exclude=[], subdirs=[], doc_extra_sources=[]): + import SENFSCons, glob, os.path + + sources, tests, includes = SENFSCons.Glob(env, exclude=((exclude)), subdirs=((subdirs)) ) + subscripts = glob.glob("*/SConscript") + + objects = env.Object(sources) + cobject = env.CombinedObject(name, objects) + + env.Default(cobject) + env.Append(ALLOBJECTS = objects, PACKET_BUNDLES = cobject) + env.Install('$OBJINSTALLDIR', cobject) + + if tests : env.BoostUnitTest('test', tests + cobject) + if includes : env.InstallSubdir('$INCLUDEINSTALLDIR', includes) + if os.path.exists("Doxyfile") : SENFSCons.Doxygen(env, extra_sources=((doc_extra_sources)) ) + if subscripts : SConscript(glob.glob("*/SConscript"))