From 29d4b6f08cbec5b34717aa5b354124a202472da3 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 26 Dec 2010 17:13:41 +0000 Subject: module load path is now configurable at build time git-svn-id: https://svn.spreadspace.org/gcsd/trunk@76 ac14a137-c7f1-4531-abe0-07747231d213 --- TODO | 8 ++++---- src/configure | 12 +++++++++++- src/gcsd.c | 5 +++++ src/module_list.lua | 3 +-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index d40a11b..82501a9 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,13 @@ * send response to requestor * out-of-order responses - * finish API for command & response dispatch tables * add listener tables (for requests, responses and other messages) - * improve module loader (configurable path) + * config-parser (file and improve parser for modules config) + * finish API for command & response dispatch tables * module API etc. clean-up, finalize, freeze - * config-parser * add modules - tcp - udp - unix - inotify - * exec module, add support for parameters \ No newline at end of file + * exec module, add support for parameters + * improve module loader (allow multiple search paths) diff --git a/src/configure b/src/configure index 5acbd2f..9b834ab 100755 --- a/src/configure +++ b/src/configure @@ -44,6 +44,7 @@ LUAC='' PREFIX='/usr/local' BINDIR='' ETCDIR='' +MODULESDIR='' MANDIR='' INSTALLMANPAGE=1 EXAMPLESDIR='' @@ -54,7 +55,8 @@ print_usage() { echo " --target= build target i.e. Linux (default: autodetect)" echo " --prefix= the installation prefix (default: /usr/local)" echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" - echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc" + echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc)" + echo " --modulesdir= the path to the gcsd modules (default: $PREFIX/lib/gcsd)" echo " --mandir= the path to the system man pages (default: $PREFIX/share/man)" echo " --no-manpage dont't install manpage" echo " --examplesdir= the path to the examples files (default: $PREFIX/share/examples)" @@ -77,6 +79,9 @@ do --sysconfdir=*) ETCDIR=${arg#--sysconfdir=} ;; + --modulesdir=*) + MODULESDIR=${arg#--modulesdir=} + ;; --mandir=*) MANDIR=${arg#--mandir=} ;; @@ -215,6 +220,10 @@ if [ -z "$ETCDIR" ]; then ETCDIR=$PREFIX/etc fi +if [ -z "$MODULESDIR" ]; then + MODULESDIR=$PREFIX/lib/gcsd +fi + if [ -z "$MANDIR" ]; then MANDIR=$PREFIX/share/man fi @@ -291,6 +300,7 @@ cat > config.h < #include "datatypes.h" +#include "config.h" #include "options.h" #include "string_list.h" #include "log.h" @@ -104,6 +105,10 @@ int init_defines(lua_State *L) lua_pushinteger(L, 4); lua_settable(L, -3); + lua_pushliteral(L, "MODULES_PATH"); + lua_pushstring(L, MODULESDIR); + lua_settable(L, -3); + lua_setglobal(L, "defines"); return 0; } diff --git a/src/module_list.lua b/src/module_list.lua index 053d9db..b5766aa 100644 --- a/src/module_list.lua +++ b/src/module_list.lua @@ -33,7 +33,6 @@ module_list = {} module_list.classes = {} -module_list.classes.__path = "./modules" local mt = {} function mt.__index(table, key) local value = rawget(table, key) @@ -41,7 +40,7 @@ function mt.__index(table, key) log.printf(log.DEBUG, "load module class: %s", key) - local filename = table.__path .. "/" .. key .. ".lua" + local filename = defines.MODULES_PATH .. "/" .. key .. ".lua" local chunk, err = loadfile(filename) if (not chunk) then error("failed to load module: " .. err) -- cgit v1.2.3