From c3b1048fc4aba19ecda0e31bccb93f6306894b9d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 27 Jan 2008 03:58:24 +0100 Subject: [PATCH] merge buildsystem improvements --- .gitignore | 1 + SConstruct | 24 ++++-- admin/scons/Buildhelper.py | 19 +++++ src/common/test/run.hpp | 9 ++- src/common/util.hpp | 1 - src/pre.hpp | 51 +++++++++++++ src/proc/asset.hpp | 2 + src/proc/asset/media.cpp | 1 + src/proc/mobject/mobject.hpp | 2 + src/proc/mobject/placement.hpp | 2 +- src/tool/try.cpp | 75 +++---------------- tests/SConscript | 6 +- tests/components/backend/mediaaccessmock.cpp | 1 - .../backend/mediaaccessmocktest.cpp | 1 - tests/components/common/appconfigtest.cpp | 1 - .../components/common/factoryspecialtest.cpp | 1 - .../common/sanitizedidentifiertest.cpp | 2 - tests/components/common/singletontest.cpp | 1 - .../common/singletontestmocktest.cpp | 1 - .../common/test/cmdlinewrappertest.cpp | 6 +- 20 files changed, 118 insertions(+), 89 deletions(-) create mode 100644 src/pre.hpp diff --git a/.gitignore b/.gitignore index d55b1ba9f..ef277c1a1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.tar.* .[^.]* *.os +*.gch Buildhelper.pyc optcache Makefile.in diff --git a/SConstruct b/SConstruct index 126e40a8d..88c5dcb97 100644 --- a/SConstruct +++ b/SConstruct @@ -65,13 +65,14 @@ def setupBasicEnvironment(): , CCFLAGS='-Wall ' # -fdiagnostics-show-option ) + RegisterPrecompiledHeader_Builder(env) handleNoBugSwitches(env) appendCppDefine(env,'DEBUG','DEBUG', 'NDEBUG') appendCppDefine(env,'OPENGL','USE_OPENGL') appendVal(env,'ARCHFLAGS', 'CCFLAGS') # for both C and C++ appendVal(env,'OPTIMIZE', 'CCFLAGS', val=' -O3') - appendVal(env,'DEBUG', 'CCFLAGS', val=' -g') + appendVal(env,'DEBUG', 'CCFLAGS', val=' -ggdb') prepareOptionsHelp(opts,env) opts.Save(OPTIONSCACHEFILE, env) @@ -91,9 +92,13 @@ def appendVal(env,var,targetVar,val=None): def handleNoBugSwitches(env): """ set the build level for NoBug. Release builds imply no DEBUG + wheras ALPHA and BETA require DEBUG """ level = env['BUILDLEVEL'] if level in ['ALPHA', 'BETA']: + if not env['DEBUG']: + print 'NoBug: ALPHA or BETA builds without DEBUG not possible, exiting.' + Exit(1) env.Replace( DEBUG = 1 ) env.Append(CPPDEFINES = 'EBUG_'+level) elif level == 'RELEASE': @@ -128,7 +133,7 @@ def defineCmdlineOptions(): def prepareOptionsHelp(opts,env): prelude = """ -USAGE: scons [-c] [OPTS] [key=val,...] [TARGETS] +USAGE: scons [-c] [OPTS] [key=val [key=val...]] [TARGETS] Build and optionally install Cinelerra. Without specifying any target, just the (re)build target will run. Add -c to the commandline to clean up anything a given target would produce @@ -228,20 +233,26 @@ def defineBuildTargets(env, artifacts): setup sub-environments with special build options if necessary. We use a custom function to declare a whole tree of srcfiles. """ + cinobj = ( srcSubtree(env,'$SRCDIR/backend') + srcSubtree(env,'$SRCDIR/proc') + srcSubtree(env,'$SRCDIR/common') + srcSubtree(env,'$SRCDIR/lib') ) plugobj = srcSubtree(env,'$SRCDIR/plugin', isShared=True) - corelib = env.StaticLibrary('$BINDIR/core.la', cinobj) + core = env.StaticLibrary('$BINDIR/core.la', cinobj) + #core = cinobj # use this for linking directly - artifacts['cinelerra'] = env.Program('$BINDIR/cinelerra', ['$SRCDIR/main.cpp']+ corelib ) + # use PCH to speed up building + precomp = env.PrecompiledHeader('$SRCDIR/pre') + env.Depends(cinobj, precomp) + + artifacts['cinelerra'] = env.Program('$BINDIR/cinelerra', ['$SRCDIR/main.cpp']+ core ) artifacts['plugins'] = env.SharedLibrary('$BINDIR/cinelerra-plugin', plugobj) # call subdir SConscript(s) for independent components SConscript(dirs=[SRCDIR+'/tool'], exports='env artifacts') - SConscript(dirs=[TESTDIR], exports='env artifacts corelib') + SConscript(dirs=[TESTDIR], exports='env artifacts core') @@ -257,7 +268,8 @@ def definePostBuildTargets(env, artifacts): allbu = env.Alias('allbuild', build+artifacts['testsuite']) env.Default('build') # additional files to be cleaned when cleaning 'build' - env.Clean ('build', [ 'scache.conf', '.sconf_temp', '.sconsign.dblite', 'config.log']) + env.Clean ('build', [ 'scache.conf', '.sconf_temp', '.sconsign.dblite', 'config.log' ]) + env.Clean ('build', [ '$SRCDIR/pre.gch' ]) # Doxygen documentation # Note: at the moment we only depend on Doxyfile diff --git a/admin/scons/Buildhelper.py b/admin/scons/Buildhelper.py index 81d501424..419de6e68 100644 --- a/admin/scons/Buildhelper.py +++ b/admin/scons/Buildhelper.py @@ -90,6 +90,25 @@ def globRootdirs(roots): +def RegisterPrecompiledHeader_Builder(env): + """ Registeres an Custom Builder for generating a precompiled Header. + Note you should define a dependency to the PCH file + """ + def genCmdline(source, target, env, for_signature): + return '$CXXCOM -x c++-header %s' % source[0] + def fixSourceDependency(target, source, env): + print "precompiled header: %s --> %s" % (source[0],target[0]) + return (target, source) + + gchBuilder = env.Builder( generator = genCmdline + , emitter = fixSourceDependency + , suffix = '.gch' + , src_suffix = '.hpp' + ) + env.Append(BUILDERS = {'PrecompiledHeader' : gchBuilder}) + + + def Tarball(env,location,dirs,suffix=''): """ Custom Command: create Tarball of some subdirs location: where to create the tar (optionally incl. filename.tar.gz) diff --git a/src/common/test/run.hpp b/src/common/test/run.hpp index 668f29645..0cee56674 100644 --- a/src/common/test/run.hpp +++ b/src/common/test/run.hpp @@ -25,12 +25,17 @@ #ifndef TESTHELPER_RUN_H #define TESTHELPER_RUN_H -#include -#include +#include "pre.hpp" + + +#include "nobugcfg.h" #include "common/test/suite.hpp" #include "common/util.hpp" +#include +#include + namespace test { diff --git a/src/common/util.hpp b/src/common/util.hpp index 6ca7f75d8..6b3a35096 100644 --- a/src/common/util.hpp +++ b/src/common/util.hpp @@ -29,7 +29,6 @@ #include #include -#include "nobugcfg.h" ///////////////////TODO: just temporarily!!!! namespace util diff --git a/src/pre.hpp b/src/pre.hpp new file mode 100644 index 000000000..af83dd9a2 --- /dev/null +++ b/src/pre.hpp @@ -0,0 +1,51 @@ +/* + PRE.hpp - precompiled header collection + + + Copyright (C) CinelerraCV + 2007, Christian Thaeter + Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +/** @file pre.hpp + ** Precompiled Header Collection. + ** Assortment of standard util, error handling and basic lib-boost components, + ** frequently used in conjunction. Precompiling these can speedup building + ** significantly. When used, this header should be included prior to any other + ** headers (and it needs to be compiled by gcc into a "pre.gch" file prior to + ** building the object files including this header). + ** + ** @see mobject.hpp usage example + */ + +#ifndef CINELERRA_PRE_HPP +#define CINELERRA_PRE_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include "cinelerra.h" + + + +#endif /*CINELERRA_PRE_HPP*/ diff --git a/src/proc/asset.hpp b/src/proc/asset.hpp index d9e2e5833..f6f8a8d98 100644 --- a/src/proc/asset.hpp +++ b/src/proc/asset.hpp @@ -55,6 +55,8 @@ #define PROC_INTERFACE_ASSET_H +#include "pre.hpp" + #include "proc/asset/category.hpp" #include "common/error.hpp" diff --git a/src/proc/asset/media.cpp b/src/proc/asset/media.cpp index 82ba763be..769863ff3 100644 --- a/src/proc/asset/media.cpp +++ b/src/proc/asset/media.cpp @@ -21,6 +21,7 @@ * *****************************************************/ +#include "pre.hpp" #include "proc/assetmanager.hpp" #include "proc/asset/media.hpp" #include "proc/asset/clip.hpp" diff --git a/src/proc/mobject/mobject.hpp b/src/proc/mobject/mobject.hpp index b051a49ec..634322470 100644 --- a/src/proc/mobject/mobject.hpp +++ b/src/proc/mobject/mobject.hpp @@ -24,6 +24,8 @@ #ifndef MOBJECT_MOBJECT_H #define MOBJECT_MOBJECT_H +#include "pre.hpp" + #include #include diff --git a/src/proc/mobject/placement.hpp b/src/proc/mobject/placement.hpp index 21c4aada8..ab29878de 100644 --- a/src/proc/mobject/placement.hpp +++ b/src/proc/mobject/placement.hpp @@ -57,7 +57,7 @@ #ifndef MOBJECT_PLACEMENT_H #define MOBJECT_PLACEMENT_H -#include "cinelerra.h" +#include "pre.hpp" #include "proc/mobject/mobject.hpp" #include "proc/mobject/session/locatingpin.hpp" #include "proc/asset/port.hpp" diff --git a/src/tool/try.cpp b/src/tool/try.cpp index 6aa45243a..349ca7db0 100644 --- a/src/tool/try.cpp +++ b/src/tool/try.cpp @@ -6,87 +6,32 @@ // 8/07 - how to control NOBUG?? // execute with NOBUG_LOG='ttt:TRACE' bin/try // 1/08 - working out a static initialisation problem for Visitor (Tag creation) +// 1/08 - check 64bit longs #include #include +#include + + using std::string; using std::cout; NOBUG_CPP_DEFINE_FLAG(test); - template class Tag; - - - template - class TagTypeRef - { - public: - static Tag tag; - }; - - - template - class Tag - { - size_t tagID; - static size_t lastRegisteredID; - - public: - Tag(size_t tt=0) : tagID(tt) {} - operator size_t() const { return tagID; } - - template - static Tag& - get (TOOLImpl* const concreteTool=0) - { - INFO (test,"getTag"); - Tag& t = TagTypeRef::tag; - if (!t) - t.tagID = ++Tag::lastRegisteredID; - return t; - } - - }; - - - - - /** storage for the Tag registry for each concrete tool */ - template - Tag TagTypeRef ::tag (0); - - template - size_t Tag::lastRegisteredID (0); - - - - - - class TT - { - - }; - - class TI : public TT - { - - }; - class TII : public TT - { - - }; int main (int argc, char* argv[]) { NOBUG_INIT; - size_t xxx = Tag::get(); - - cout << "created Tag=" << xxx <<"\n"; - cout << "created Tag=" << Tag::get () <<"\n"; + int64_t lol (1); + cout << sizeof(lol)<< "\n"; + + cout << "long: "<< std::numeric_limits::max() + <<" 64: " << std::numeric_limits::max() + <<"\n"; return 0; } diff --git a/tests/SConscript b/tests/SConscript index 31bd607e2..7f66b6284 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -7,7 +7,7 @@ from os import path from Buildhelper import srcSubtree from Buildhelper import globRootdirs -Import('env','artifacts','corelib') +Import('env','artifacts','core') def testExecutable(env,tree, exeName=None, obj=None): @@ -24,7 +24,7 @@ def testExecutable(env,tree, exeName=None, obj=None): obj = srcSubtree(env,tree) # use all sourcefiles found in subtree if not exeName: exeName = 'test-%s' % tree - return env.Program('#$BINDIR/'+exeName, obj + corelib) + return env.Program('#$BINDIR/'+exeName, obj + core) def treatPluginTestcase(env): @@ -38,7 +38,7 @@ def treatPluginTestcase(env): testplugin = ( env.SharedLibrary('#$BINDIR/.libs/example_plugin', oC, SHLIBPREFIX='') + env.SharedLibrary('#$BINDIR/.libs/example_plugin_cpp', oCPP, SHLIBPREFIX='') ) - testExe = env.Program('#$BINDIR/test-plugin', ['plugin/plugin_main.c'] + corelib) + testExe = env.Program('#$BINDIR/test-plugin', ['plugin/plugin_main.c'] + core) env.Depends(testExe, testplugin) return testExe #-- it depentds (at the moment) on a specific isolated test-plugin, diff --git a/tests/components/backend/mediaaccessmock.cpp b/tests/components/backend/mediaaccessmock.cpp index cd87399bb..d980c83d5 100644 --- a/tests/components/backend/mediaaccessmock.cpp +++ b/tests/components/backend/mediaaccessmock.cpp @@ -36,7 +36,6 @@ #include "backend/mediaaccessmock.hpp" #include "common/util.hpp" -#include "nobugcfg.h" #include #include diff --git a/tests/components/backend/mediaaccessmocktest.cpp b/tests/components/backend/mediaaccessmocktest.cpp index 2e4a71ec5..110d2b3cd 100644 --- a/tests/components/backend/mediaaccessmocktest.cpp +++ b/tests/components/backend/mediaaccessmocktest.cpp @@ -26,7 +26,6 @@ #include "common/test/run.hpp" //#include "common/util.hpp" -#include "nobugcfg.h" //#include #include diff --git a/tests/components/common/appconfigtest.cpp b/tests/components/common/appconfigtest.cpp index c76817712..49266c4ae 100644 --- a/tests/components/common/appconfigtest.cpp +++ b/tests/components/common/appconfigtest.cpp @@ -21,7 +21,6 @@ * *****************************************************/ -#include "nobugcfg.h" #include "common/appconfig.hpp" diff --git a/tests/components/common/factoryspecialtest.cpp b/tests/components/common/factoryspecialtest.cpp index 39066d952..e9848c599 100644 --- a/tests/components/common/factoryspecialtest.cpp +++ b/tests/components/common/factoryspecialtest.cpp @@ -26,7 +26,6 @@ #include "common/test/run.hpp" #include "common/util.hpp" -#include "nobugcfg.h" #include #include diff --git a/tests/components/common/sanitizedidentifiertest.cpp b/tests/components/common/sanitizedidentifiertest.cpp index b066ec03c..a6dba2c79 100644 --- a/tests/components/common/sanitizedidentifiertest.cpp +++ b/tests/components/common/sanitizedidentifiertest.cpp @@ -21,8 +21,6 @@ * *****************************************************/ -#include "nobugcfg.h" - #include "common/test/run.hpp" #include "common/util.hpp" diff --git a/tests/components/common/singletontest.cpp b/tests/components/common/singletontest.cpp index 1fa5e0209..ce88d5245 100644 --- a/tests/components/common/singletontest.cpp +++ b/tests/components/common/singletontest.cpp @@ -26,7 +26,6 @@ #include "common/test/run.hpp" #include "common/singleton.hpp" #include "common/util.hpp" -#include "nobugcfg.h" #include #include diff --git a/tests/components/common/singletontestmocktest.cpp b/tests/components/common/singletontestmocktest.cpp index eab73eba6..b33dda5d2 100644 --- a/tests/components/common/singletontestmocktest.cpp +++ b/tests/components/common/singletontestmocktest.cpp @@ -25,7 +25,6 @@ #include "common/test/run.hpp" #include "common/singleton.hpp" #include "common/util.hpp" -#include "nobugcfg.h" #include #include diff --git a/tests/components/common/test/cmdlinewrappertest.cpp b/tests/components/common/test/cmdlinewrappertest.cpp index 4ab8b28be..84b0780c1 100644 --- a/tests/components/common/test/cmdlinewrappertest.cpp +++ b/tests/components/common/test/cmdlinewrappertest.cpp @@ -21,8 +21,6 @@ * *****************************************************/ -#include "nobugcfg.h" - #include "common/test/run.hpp" #include "common/cmdline.hpp" #include "common/util.hpp" @@ -32,7 +30,6 @@ #include -using namespace boost::lambda; using std::cout; @@ -41,6 +38,9 @@ namespace util { namespace test { + using boost::lambda::_1; + using boost::lambda::var; + /** @test for util::Cmdline, wrapping various example cmdlines */