From 62922d357beffce111a4794fca751f15e33877c5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 20 Dec 2008 03:40:28 +0100 Subject: [PATCH] (irrelevant) changes to make the dummy code build and load shared module Explanation: together with the bare SCons build system, on this branch I added some dummy codefiles, to validate the build system is working as merged in from master --- admin/scons/ToolCCache.py | 65 ++++++++++++++++++++ src/common/dummy-func.cpp | 42 +++++++++++++ src/common/dummy-func.hpp | 20 ++++++ src/gui/gtk-lumiera.cpp | 10 +++ src/gui/gtk-lumiera.hpp | 8 ++- src/include/nobugcfg.h | 39 ------------ src/lumiera/main.cpp | 58 ++---------------- src/proc/common.hpp | 7 +-- src/tool/SConscript | 1 - src/tool/luidgen.c | 124 -------------------------------------- tests/00test.tests | 1 - tests/bugs/buggy.cpp | 2 +- 12 files changed, 151 insertions(+), 226 deletions(-) create mode 100644 admin/scons/ToolCCache.py create mode 100644 src/common/dummy-func.cpp create mode 100644 src/common/dummy-func.hpp delete mode 100644 src/tool/luidgen.c diff --git a/admin/scons/ToolCCache.py b/admin/scons/ToolCCache.py new file mode 100644 index 000000000..ecc45d011 --- /dev/null +++ b/admin/scons/ToolCCache.py @@ -0,0 +1,65 @@ +# -*- python -*- +## +## ToolDistCC.py - SCons tool for distributed compilation using DistCC +## + +# Copyright (C) Lumiera.org and FreeOrion.org +# 2008, 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. +##################################################################### + +# This SCons builder was extracted from http://www.freeorion.org/ +# FreeOrion is an open-source platform-independent galactic conquest game +# +# history: 12/2008 adapted for Lumiera build system + + +import os +from Buildhelper import * + + +def generate(env): + """ Modify the environment such as to redirect any + C/C++ compiler invocations through DistCC. Additionally + pull in the environment config variables used by DistCC + """ + if not exists(env): return + + assert env['DISTCC'] + if not env['DISTCC'] in env['CC']: + env['CC'] = env.subst('$DISTCC $CC') + if not env['DISTCC'] in env['CXX']: + env['CXX'] = env.subst('$DISTCC $CXX') + print env.subst("* Build using $DISTCC") + for i in ['HOME' + ,'DISTCC_HOSTS' + ,'DISTCC_VERBOSE' + ,'DISTCC_FALLBACK' + ,'DISTCC_LOG' + ,'DISTCC_MMAP' + ,'DISTCC_SAVE_TEMPS' + ,'DISTCC_TCP_CORK' + ,'DISTCC_SSH' + ]: + if os.environ.has_key(i) and not env.has_key(i): + env['ENV'][i] = os.environ[i] + + +def exists(env): + """ Ensure DistCC exists. + """ + return checkCommandOption(env, 'DISTCC', cmdName='distcc') + diff --git a/src/common/dummy-func.cpp b/src/common/dummy-func.cpp new file mode 100644 index 000000000..08b7f69a0 --- /dev/null +++ b/src/common/dummy-func.cpp @@ -0,0 +1,42 @@ +/* + dummy-func.cpp - placeholder with dummy functions to demonstrate building shared modules + +* ******************************************************************************************/ + + +#include "common/dummy-func.hpp" + +#include +#include + + + + + +namespace lumiera { + + const char * const GUI_MODULE_NAME = ".libs/gtk_gui.lum"; + + typedef void (*VoidFunc)(void); + + + void + loadDummyGui() + { + void* handle = dlopen (GUI_MODULE_NAME, RTLD_LAZY|RTLD_LOCAL); + if (handle) + { + VoidFunc entryPoint = (VoidFunc) dlsym (handle, "start_dummy_gui"); + + if (!entryPoint) + ERROR (lumiera, "unable to resolve the entry point symbol after loading the GUI module."); + + else + (*entryPoint) (); + } + else + ERROR (lumiera, "unable to load %s", GUI_MODULE_NAME); + } + + +} // namespace lumiera diff --git a/src/common/dummy-func.hpp b/src/common/dummy-func.hpp new file mode 100644 index 000000000..cbf3a96bb --- /dev/null +++ b/src/common/dummy-func.hpp @@ -0,0 +1,20 @@ +/* + dummy-func.hpp - placeholder with dummy functions to demonstrate building shared modules + +* ******************************************************************************************/ + + +#include "include/nobugcfg.h" + + +namespace lumiera { + + /** this is a function located in the liblumieracore.so, + * which attempts to load the "pseudo-gui" as shared module + * and invoke the gui-main. The sole purpose of this function + * is to demonstarte that the SCons build system is working. + */ + void loadDummyGui(); + + +} // namespace lumiera diff --git a/src/gui/gtk-lumiera.cpp b/src/gui/gtk-lumiera.cpp index 9c0528bbd..4dbc6ec5e 100644 --- a/src/gui/gtk-lumiera.cpp +++ b/src/gui/gtk-lumiera.cpp @@ -37,6 +37,16 @@ main (int argc, char *argv[]) return the_application.main(argc, argv); } +extern "C" +void +start_dummy_gui () +{ + NOTICE(gui, "This is a placeholder for the Lumiera GTK-GUI starting...."); +} + + + + namespace gui { diff --git a/src/gui/gtk-lumiera.hpp b/src/gui/gtk-lumiera.hpp index f543f1fde..a55160530 100644 --- a/src/gui/gtk-lumiera.hpp +++ b/src/gui/gtk-lumiera.hpp @@ -12,14 +12,20 @@ #include #include #include -#include "lib/util.hpp" #include extern "C" { #include + + +/** Dummy function just to demonstrate loading the GUI as + * shared module from the SCons build. */ +void start_dummy_gui (); + } + NOBUG_DECLARE_FLAG(gui); #ifdef ENABLE_NLS diff --git a/src/include/nobugcfg.h b/src/include/nobugcfg.h index cfcedd6b7..5e1a33eb1 100644 --- a/src/include/nobugcfg.h +++ b/src/include/nobugcfg.h @@ -24,37 +24,6 @@ /** @file nobugcfg.h ** This header is for including and configuring NoBug. - ** The idea is that configuration and some commonly used flag - ** declarations are to be kept in one central location. Subsystems - ** are free to define and use additional flags for local use. Typically, - ** this header will be included via some of the basic headers like error.hpp, - ** which in turn gets included e.g. by proc/common.hpp - ** - ** This header can thus be assumed to be effectively global. It should contain - ** only declarations of global relevance, as any change causes the whole project - ** to be rebuilt. Moreover, for C++ this header assures automatic initialisation - ** of NoBug by placing a static ctor call. - ** - ** Besides the usual guarded declarations, this header contains one section - ** with the corresponding definitions. This section is to be included once - ** by some translation unit (currently this is lumiera/nobugcfg.cpp) in order to - ** generate the necessary definitions. - ** - ** @par Logging configuration - ** By default, logging is configured such as to emit a small number of informative - ** messages on the starting terminal and to report fatal errors. But besides the - ** usual fine-grained tracing messages, we define a small number of distinct - ** thematic Logging Channels providing a consistent high-level view of - ** what is going on with regards to a specific aspect of the application - ** - \c operate documents a high-level overall view of what the application \em does - ** - \c render focuses on the working of the render engine (without logging each frame) - ** - \c config shows anything of relevance regarding the configured state of App and session - ** - \c memory allows to diagnose a high-level view of memory management - ** - ** Any log level can be overridden by an environment variable, for example - ** \code NOBUG_LOG='operate:INFO' ./lumiera \endcode - ** - ** @todo logging to files? */ @@ -67,14 +36,6 @@ #ifdef __cplusplus /* ============= C++ ================ */ -#include "include/lifecycle.h" -#include "include/error.hpp" ///< make assertions throw instead of abort() - -namespace lumiera { - void initialise_NoBug (); - namespace { - LifecycleHook trigger_it_ (ON_BASIC_INIT, &initialise_NoBug); -} } #endif /* =====================(End) C++ ================ */ diff --git a/src/lumiera/main.cpp b/src/lumiera/main.cpp index 8dce65c54..f148965d6 100644 --- a/src/lumiera/main.cpp +++ b/src/lumiera/main.cpp @@ -23,67 +23,17 @@ #include "include/nobugcfg.h" -#include "include/error.hpp" -#include "common/appstate.hpp" -#include "common/option.hpp" - -#include "backend/enginefacade.hpp" -#include "backend/netnodefacade.hpp" -#include "backend/scriptrunnerfacade.hpp" -#include "proc/facade.hpp" -#include "gui/guifacade.hpp" - -using util::Cmdline; -using lumiera::Subsys; -using lumiera::AppState; -using lumiera::ON_GLOBAL_INIT; - -namespace { - Subsys& engine = backend::EngineFacade::getDescriptor(); - Subsys& netNode = backend::NetNodeFacade::getDescriptor(); - Subsys& script = backend::ScriptRunnerFacade::getDescriptor(); - Subsys& builder = proc::Facade::getBuilderDescriptor(); - Subsys& session = proc::Facade::getSessionDescriptor(); - Subsys& lumigui = gui::GuiFacade::getDescriptor(); -} +#include "common/dummy-func.hpp" int main (int argc, const char* argv[]) { + NOBUG_INIT; + NOTICE (lumiera, "*** Lumiera NLE for Linux ***"); - AppState& application = AppState::instance(); - try - { - Cmdline args (argc,argv); - lumiera::Option options (args); - application.init (options); - - session.depends (builder); - netNode.depends (session); - netNode.depends (engine); -// lumigui.depends (session); //////TODO commented out in order to be able to start up a dummy GuiStarterPlugin -// lumigui.depends (engine); - script.depends (session); - script.depends (engine); - - application.maybeStart (session); - application.maybeStart (netNode); - application.maybeStart (lumigui); - application.maybeStart (script); - - return application.maybeWait(); - } + lumiera::loadDummyGui(); - - catch (lumiera::Error& problem) - { - return application.abort (problem); - } - catch (...) - { - return application.abort(); - } } diff --git a/src/proc/common.hpp b/src/proc/common.hpp index 970811102..8c9c7fe78 100644 --- a/src/proc/common.hpp +++ b/src/proc/common.hpp @@ -41,11 +41,8 @@ /* common types frequently used... */ -#include "lib/p.hpp" -#include "lib/util.hpp" -#include "lib/lumitime.hpp" -#include "include/symbol.hpp" -#include "include/error.hpp" ///< pulls in NoBug via nobugcfg.h +#include "include/nobugcfg.h" +#include "common/dummy-func.hpp" /** diff --git a/src/tool/SConscript b/src/tool/SConscript index 2336c3553..41a1593d1 100644 --- a/src/tool/SConscript +++ b/src/tool/SConscript @@ -8,7 +8,6 @@ Import('env','artifacts','core') # build the ubiquitous Hello World application (note: C source) artifacts['tools'] = [ env.Program('#$BINDIR/hello-world','hello.c') - + env.Program('#$BINDIR/luidgen', ['luidgen.c']+core) + env.Program('#$BINDIR/try', 'try.cpp') #### to try out some feature... ] diff --git a/src/tool/luidgen.c b/src/tool/luidgen.c deleted file mode 100644 index 730395b6c..000000000 --- a/src/tool/luidgen.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - luidgen.c - generate a lumiera uuid - - Copyright (C) Lumiera.org - 2008 Christian Thaeter - - 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. -*/ - -#include "lib/safeclib.h" -#include "lib/luid.h" - -#include -#include -#include -#include -#include -#include - -/** - * @file - * Generate amd print a Lumiera uid as octal escaped string - * or process a file replaceing 'LUIDGEN' with a octal escaped string - */ - - -int -main (int argc, char** argv) -{ - NOBUG_INIT; - lumiera_uid luid; - - if (argc == 1) - { - lumiera_uid_gen (&luid); - printf ("\""); - for (int i = 0; i < 16; ++i) - printf ("\\%.3hho", *(((char*)&luid)+i)); - printf ("\"\n"); - } - else - { - for (int i = 1; i < argc; ++i) - { - FILE* in = fopen (argv[i], "r"); - if (!in) - { - fprintf (stderr, "Failed to open file %s for reading: %s\n", argv[i], strerror (errno)); - continue; - } - - char* outname = lumiera_tmpbuf_snprintf (SIZE_MAX, "%s.luidgen", argv[i]); - FILE* out = fopen (outname, "wx"); - if (!out) - { - fprintf (stderr, "Failed to open file %s for writing: %s\n", outname, strerror (errno)); - fclose (in); - continue; - } - - char buf[4096]; - char luidbuf[67]; - - printf ("Luidgen %s ", argv[i]); fflush (stdout); - - while (fgets (buf, 4096, in)) - { - char* pos; - while ((pos = strstr(buf, "LUIDGEN"))) - { - memmove (pos+66, pos+7, strlen (pos+7)+1); - lumiera_uid_gen (&luid); - sprintf (luidbuf, "\""LUMIERA_UID_FMT"\"", LUMIERA_UID_ELEMENTS(luid)); - memcpy (pos, luidbuf, 66); - putchar ('.'); fflush (stdout); - } - fputs (buf, out); - } - - fclose (out); - fclose (in); - - char* backup = lumiera_tmpbuf_snprintf (SIZE_MAX, "%s~", argv[i]); - unlink (backup); - - if (!!rename (argv[i], backup)) - { - fprintf (stderr, "Failed to create backupfile %s: %s\n", backup, strerror (errno)); - continue; - } - - if (!!rename (outname, argv[i])) - { - fprintf (stderr, "Renaming %s to %s failed: %s\n", outname, argv[i], strerror (errno)); - rename (backup, argv[i]); - continue; - } - - printf (" done\n"); - } - } - - return 0; -} - -/* -// Local Variables: -// mode: C -// c-file-style: "gnu" -// indent-tabs-mode: nil -// End: -*/ diff --git a/tests/00test.tests b/tests/00test.tests index d1205b8c1..71b7edccb 100644 --- a/tests/00test.tests +++ b/tests/00test.tests @@ -21,5 +21,4 @@ return: 2 END PLANNED "this may never happen" -END diff --git a/tests/bugs/buggy.cpp b/tests/bugs/buggy.cpp index b856f2a44..630d3b00b 100644 --- a/tests/bugs/buggy.cpp +++ b/tests/bugs/buggy.cpp @@ -23,7 +23,7 @@ #include -#include "proc/lumiera.hpp" +#include "proc/common.hpp" using std::cout;