From: g0dil Date: Thu, 17 Sep 2009 22:42:30 +0000 (+0000) Subject: Implement partial BUILDDIR support X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=737789818bf8658d3b3f4444a273b2d44021e51a;p=senf.git Implement partial BUILDDIR support git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1421 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/.gitignore b/.gitignore index e77f14a..d210c44 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ doc/ /TODO /dist/ /lcov.info +/build/ +/lcov-build/ diff --git a/SConscript b/SConscript new file mode 100644 index 0000000..fbe6953 --- /dev/null +++ b/SConscript @@ -0,0 +1,15 @@ +Import('env') + +env['ALLOBJECTS'] = [] + +SConscript('senf/SConscript') + +#### libsenf.a +libsenf = env.Library("$LOCALLIBDIR/${LIBSENF}${LIBADDSUFFIX}", env['ALLOBJECTS']) +env.Default(libsenf) +env.Install('$LIBINSTALLDIR', libsenf) + +conf = env.CreateFile("${LOCALLIBDIR}/${LIBSENF}${LIBADDSUFFIX}.conf", + env.Value(env.subst("$_CPPDEFFLAGS"))) +env.Default(conf) +env.Install('$CONFINSTALLDIR', conf) diff --git a/SConstruct b/SConstruct index 1dbe31c..b9cd5c5 100644 --- a/SConstruct +++ b/SConstruct @@ -1,6 +1,6 @@ # -*- python -*- -import sys, glob, os.path, fnmatch +import sys, os.path, fnmatch import SENFSCons, senfutil ########################################################################### @@ -21,6 +21,7 @@ env.Tool('Boost') env.Tool('CombinedObject') env.Tool('PhonyTarget') env.Tool('InstallDir') +env.Tool('CreateFile') env.Help(""" Additional top-level build targets: @@ -45,8 +46,9 @@ env.Append( ENV = { 'PATH' : os.environ.get('PATH'), 'HOME' : os.environ.get('HOME') }, CLEAN_PATTERNS = [ '*~', '#*#', '*.pyc', 'semantic.cache', '.sconsign*' ], - CPPPATH = [ '#' ], - LOCALLIBDIR = '#', + BUILDDIR = '#', + CPPPATH = [ '$BUILDDIR', '#' ], + LOCALLIBDIR = '$BUILDDIR', LIBPATH = [ '$LOCALLIBDIR' ], LIBS = [ '$LIBSENF$LIBADDSUFFIX', 'rt', '$BOOSTREGEXLIB', '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB', '$BOOSTFSLIB' ], @@ -121,7 +123,7 @@ if not os.path.exists("doclib/Doxyfile.local"): 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.Execute([ "$SCONS prepare" ]) # Load SConscripts @@ -129,7 +131,10 @@ SConscriptChdir(0) SConscript("debian/SConscript") SConscriptChdir(1) if os.path.exists('SConscript.local') : SConscript('SConscript.local') -SConscript("senf/SConscript") +if env['BUILDDIR'] == '#': + SConscript("SConscript") +else: + SConscript("SConscript", variant_dir=env['BUILDDIR'], src_dir='#', duplicate=False) SConscript("Examples/SConscript") SConscript("HowTos/SConscript") SConscript("doclib/SConscript") @@ -137,20 +142,6 @@ SConscript("doclib/SConscript") ########################################################################### # Define build targets -#### libsenf.a -libsenf = env.Library("$LOCALLIBDIR/${LIBSENF}${LIBADDSUFFIX}", env['ALLOBJECTS']) -env.Default(libsenf) -env.Install('$LIBINSTALLDIR', libsenf) - -def create(target, source, env): - file(str(target[0]), 'w').write(source[0].get_contents()+"\n") -env['BUILDERS']['CreateFile'] = Builder(action = create) - -conf = env.CreateFile("${LOCALLIBDIR}/${LIBSENF}${LIBADDSUFFIX}.conf", - env.Value(env.subst("$_CPPDEFFLAGS"))) -env.Default(conf) -env.Install('$CONFINSTALLDIR', conf) - #### install_all, default, all_tests, all env.Install('${SCONSINSTALLDIR}', [ 'site_scons/__init__.py', 'site_scons/senfutil.py', @@ -183,18 +174,17 @@ for test in env.FindAllBoostUnitTests(): ### lcov env.PhonyTarget('lcov', [], [ - '$SCONS debug=1 CCFLAGS+="-fprofile-arcs -ftest-coverage" LIBS+="gcov" all_tests', - '$LCOV --follow --directory $TOPDIR/senf --capture --output-file /tmp/senf_lcov.info --base-directory $TOPDIR', + '$SCONS debug=1 BUILDDIR="#/lcov-build" CCFLAGS+="-fprofile-arcs -ftest-coverage" LIBS+="gcov" all_tests', + '$LCOV --follow --directory $TOPDIR/lcov-build/senf --capture --output-file /tmp/senf_lcov.info --base-directory $TOPDIR', '$LCOV --output-file lcov.info --remove /tmp/senf_lcov.info "*/include/*" "*/boost/*" "*.test.*" ', '$GENHTML --output-directory doc/lcov --title all_tests lcov.info', 'rm /tmp/senf_lcov.info' ]) if env.GetOption('clean'): - env.Depends('lcov', 'all_tests') env.Clean('lcov', [ os.path.join(path,f) for path, subdirs, files in os.walk('.') for pattern in ('*.gcno', '*.gcda', '*.gcov') for f in fnmatch.filter(files,pattern) ] + - [ 'lcov.info', env.Dir('doc/lcov') ]) + [ 'lcov.info', env.Dir('doc/lcov'), env.Dir('lcov-build') ]) #### clean env.Clean('all', ('.prepare-stamp', env.Dir('dist'))) diff --git a/senf/PPI/PPI.hh b/senf/PPI/PPI.hh index c252245..31c988f 100644 --- a/senf/PPI/PPI.hh +++ b/senf/PPI/PPI.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_PPI_PPI_ #define HH_SENF_PPI_PPI_ 1 -#include "all_includes.hh" +#include #endif diff --git a/senf/Packets/SConscript b/senf/Packets/SConscript index 954e5f9..68ea6cb 100644 --- a/senf/Packets/SConscript +++ b/senf/Packets/SConscript @@ -5,6 +5,8 @@ import SENFSCons ########################################################################### +env['PACKET_BUNDLES'] = [] + SENFSCons.AutoRules(env, doc_extra_sources = [ env.Dia2Png("structure.dia"), env.Dia2Png("80221Bundle/TLV.dia"), diff --git a/senf/SConscript b/senf/SConscript index b8589db..e022ad3 100644 --- a/senf/SConscript +++ b/senf/SConscript @@ -1,7 +1,7 @@ # -*- python -*- Import('env') -import SENFSCons, glob, os +import SENFSCons, os ########################################################################### @@ -11,7 +11,8 @@ if not env.GetOption('clean') and not os.path.exists("local_config.hh"): # Ext/SConscript is last so it can depend on env vars set by any other script # (e.g. $PACKET_BUNDLES) -SConscript(list(set(glob.glob("*/SConscript")) - set(("Ext/SConscript",)))) +SConscript(sorted(list(set(env.Glob("*/SConscript", strings=True)) - set(("Ext/SConscript",))))) SConscript("Ext/SConscript") -env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = [ glob.glob("*.hh") ]) +env.InstallSubdir(target = '$INCLUDEINSTALLDIR', + source = sorted(env.Glob("*.hh", strings=True))) diff --git a/senf/Socket/Protocols/DVB/DVB.hh b/senf/Socket/Protocols/DVB/DVB.hh index b60d026..f44665e 100644 --- a/senf/Socket/Protocols/DVB/DVB.hh +++ b/senf/Socket/Protocols/DVB/DVB.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_Socket_Protocols_DVB_DVB_ #define HH_SENF_Socket_Protocols_DVB_DVB_ 1 -#include "all_includes.hh" +#include #endif diff --git a/senf/Socket/Protocols/INet/INet.hh b/senf/Socket/Protocols/INet/INet.hh index eb03316..ba86147 100644 --- a/senf/Socket/Protocols/INet/INet.hh +++ b/senf/Socket/Protocols/INet/INet.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_Socket_Protocols_INet_INet_ #define HH_SENF_Socket_Protocols_INet_INet_ 1 -#include "all_includes.hh" +#include #endif diff --git a/senf/Socket/Protocols/Raw/Raw.hh b/senf/Socket/Protocols/Raw/Raw.hh index 3a0d06f..5326970 100644 --- a/senf/Socket/Protocols/Raw/Raw.hh +++ b/senf/Socket/Protocols/Raw/Raw.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_Socket_Protocols_Raw_Raw_ #define HH_SENF_Socket_Protocols_Raw_Raw_ 1 -#include "all_includes.hh" +#include #endif diff --git a/senf/Socket/Protocols/UN/UN.hh b/senf/Socket/Protocols/UN/UN.hh index 25c6a9c..5ebb8cf 100644 --- a/senf/Socket/Protocols/UN/UN.hh +++ b/senf/Socket/Protocols/UN/UN.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_Socket_Protocols_UN_UN_ #define HH_SENF_Socket_Protocols_UN_UN_ 1 -#include "all_includes.hh" +#include #endif diff --git a/senf/Socket/Socket.hh b/senf/Socket/Socket.hh index ca54b3c..ffd8052 100644 --- a/senf/Socket/Socket.hh +++ b/senf/Socket/Socket.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_Socket_Socket_ #define HH_SENF_Socket_Socket_ 1 -#include "all_includes.hh" +#include #endif diff --git a/senf/Utils/Logger/Logger.hh b/senf/Utils/Logger/Logger.hh index 93fdbba..11b3a0a 100644 --- a/senf/Utils/Logger/Logger.hh +++ b/senf/Utils/Logger/Logger.hh @@ -26,7 +26,7 @@ #ifndef HH_SENF_Utils_Logger_Logger_ #define HH_SENF_Utils_Logger_Logger_ 1 -#include "all_includes.hh" +#include #endif diff --git a/site_scons/SENFSCons.py b/site_scons/SENFSCons.py index 7ff6272..384349c 100644 --- a/site_scons/SENFSCons.py +++ b/site_scons/SENFSCons.py @@ -4,21 +4,27 @@ import SCons.Defaults, SCons.Action from SCons.Script import * 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 ] + testSources = env.Glob("*.test.cc",strings=True) + sources = [ x + for x in env.Glob("*.cc",strings=True) + 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")) + testSources += env.Glob(os.path.join(subdir,"*.test.cc"),strings=True) + sources += [ x + for x in env.Glob(os.path.join(subdir,"*.cc"),strings=True) if x not in testSources and x not in exclude ] includes = [] - for d in [ '.' ] + subdirs: - for f in os.listdir(d): - ext = '.' + f.split('.',1)[-1] - p = os.path.join(d,f) + for d in [ '' ] + [ x+'/' for x in subdirs ]: + for p in env.Glob("%s*" % d, strings=True) + env.Glob("%s*" % d, strings=True, ondisk=False): + ext = '.' + p.split('.',1)[-1] if ext in env['CPP_INCLUDE_EXTENSIONS'] \ and ext not in env['CPP_EXCLUDE_EXTENSIONS'] \ and p not in exclude: includes.append(p) + includes = list(set(includes)) + sources.sort() + testSources.sort() + includes.sort() return ( sources, testSources, includes ) def Doxygen(env, doxyfile = "Doxyfile", extra_sources = [], output_directory = "doc"): @@ -88,15 +94,14 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = [], output_directory = " return doc def AllIncludesHH(env, exclude=[]): - exclude = exclude[:] + ['all_includes.hh'] # Make a copy !! - headers = [ f for f in glob.glob("*.hh") - if f not in exclude and not f.endswith('.test.hh') ] - headers.sort() + exclude = exclude + ['all_includes.hh'] + headers = [ f for f in env.Glob("*.hh", source=True) + if f.name not in exclude and not f.name.endswith('.test.hh') ] + headers.sort(key=lambda x:x.name) target = env.File("all_includes.hh") - file(target.abspath,"w").write("".join([ '#include "%s"\n' % f - for f in headers ])) - env.Clean(env.Alias('all'), target) - + env.Default(env.CreateFile(target, + env.Value("".join([ '#include <%s>\n' % f.srcnode().get_path(env.Dir('#')) + for f in headers ])))) INDEXPAGE=""" /** \mainpage ${TITLE} @@ -117,7 +122,7 @@ INDEXPAGE=""" def IndexPage(env, name, title, text=""): SUBPAGES = [] - for dox in sorted(glob.glob("*/Mainpage.dox")): + for dox in sorted(env.Glob("*/Mainpage.dox",strings=True)): subtitle = ([None] + [ line.split('\\mainpage',1)[-1].strip() for line in file(dox) if '\\mainpage' in line ])[-1] if subtitle: @@ -139,8 +144,9 @@ def AutoRules(env, exclude=[], subdirs=[], doc_extra_sources = []): import SENFSCons sources, tests, includes = SENFSCons.Glob(env, exclude=((exclude)), subdirs=((subdirs)) ) - subscripts = env.Glob("*/SConscript") + subscripts = sorted(env.Glob("*/SConscript", strings=True)) doxyfile = env.Glob("Doxyfile") + objects = [] if sources : env.Append(ALLOBJECTS = env.Object(sources)) if tests : env.BoostUnitTest('test', tests) @@ -153,7 +159,7 @@ def AutoPacketBundle(env, name, exclude=[], subdirs=[], doc_extra_sources=[]): import SENFSCons sources, tests, includes = SENFSCons.Glob(env, exclude=((exclude)), subdirs=((subdirs)) ) - subscripts = env.Glob("*/SConscript") + subscripts = sorted(env.Glob("*/SConscript", strings=True)) doxyfile = env.Glob("Doxyfile") objects = env.Object(sources) diff --git a/site_scons/senfutil.py b/site_scons/senfutil.py index 9a4578b..bda8b3c 100644 --- a/site_scons/senfutil.py +++ b/site_scons/senfutil.py @@ -173,12 +173,17 @@ def DefaultOptions(env): ) 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 ] + testSources = env.Glob("*.test.cc", strings=True) + sources = [ x + for x in env.Glob("*.cc", strings=True) + 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")) + sources += [ x + for x in env.Glob(os.path.join(subdir,"*.cc")) if x not in testSources and x not in exclude ] + sources.sort() + testSources.sort() return (sources, testSources) tagfiles = None diff --git a/site_scons/site_tools/CreateFile.py b/site_scons/site_tools/CreateFile.py new file mode 100644 index 0000000..63f3aea --- /dev/null +++ b/site_scons/site_tools/CreateFile.py @@ -0,0 +1,10 @@ +import SCons.Builder + +def create(target, source, env): + file(str(target[0]), 'w').write(source[0].get_contents()+"\n") + +def generate(env): + env['BUILDERS']['CreateFile'] = SCons.Builder.Builder(action = create) + +def exists(env): + return True diff --git a/site_scons/site_tools/Doxygen.py b/site_scons/site_tools/Doxygen.py index a6cf523..5b04516 100644 --- a/site_scons/site_tools/Doxygen.py +++ b/site_scons/site_tools/Doxygen.py @@ -151,11 +151,12 @@ class DoxyfileParser: ENVVAR_RE = re.compile(r"\$\(([0-9A-Za-z_-]+)\)") - def __init__(self, path, env, include_path=None, items = None): + def __init__(self, node, env, include_path=None, items = None): + self._node = node self._env = env self._include_path = include_path or [] - self._lexer = DoxyfileLexer(file(path)) - self._dir = os.path.split(path)[0] + self._lexer = DoxyfileLexer(file(node.srcnode().get_path())) + self._dir = node.dir self._items = items or {} def parse(self): @@ -192,7 +193,7 @@ class DoxyfileParser: p = os.path.join(d,value[0]) if os.path.exists(p): self._items.setdefault('@INCLUDE',[]).append(p) - parser = DoxyfileParser(p, self._env, self._include_path, self._items) + parser = DoxyfileParser(self._node.File(p), self._env, self._include_path, self._items) parser.parse() return @@ -204,15 +205,13 @@ class DoxyfileParser: def items(self): return self._items -def DoxyfileParse(env,file): +def DoxyfileParse(env,node): # We don't parse source files which do not contain the word 'doxyfile'. SCons will # pass other dependencies to DoxyfileParse which are not doxyfiles ... grmpf ... - if not 'doxyfile' in file.lower(): - return {} ENV = {} ENV.update(env.get("ENV",{})) ENV.update(env.get("DOXYENV", {})) - parser = DoxyfileParser(file,ENV) + parser = DoxyfileParser(node,ENV) try: parser.parse() except ValueError, v: @@ -260,7 +259,7 @@ def DoxySourceScan(node, env, path): sources = [] basedir = node.dir.abspath - data = DoxyfileParse(env, node.abspath) + data = DoxyfileParse(env, node) recursive = data.get("RECURSIVE", "NO").upper()=="YES" file_patterns = data.get("FILE_PATTERNS", default_file_patterns) exclude_patterns = data.get("EXCLUDE_PATTERNS", default_exclude_patterns) @@ -291,7 +290,7 @@ def DoxySourceScan(node, env, path): def DoxySourceScanCheck(node, env): """Check if we should scan this file""" - return os.path.isfile(node.path) + return os.path.isfile(node.path) and 'doxyfile' in node.name.lower() def DoxyEmitter(source, target, env): """Doxygen Doxyfile emitter""" @@ -304,7 +303,7 @@ def DoxyEmitter(source, target, env): "XML" : ("NO", "xml"), } - data = DoxyfileParse(env, source[0].abspath) + data = DoxyfileParse(env, source[0]) targets = [] if data.get("OUTPUT_DIRECTORY",""): @@ -342,7 +341,7 @@ def DoxyEmitter(source, target, env): def doxyNodeHtmlDir(env,node): if not node.sources : return None - data = DoxyfileParse(env, node.sources[0].abspath) + data = DoxyfileParse(env, node.sources[0]) if data.get("GENERATE_HTML",'YES').upper() != 'YES' : return None return os.path.normpath(os.path.join( node.sources[0].dir.abspath, data.get("OUTPUT_DIRECTORY","."), diff --git a/tools/find-sources.sh b/tools/find-sources.sh index 3c2c283..b148154 100755 --- a/tools/find-sources.sh +++ b/tools/find-sources.sh @@ -25,6 +25,7 @@ find . \ -name doc -prune -o \ -name debian -prune -o \ -name dist -prune -o \ + -name build -prune -o \ -name "*.a" -o \ -name "*.o" -o \ -name "*~" -o \