From c5a7d137b8c82242a70f3a3b0333c104f12b3922 Mon Sep 17 00:00:00 2001 From: g0dil <g0dil@wiback.org> Date: Thu, 20 Aug 2009 08:27:31 +0000 Subject: [PATCH] Replace SENFSCons.InstallIncludeFiles with InstallSubdir builder calls --- .gitignore | 3 +- PPI/SConscript | 2 +- Packets/80211Bundle/SConscript | 3 +- Packets/DefaultBundle/SConscript | 3 +- Packets/MPEGDVBBundle/SConscript | 3 +- Packets/SConscript | 3 +- SConstruct | 8 +- Scheduler/SConscript | 3 +- Socket/Protocols/DVB/SConscript | 3 +- Socket/Protocols/INet/SConscript | 3 +- Socket/Protocols/Raw/SConscript | 3 +- Socket/Protocols/SConscript | 3 +- Socket/Protocols/UN/SConscript | 3 +- Socket/SConscript | 3 +- Utils/Console/SConscript | 4 +- Utils/Daemon/SConscript | 3 +- Utils/Logger/SConscript | 3 +- Utils/SConscript | 3 +- Utils/Termlib/SConscript | 4 +- senfscons/InstallSubdir.py | 17 ++++ senfscons/SENFSCons.py | 136 +++---------------------------- 21 files changed, 71 insertions(+), 145 deletions(-) create mode 100644 senfscons/InstallSubdir.py diff --git a/.gitignore b/.gitignore index f3de49645..f83fefec2 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 b7ee214c8..c0aedb7ff 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 ac3152232..8aa9f69f5 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 47b7a1132..c91e6e847 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 654bbe52c..b661ecaf6 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 55bf07c5b..69d353b5c 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 92a4078e4..c8e0d4560 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 73103906d..6113f90a6 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 0b56081db..6f982f393 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 e48d809a5..9e27f8bb9 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 7c58379dd..83b578b7f 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 dee839eb5..3346cec86 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 021bbe6c0..6c79bf399 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 0e7b440dd..5206292cd 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 026e3c26e..5303f1ab4 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 1b7e8febe..77967ed2f 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 a3803c6f8..bb4f89730 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 a39548afc..ef0872cfc 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 ffacf97fa..5f7783972 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 000000000..d76a51274 --- /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 78add3a20..1f302d8be 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: -# <dl><dt>\ref use</dt><dd>help using complex environments and -# configure the construction environmen correspondingly</dd> -# -# <dt>\ref target</dt><dd>simplify building common targest and include -# enhanced functionality like unit-testing.</dd></dl> -# -# Additionally for external use are -# <dl><dt>MakeEnvironment()</dt><dd>Build construction -# environment</dd> -# -# <dt>GlobSources()</dt><dd>Utility to find source files</dd></dl> -# -# 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 <a -# href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a> -# library. \a LIBS may specify any additional library modules <em>from -# the same project</em> 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 lib<i>library</i>.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): -- GitLab