From: g0dil Date: Thu, 20 Aug 2009 08:27:31 +0000 (+0000) Subject: Replace SENFSCons.InstallIncludeFiles with InstallSubdir builder calls X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=b1f9349b1f3521d58cbef52ead0f2e5303a58c9e;p=senf.git Replace SENFSCons.InstallIncludeFiles with InstallSubdir builder calls git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1309 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/.gitignore b/.gitignore index f3de496..f83fefe 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,8 @@ *.test.checked .sconsign* *~ -#*# +*# +.#* # File names to ignore in all directories all_includes.hh diff --git a/PPI/SConscript b/PPI/SConscript index b7ee214..c0aedb7 100644 --- a/PPI/SConscript +++ b/PPI/SConscript @@ -17,4 +17,4 @@ SENFSCons.Doxygen(env, extra_sources=[ env.Dia2Png('classes.dia'), env.Dia2Png('ratestuffer.dia'), ]) -SENFSCons.InstallIncludeFiles(env, includes) +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Packets/80211Bundle/SConscript b/Packets/80211Bundle/SConscript index ac31522..8aa9f69 100644 --- a/Packets/80211Bundle/SConscript +++ b/Packets/80211Bundle/SConscript @@ -9,6 +9,7 @@ sources, includes = SENFSCons.Glob(env) SENFSCons.Object(env, target='80211Bundle', sources=sources) SENFSCons.Lib(env, sources=sources[0]) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) SConscript(glob.glob("*/SConscript")) diff --git a/Packets/DefaultBundle/SConscript b/Packets/DefaultBundle/SConscript index 47b7a11..c91e6e8 100644 --- a/Packets/DefaultBundle/SConscript +++ b/Packets/DefaultBundle/SConscript @@ -9,6 +9,7 @@ sources, includes = SENFSCons.Glob(env) SENFSCons.Object(env, target='DefaultBundle', sources=sources) SENFSCons.Lib(env, sources[0]) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) SConscript(glob.glob("*/SConscript")) diff --git a/Packets/MPEGDVBBundle/SConscript b/Packets/MPEGDVBBundle/SConscript index 654bbe5..b661eca 100644 --- a/Packets/MPEGDVBBundle/SConscript +++ b/Packets/MPEGDVBBundle/SConscript @@ -9,4 +9,5 @@ sources, includes = SENFSCons.Glob(env) SENFSCons.Object(env, target='MPEGDVBBundle', sources=sources) SENFSCons.Lib(env, sources[0]) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Packets/SConscript b/Packets/SConscript index 55bf07c..69d353b 100644 --- a/Packets/SConscript +++ b/Packets/SConscript @@ -57,7 +57,8 @@ SENFSCons.Doxygen(env, extra_sources = [ env.PkgDraw("MPEGDVBBundle/SNDUPacket.hh"), env.PkgDraw("MPEGDVBBundle/TransportPacket.hh"), ]) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) SConscript(glob.glob("*/SConscript")) diff --git a/SConstruct b/SConstruct index 92a4078..c8e0d45 100644 --- a/SConstruct +++ b/SConstruct @@ -18,11 +18,12 @@ env.Tool('CopyToDir', [ 'senfscons' ]) env.Tool('CompileCheck', [ 'senfscons' ]) env.Tool('Boost', [ 'senfscons' ]) env.Tool('BoostUnitTests', [ 'senfscons' ]) +env.Tool('InstallSubdir', [ 'senfscons' ]) env.Help(""" Additional top-level build targets: -prepare Create all source files not part of the repository +prepare Create all target files not part of the repository all_tests Build and run unit tests for all modules all_docs Build documentation for all modules all Build everything @@ -39,7 +40,7 @@ class BuildTypeOptions: def __init__(self, var): self._var = var - def __call__(self, source, target, env, for_signature): + def __call__(self, target, source, env, for_signature): type = env['final'] and "final" or env['debug'] and "debug" or "normal" return env[self._var + "_" + type] @@ -147,7 +148,8 @@ env.Default(libsenf) env.Clean('all', libsenf) env.Alias('default', libsenf) -SENFSCons.InstallIncludeFiles(env, [ 'config.hh' ]) +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = [ 'config.hh' ]) + env.Alias('install_all', env.Install('$LIBINSTALLDIR', libsenf)) if env.GetOption('clean'): diff --git a/Scheduler/SConscript b/Scheduler/SConscript index 7310390..6113f90 100644 --- a/Scheduler/SConscript +++ b/Scheduler/SConscript @@ -9,4 +9,5 @@ sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Socket/Protocols/DVB/SConscript b/Socket/Protocols/DVB/SConscript index 0b56081..6f982f3 100644 --- a/Socket/Protocols/DVB/SConscript +++ b/Socket/Protocols/DVB/SConscript @@ -13,4 +13,5 @@ SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Socket/Protocols/INet/SConscript b/Socket/Protocols/INet/SConscript index e48d809..9e27f8b 100644 --- a/Socket/Protocols/INet/SConscript +++ b/Socket/Protocols/INet/SConscript @@ -13,4 +13,5 @@ SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Socket/Protocols/Raw/SConscript b/Socket/Protocols/Raw/SConscript index 7c58379..83b578b 100644 --- a/Socket/Protocols/Raw/SConscript +++ b/Socket/Protocols/Raw/SConscript @@ -13,4 +13,5 @@ SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Socket/Protocols/SConscript b/Socket/Protocols/SConscript index dee839e..3346cec 100644 --- a/Socket/Protocols/SConscript +++ b/Socket/Protocols/SConscript @@ -9,4 +9,5 @@ SConscript(glob.glob("*/SConscript")) sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Socket/Protocols/UN/SConscript b/Socket/Protocols/UN/SConscript index 021bbe6..6c79bf3 100644 --- a/Socket/Protocols/UN/SConscript +++ b/Socket/Protocols/UN/SConscript @@ -13,4 +13,5 @@ SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh") sources, includes = SENFSCons.Glob(env) SENFSCons.Lib( env, sources) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Socket/SConscript b/Socket/SConscript index 0e7b440..5206292 100644 --- a/Socket/SConscript +++ b/Socket/SConscript @@ -20,4 +20,5 @@ SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png('Protocols.dia'), env.Dia2Png('Handle.dia'), ]) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Utils/Console/SConscript b/Utils/Console/SConscript index 026e3c2..5303f1a 100644 --- a/Utils/Console/SConscript +++ b/Utils/Console/SConscript @@ -9,5 +9,7 @@ sources, includes = SENFSCons.Glob(env, exclude=['testServer.cc']) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) + SENFSCons.Binary(env, "testServer", ['testServer.cc']) diff --git a/Utils/Daemon/SConscript b/Utils/Daemon/SConscript index 1b7e8fe..77967ed 100644 --- a/Utils/Daemon/SConscript +++ b/Utils/Daemon/SConscript @@ -9,4 +9,5 @@ sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Utils/Logger/SConscript b/Utils/Logger/SConscript index a3803c6..bb4f897 100644 --- a/Utils/Logger/SConscript +++ b/Utils/Logger/SConscript @@ -13,4 +13,5 @@ sources, includes = SENFSCons.Glob(env) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) diff --git a/Utils/SConscript b/Utils/SConscript index a39548a..ef0872c 100644 --- a/Utils/SConscript +++ b/Utils/SConscript @@ -9,6 +9,7 @@ sources, includes = SENFSCons.Glob(env, subdirs=[ 'impl' ]) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) SConscript(glob.glob("*/SConscript")) diff --git a/Utils/Termlib/SConscript b/Utils/Termlib/SConscript index ffacf97..5f77839 100644 --- a/Utils/Termlib/SConscript +++ b/Utils/Termlib/SConscript @@ -9,5 +9,7 @@ sources, includes = SENFSCons.Glob(env, exclude=[ 'telnetServer.cc']) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env) -SENFSCons.InstallIncludeFiles(env, includes) + +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = includes) + SENFSCons.Binary(env, "telnetServer", ['telnetServer.cc']) diff --git a/senfscons/InstallSubdir.py b/senfscons/InstallSubdir.py new file mode 100644 index 0000000..d76a512 --- /dev/null +++ b/senfscons/InstallSubdir.py @@ -0,0 +1,17 @@ +import SCons.Errors + +def InstallSubdir(env, target=None, source=None, base='#', **kw): + builds = [] + target = env.arg2nodes(target, env.fs.Dir) + if len(target) != 1: + raise SCons.Errors.UserError, "Need exactly one target for InstallWithDir()" + base = env.arg2nodes(base, env.fs.Dir)[0] + for src in env.arg2nodes(source, env.fs.Entry): + builds.extend(apply(env.Install, (target[0].Dir(src.dir.get_path(base)), src), kw)) + return builds + +def generate(env): + env['BUILDERS']['InstallSubdir'] = InstallSubdir + +def exists(env): + return 1 diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index 78add3a..1f302d8 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -1,58 +1,8 @@ -## \file -# \brief SENFSCons package - -## \package senfscons.SENFSCons -# \brief Build helpers and utilities -# -# The SENFSCons package contains a number of build helpers and -# utilities which are used to simplify commmon tasks. -# -# The utitlities of this package are grouped into: -#
\ref use
help using complex environments and -# configure the construction environmen correspondingly
-# -#
\ref target
simplify building common targest and include -# enhanced functionality like unit-testing.
-# -# Additionally for external use are -#
MakeEnvironment()
Build construction -# environment
-# -#
GlobSources()
Utility to find source files
-# -# All other functions are for internal use only. - import os.path, glob import SCons.Options, SCons.Environment, SCons.Script.SConscript, SCons.Node.FS import SCons.Defaults, SCons.Action from SCons.Script import * -## \defgroup use Predefined Framework Configurators -# -# The following framework configurators are used in the top level \c -# SConstruct file to simplify more complex configurations. -# -# Each of the framework configurators introduces additional -# configuration parameters to \ref sconfig - -## \defgroup target Target Helpers -# -# To specify standard targets, the following helpers can be used. They -# automatically integrate several modules (like documentation, -# unit-testing etc). - -## \defgroup builder Builders -# -# The SENFSCons framework includes a series of builders. Each builder -# is defined in it's own package. - -## \brief Find normal and test C++ sources -# -# GlobSources() will return a list of all C++ source files (named -# "*.cc") as well as a list of all unit-test files (named "*.test.cc") -# in the current directory. The sources will be returned as a tuple of -# sources, test-sources. The target helpers all accept such a tuple as -# their source argument. def GlobSources(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 ] @@ -78,16 +28,8 @@ def Glob(env, exclude=[], subdirs=[]): return ( GlobSources(env, exclude, subdirs), GlobIncludes(env, exclude, subdirs) ) -## \brief Return path of a built library within $LOCALLIBDIR -# \internal def LibPath(lib): return '${LOCALLIBDIR}/${LIBPREFIX}%s${LIBADDSUFFIX}${LIBSUFFIX}' % lib -## \brief Add explicit test -# -# This target helper will add an explicit test. This is like a unit test but is -# built directly against the completed library -# -# \ingroup target def Test(env, sources, LIBS = [], OBJECTS = []): test = [ env.BoostUnitTests( target = 'test', @@ -102,26 +44,8 @@ def Test(env, sources, LIBS = [], OBJECTS = []): test.extend(env.CompileCheck(source = compileTestSources)) env.Alias('all_tests', test) env.Command(env.File('test'), test, [ 'true' ]) - #env.Alias(env.File('test'), test) -## \brief Build object files -# -# This target helper will build object files from the given -# sources. -# -# If \a testSources are given, a unit test will be built using the Boost.Test -# library. \a LIBS may specify any additional library modules from -# the same project on which the test depends. Those libraries -# will be linked into the final test executable. The test will -# automatically be run if the \c test or \c all_tests targets are -# given. -# -# If \a sources is a 2-tuple as returned by GlobSources(), it will -# provide both \a sources and \a testSources. -# -# \ingroup target def Objects(env, sources, testSources = None, OBJECTS = []): if type(sources) == type(()): testSources = sources[1] @@ -161,16 +85,6 @@ def Objects(env, sources, testSources = None, OBJECTS = []): return objects -def InstallIncludeFiles(env, files): - # Hrmpf ... why do I need this in 0.97?? - if env.GetOption('clean'): - return - target = env.Dir(env['INCLUDEINSTALLDIR']) - base = env.Dir('#') - for f in files: - src = env.File(f) - env.Alias('install_all', env.Install(target.Dir(src.dir.get_path(base)), src)) - ## \brief Build documentation with doxygen # # \ingroup target @@ -236,53 +150,27 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): return doc -## \brief Build library -# -# This target helper will build the given library. The library will be -# called liblibrary.a as is customary on UNIX systems. \a -# sources, \a testSources and \a LIBS are directly forwarded to the -# Objects build helper. -# -# The library is added to the list of default targets. -# -#\ingroup target def Lib(env, sources, testSources = None, OBJECTS = []): objects = Objects(env,sources,testSources,OBJECTS=OBJECTS) - if objects: - env.Append(ALLOBJECTS = objects) + env.Append(ALLOBJECTS = objects) return objects -## \brief Build Object from multiple sources def Object(env, target, sources, testSources = None, OBJECTS = []): objects = Objects(env,sources,testSources,OBJECTS=OBJECTS) - ob = None - if objects: - ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects, "ld -r -o $TARGET $SOURCES") - env.Default(ob) - env.Alias('default', ob) - env.Alias('install_all', env.Install("$OBJINSTALLDIR", ob)) + ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects, "ld -r -o $TARGET $SOURCES") + env.Default(ob) + env.Alias('default', ob) + env.Alias('install_all', env.Install("$OBJINSTALLDIR", ob)) return ob -## \brief Build executable -# -# This target helper will build the given binary. The \a sources, \a -# testSources and \a LIBS arguments are forwarded to the Objects -# builder. The final program will be linked against all the library -# modules specified in \a LIBS (those are libraries which are built as -# part of the same proejct). To specify non-module libraries, use the -# construction environment parameters or the framework helpers. -# -# \ingroup target def Binary(env, binary, sources, testSources = None, OBJECTS = []): - objects = Objects(env,sources,testSources,OBJECTS=OBJECTS) - program = None - if objects: - progEnv = env.Clone() - progEnv.Prepend(LIBS = [ '$LIBSENF$LIBADDSUFFIX' ]) - program = progEnv.Program(target=binary,source=objects+OBJECTS) - env.Default(program) - env.Alias('default', program) - env.Alias('install_all', env.Install('$BININSTALLDIR', program)) + objects = Objects(env, sources, testSources, OBJECTS=OBJECTS) + 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):