(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
This commit is contained in:
Fischlurch 2008-12-20 03:40:28 +01:00
parent f6209d99d3
commit 62922d357b
12 changed files with 151 additions and 226 deletions

65
admin/scons/ToolCCache.py Normal file
View file

@ -0,0 +1,65 @@
# -*- python -*-
##
## ToolDistCC.py - SCons tool for distributed compilation using DistCC
##
# Copyright (C) Lumiera.org and FreeOrion.org
# 2008, Hermann Vosseler <Ichthyostega@web.de>
#
# 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')

42
src/common/dummy-func.cpp Normal file
View file

@ -0,0 +1,42 @@
/*
dummy-func.cpp - placeholder with dummy functions to demonstrate building shared modules
* ******************************************************************************************/
#include "common/dummy-func.hpp"
#include <dlfcn.h>
#include <nobug.h>
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

20
src/common/dummy-func.hpp Normal file
View file

@ -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

View file

@ -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 {

View file

@ -12,14 +12,20 @@
#include <vector>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include "lib/util.hpp"
#include <libgdl-1.0/gdl/gdl-dock-layout.h>
extern "C" {
#include <gavl/gavltime.h>
/** 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

View file

@ -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 <b>definitions</b>. 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 <b>Logging Channels</b> 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++ ================ */

View file

@ -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();
}
}

View file

@ -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"
/**

View file

@ -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...
]

View file

@ -1,124 +0,0 @@
/*
luidgen.c - generate a lumiera uuid
Copyright (C) Lumiera.org
2008 Christian Thaeter <ct@pipapo.org>
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 <unistd.h>
#include <stdint.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <nobug.h>
/**
* @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:
*/

View file

@ -21,5 +21,4 @@ return: 2
END
PLANNED "this may never happen"
END

View file

@ -23,7 +23,7 @@
#include <iostream>
#include "proc/lumiera.hpp"
#include "proc/common.hpp"
using std::cout;