From e9447ecc19114cee9550c7aaea89a4d3de3cfa3f Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 21 Apr 2014 17:53:25 +1000 Subject: Move LumbrJack and Runnr to the libraries directory, and use them from GuiLua. --- ClientHamr/GuiLua/GuiLua.c | 379 +------------------------------------------ ClientHamr/GuiLua/GuiLua.h | 39 +---- ClientHamr/GuiLua/build.lua | 2 +- ClientHamr/extantz/build.lua | 2 +- LuaSL/build.lua | 2 +- LumbrJack/LumbrJack.c | 82 ---------- LumbrJack/LumbrJack.h | 38 ----- LumbrJack/README | 1 - LumbrJack/build.lua | 21 --- Runnr/README | 1 - Runnr/Runnr.c | 318 ------------------------------------ Runnr/Runnr.h | 15 -- Runnr/build.lua | 21 --- build.lua | 22 ++- libraries/LumbrJack.c | 82 ++++++++++ libraries/LumbrJack.h | 38 +++++ libraries/README | 8 + libraries/Runnr.c | 318 ++++++++++++++++++++++++++++++++++++ libraries/Runnr.h | 15 ++ libraries/build.lua | 24 +++ 20 files changed, 506 insertions(+), 922 deletions(-) delete mode 100644 LumbrJack/LumbrJack.c delete mode 100644 LumbrJack/LumbrJack.h delete mode 100644 LumbrJack/README delete mode 100755 LumbrJack/build.lua delete mode 100644 Runnr/README delete mode 100644 Runnr/Runnr.c delete mode 100644 Runnr/Runnr.h delete mode 100755 Runnr/build.lua create mode 100644 libraries/LumbrJack.c create mode 100644 libraries/LumbrJack.h create mode 100644 libraries/Runnr.c create mode 100644 libraries/Runnr.h create mode 100755 libraries/build.lua diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c index cb7f64c..1e6d3fa 100644 --- a/ClientHamr/GuiLua/GuiLua.c +++ b/ClientHamr/GuiLua/GuiLua.c @@ -147,383 +147,6 @@ globals ourGlobals; static const char *globName = "ourGlobals"; -void dumpStack(lua_State *L, int i) -{ - int type = lua_type(L, i); - - switch (type) - { - case LUA_TNONE : printf("Stack %d is empty\n", i); break; - case LUA_TNIL : printf("Stack %d is a nil\n", i); break; - case LUA_TBOOLEAN : printf("Stack %d is a boolean - %d\n", i, lua_toboolean(L, i)); break; - case LUA_TNUMBER : printf("Stack %d is a number\n - %f", i, lua_tonumber(L, i)); break; - case LUA_TSTRING : printf("Stack %d is a string - %s\n", i, lua_tostring(L, i)); break; - case LUA_TFUNCTION : printf("Stack %d is a function\n", i); break; - case LUA_TTHREAD : printf("Stack %d is a thread\n", i); break; - case LUA_TTABLE : - { - int j; - - printf("Stack %d is a table", i); - lua_getfield(L, i, "_NAME"); - j = lua_gettop(L); - if (lua_isstring(L, j)) - printf(" - %s", lua_tostring(L, j)); - lua_pop(L, 1); - printf("\n"); - break; - } - case LUA_TUSERDATA : printf("Stack %d is a userdata\n", i); break; - case LUA_TLIGHTUSERDATA : printf("Stack %d is a light userdata\n", i); break; - default : printf("Stack %d is unknown\n", i); break; - } -} - -static char dateTime[DATE_TIME_LEN]; - -static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args) -{ - FILE *f = data; - char dt[DATE_TIME_LEN + 1]; - char fileTab[256], funcTab[256]; - - getDateTime(NULL, dt, NULL); - dt[19] = '\0'; - if (12 > strlen(file)) - snprintf(fileTab, sizeof(fileTab), "%s\t\t", file); - else - snprintf(fileTab, sizeof(fileTab), "%s\t", file); - snprintf(funcTab, sizeof(funcTab), "\t%s", fnc); - fprintf(f, "%s ", dt); - if (f == stderr) - eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args); - else if (f == stdout) - eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args); - fflush(f); -} - -void loggingStartup(globals *ourGlobals) -{ - if (ourGlobals->logDom < 0) - { - ourGlobals->logDom = eina_log_domain_register("GuiLua", NULL); - if (ourGlobals->logDom < 0) - { - EINA_LOG_CRIT("could not register log domain 'GuiLua'"); - return; - } - } - eina_log_level_set(EINA_LOG_LEVEL_DBG); - eina_log_domain_level_set("GuiLua", EINA_LOG_LEVEL_DBG); - eina_log_print_cb_set(_ggg_log_print_cb, stderr); - - // Shut up the excess debugging shit from EFL. - eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); -} - -char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) -{ - struct tm *newTime; - time_t szClock; - char *date = dateTime; - - // Get time in seconds - time(&szClock); - // Convert time to struct tm form - newTime = localtime(&szClock); - - if (nowOut) - *nowOut = newTime; - if (dateOut) - date = dateOut; - if (timeOut) - *timeOut = szClock; - - // format - strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); - return (dateTime); -} - - -// These are what the various symbols are for each type - -// int % -// num # -// str $ -// bool ! -// C func & -// table.field @ Expects an integer and a string. -// nil ~ -// table {} Starts and stops filling up a new table. -// ( Just syntax sugar for call. -// call ) Expects an integer, the number of results left after the call. -// FIXME: Still to do, if we ever use them - -// stack = Get a value from the stack, expects a stack index. -// userdata + -// lightuserdata * -// thread ^ - -static char *_push_name(lua_State *L, char *q, int *idx) // Stack usage [-0, +1, e or m] -{ - char *p = q; - char temp = '\0'; - - // A simplistic scan through an identifier, it's wrong, but it's quick, - // and we don't mind that it's wrong, coz this is only internal. - while (isalnum((int)*q)) - q++; - temp = *q; - *q = '\0'; - if (*idx > 0) - lua_getfield(L, *idx, p); // Stack usage [-0, +1, e] - else - { - if (p != q) - lua_pushstring(L, p); // Stack usage [-0, +1, m] - else - { - lua_pushnumber(L, (lua_Number) (0 - (*idx))); - (*idx)--; - } - } - *q = temp; - - return q; -} - -int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage - - // if i is a table - // [-n, +n, e] - // else - // [-0, +0, -] -{ - va_list vl; - char *f = strdup(params); - char *p = f; - int n = 0, j = i, count = 0; - Eina_Bool table = EINA_FALSE; - - if (!f) return -1; - va_start(vl, params); - - if (lua_istable(L, i)) // Stack usage [-0, +0, -] - { - j = -1; - table = EINA_TRUE; - } - - while (*p) - { - char *q; - Eina_Bool get = EINA_TRUE; - - while (isspace((int)*p)) - p++; - q = p + 1; - switch (*p) - { - case '%': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] - { - int *v = va_arg(vl, int *); - *v = lua_tointeger(L, j); // Stack usage [-0, +0, -] - n++; - } - break; - } - case '#': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] - { - double *v = va_arg(vl, double *); - *v = lua_tonumber(L, j); // Stack usage [-0, +0, -] - n++; - } - break; - } - case '$': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isstring(L, j)) // Stack usage [-0, +0, -] - { - char **v = va_arg(vl, char **); - size_t len; - char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m] - - len++; // Cater for the null at the end. - *v = malloc(len); - if (*v) - { - memcpy(*v, temp, len); - n++; - } - } - break; - } - case '!': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isboolean(L, j)) // Stack usage [-0, +0, -] - { - int *v = va_arg(vl, int *); - *v = lua_toboolean(L, j); // Stack usage [-0, +0, -] - n++; - } - break; - } - default: - { - get = EINA_FALSE; - break; - } - } - - if (get) - { - if (table) - { - // If this is a table, then we pushed a value on the stack, pop it off. - lua_pop(L, 1); // Stack usage [-n, +0, -] - } - else - j++; - count++; - } - p = q; - } - - va_end(vl); - free(f); - if (count > n) - n = 0; - else if (table) - n = 1; - return n; -} - -int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em] -{ - va_list vl; - char *f = strdup(params); - char *p = f; - int n = 0, table = 0, i = -1; - - if (!f) return -1; - - va_start(vl, params); - - while (*p) - { - char *q; - Eina_Bool set = EINA_TRUE; - - while (isspace((int)*p)) - p++; - q = p + 1; - switch (*p) - { - case '%': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushinteger(L, va_arg(vl, int)); // Stack usage [-0, +1, -] - break; - } - case '#': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushnumber(L, va_arg(vl, double)); // Stack usage [-0, +1, -] - break; - } - case '$': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushstring(L, va_arg(vl, char *)); // Stack usage [-0, +1, m] - break; - } - case '!': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushboolean(L, va_arg(vl, int)); // Stack usage [-0, +1, -] - break; - } - case '=': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushvalue(L, va_arg(vl, int)); // Stack usage [-0, +1, -] - break; - } - case '@': - { - int tabl = va_arg(vl, int); - char *field = va_arg(vl, char *); - - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_getfield(L, tabl, field); // Stack usage [-0, +1, e] - break; - } - case '&': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushcfunction(L, va_arg(vl, void *)); // Stack usage [-0, +1, m] - break; - } - case '~': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushnil(L); // Stack usage [-0, +1, -] - break; - } - case '(': // Just syntax sugar. - { - set = EINA_FALSE; - break; - } - case ')': - { - lua_call(L, n - 1, va_arg(vl, int)); - n = 0; - set = EINA_FALSE; - break; - } - case '{': - { - lua_newtable(L); - table++; - n++; - set = EINA_FALSE; - break; - } - case '}': - { - table--; - set = EINA_FALSE; - break; - } - default: - { - set = EINA_FALSE; - break; - } - } - - if (set) - { - if (table > 0) - lua_settable(L, -3); // Stack usage [-2, +0, e] - else - n++; - } - p = q; - } - - va_end(vl); - free(f); - return n; -} - - // TODO - These functions should be able to deal with multiple windows. // TODO - Should be able to open external and internal windows, and even switch between them on the fly. static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) @@ -742,7 +365,7 @@ int luaopen_libGuiLua(lua_State *L) // In theory this function only ever gets called once. memset(&ourGlobals, 0, sizeof(globals)); - loggingStartup(&ourGlobals); + ourGlobals.logDom = loggingStartup("GuiLua", ourGlobals.logDom); elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE); diff --git a/ClientHamr/GuiLua/GuiLua.h b/ClientHamr/GuiLua/GuiLua.h index 50aa3da..156fa1a 100644 --- a/ClientHamr/GuiLua/GuiLua.h +++ b/ClientHamr/GuiLua/GuiLua.h @@ -9,46 +9,21 @@ #include #include +#include "LumbrJack.h" +#include "Runnr.h" + typedef struct _globals globals; #define WIDTH (300) #define HEIGHT (300) -#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__) -#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__) -#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__) -#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__) -#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__) - -#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__) -#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__) -#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__) -#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__) -#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__) - -#define D() PD("DEBUG") - #define SKANG "skang" #define MODULEBEGIN "moduleBegin" #define MODULEEND "moduleEnd" #define THINGASM "thingasm" -// "01:03:52 01-01-1973\n\0" -#define DATE_TIME_LEN 21 -# define DATE_TIME_LEN 21 - - -#ifndef FALSE -// NEVER change this -typedef enum -{ - FALSE = 0, - TRUE = 1 -} boolean; -#endif - struct _globals { Evas_Object *win; // Our Elm window. @@ -56,13 +31,5 @@ struct _globals }; -void dumpStack(lua_State *L, int i); - -void loggingStartup(globals *ourGlobals); -char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); - -int pull_lua(lua_State *L, int i, char *params, ...); -int push_lua(lua_State *L, char *params, ...); - int luaopen_widget(lua_State *L); void GuiLuaDo(int argc, char **argv); diff --git a/ClientHamr/GuiLua/build.lua b/ClientHamr/GuiLua/build.lua index d2ffdd9..46a4cc5 100755 --- a/ClientHamr/GuiLua/build.lua +++ b/ClientHamr/GuiLua/build.lua @@ -6,7 +6,7 @@ if 'nil' == type(dir) then local build, err = loadfile('../../build.lua') if build then setfenv(build, getfenv(2)) - build('') + build(2) else print("ERROR - " .. err) end diff --git a/ClientHamr/extantz/build.lua b/ClientHamr/extantz/build.lua index ca67fec..096c5ff 100755 --- a/ClientHamr/extantz/build.lua +++ b/ClientHamr/extantz/build.lua @@ -6,7 +6,7 @@ if 'nil' == type(dir) then local build, err = loadfile('../../build.lua') if build then setfenv(build, getfenv(2)) - build('') + build(2) else print("ERROR - " .. err) end diff --git a/LuaSL/build.lua b/LuaSL/build.lua index 6b71532..c74cad6 100755 --- a/LuaSL/build.lua +++ b/LuaSL/build.lua @@ -6,7 +6,7 @@ if 'nil' == type(dir) then local build, err = loadfile('../build.lua') if build then setfenv(build, getfenv(2)) - build('') + build(1) else print("ERROR - " .. err) end diff --git a/LumbrJack/LumbrJack.c b/LumbrJack/LumbrJack.c deleted file mode 100644 index 9760766..0000000 --- a/LumbrJack/LumbrJack.c +++ /dev/null @@ -1,82 +0,0 @@ -/* LumbrJack - a logging library that wraps Eina logging. - -*/ - - -#include "LumbrJack.h" - - -static char dateTime[DATE_TIME_LEN]; - -static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args) -{ - FILE *f = data; - char dt[DATE_TIME_LEN + 1]; - char fileTab[256], funcTab[256]; - - getDateTime(NULL, dt, NULL); - dt[19] = '\0'; - if (12 > strlen(file)) - snprintf(fileTab, sizeof(fileTab), "%s\t\t", file); - else - snprintf(fileTab, sizeof(fileTab), "%s\t", file); - snprintf(funcTab, sizeof(funcTab), "\t%s", fnc); - fprintf(f, "%s ", dt); - if (f == stderr) - eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args); - else if (f == stdout) - eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args); - fflush(f); -} - -int loggingStartup(char *name, int logDom) -{ - if (logDom < 0) - { - logDom = eina_log_domain_register(name, NULL); - if (logDom < 0) - { - EINA_LOG_CRIT("could not register log domain '%s'", name); - return logDom; - } - } - eina_log_level_set(EINA_LOG_LEVEL_DBG); - eina_log_domain_level_set(name, EINA_LOG_LEVEL_DBG); - eina_log_print_cb_set(_ggg_log_print_cb, stderr); - - // Shut up the excess debugging shit from EFL. - eina_log_domain_level_set("eo", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("eldbus", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("eet", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("ecore", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("ecore_audio", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); - eina_log_domain_level_set("ecore_system_upower", EINA_LOG_LEVEL_WARN); - - return logDom; -} - -char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) -{ - struct tm *newTime; - time_t szClock; - char *date = dateTime; - - // Get time in seconds - time(&szClock); - // Convert time to struct tm form - newTime = localtime(&szClock); - - if (nowOut) - *nowOut = newTime; - if (dateOut) - date = dateOut; - if (timeOut) - *timeOut = szClock; - - // format - strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); - return (dateTime); -} diff --git a/LumbrJack/LumbrJack.h b/LumbrJack/LumbrJack.h deleted file mode 100644 index 4a3290c..0000000 --- a/LumbrJack/LumbrJack.h +++ /dev/null @@ -1,38 +0,0 @@ - -#include -#include - -#include - - -#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__) -#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__) -#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__) -#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__) -#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__) - -#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__) -#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__) -#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__) -#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__) -#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__) - -#define D() PD("DEBUG") - - -// "01:03:52 01-01-1973\n\0" -#define DATE_TIME_LEN 21 - - -#ifndef FALSE -// NEVER change this -typedef enum -{ - FALSE = 0, - TRUE = 1 -} boolean; -#endif - - -int loggingStartup(char *name, int logDom); -char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); diff --git a/LumbrJack/README b/LumbrJack/README deleted file mode 100644 index 367724f..0000000 --- a/LumbrJack/README +++ /dev/null @@ -1 +0,0 @@ -A library of logging stuff, coz every one wants to log. diff --git a/LumbrJack/build.lua b/LumbrJack/build.lua deleted file mode 100755 index 3181bef..0000000 --- a/LumbrJack/build.lua +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env lua - -local dir = ... - -if 'nil' == type(dir) then - local build, err = loadfile('../build.lua') - if build then - setfenv(build, getfenv(2)) - build('') - else - print("ERROR - " .. err) - end - dir = workingDir -end - -LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS - -removeFiles(dir, {'LumbrJack.o', 'libLumbrJack.so'}) - -runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c LumbrJack.c') -runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libLumbrJack.so -o libLumbrJack.so LumbrJack.o') diff --git a/Runnr/README b/Runnr/README deleted file mode 100644 index 65ddc0b..0000000 --- a/Runnr/README +++ /dev/null @@ -1 +0,0 @@ -A library for running Lua scripts. Named (sorta) after a friend of mine. diff --git a/Runnr/Runnr.c b/Runnr/Runnr.c deleted file mode 100644 index a24e7f5..0000000 --- a/Runnr/Runnr.c +++ /dev/null @@ -1,318 +0,0 @@ -/* Runnr - a library that deals with running Lua scripts. - -*/ - - -#include "Runnr.h" - - -void dumpStack(lua_State *L, int i) -{ - int type = lua_type(L, i); - - switch (type) - { - case LUA_TNONE : printf("Stack %d is empty\n", i); break; - case LUA_TNIL : printf("Stack %d is a nil\n", i); break; - case LUA_TBOOLEAN : printf("Stack %d is a boolean - %d\n", i, lua_toboolean(L, i)); break; - case LUA_TNUMBER : printf("Stack %d is a number\n - %f", i, lua_tonumber(L, i)); break; - case LUA_TSTRING : printf("Stack %d is a string - %s\n", i, lua_tostring(L, i)); break; - case LUA_TFUNCTION : printf("Stack %d is a function\n", i); break; - case LUA_TTHREAD : printf("Stack %d is a thread\n", i); break; - case LUA_TTABLE : - { - int j; - - printf("Stack %d is a table", i); - lua_getfield(L, i, "_NAME"); - j = lua_gettop(L); - if (lua_isstring(L, j)) - printf(" - %s", lua_tostring(L, j)); - lua_pop(L, 1); - printf("\n"); - break; - } - case LUA_TUSERDATA : printf("Stack %d is a userdata\n", i); break; - case LUA_TLIGHTUSERDATA : printf("Stack %d is a light userdata\n", i); break; - default : printf("Stack %d is unknown\n", i); break; - } -} - - -// These are what the various symbols are for each type - -// int % -// num # -// str $ -// bool ! -// C func & -// table.field @ Expects an integer and a string. -// nil ~ -// table {} Starts and stops filling up a new table. -// ( Just syntax sugar for call. -// call ) Expects an integer, the number of results left after the call. -// FIXME: Still to do, if we ever use them - -// stack = Get a value from the stack, expects a stack index. -// userdata + -// lightuserdata * -// thread ^ - -static char *_push_name(lua_State *L, char *q, int *idx) // Stack usage [-0, +1, e or m] -{ - char *p = q; - char temp = '\0'; - - // A simplistic scan through an identifier, it's wrong, but it's quick, - // and we don't mind that it's wrong, coz this is only internal. - while (isalnum((int)*q)) - q++; - temp = *q; - *q = '\0'; - if (*idx > 0) - lua_getfield(L, *idx, p); // Stack usage [-0, +1, e] - else - { - if (p != q) - lua_pushstring(L, p); // Stack usage [-0, +1, m] - else - { - lua_pushnumber(L, (lua_Number) (0 - (*idx))); - (*idx)--; - } - } - *q = temp; - - return q; -} - -int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage - - // if i is a table - // [-n, +n, e] - // else - // [-0, +0, -] -{ - va_list vl; - char *f = strdup(params); - char *p = f; - int n = 0, j = i, count = 0; - Eina_Bool table = EINA_FALSE; - - if (!f) return -1; - va_start(vl, params); - - if (lua_istable(L, i)) // Stack usage [-0, +0, -] - { - j = -1; - table = EINA_TRUE; - } - - while (*p) - { - char *q; - Eina_Bool get = EINA_TRUE; - - while (isspace((int)*p)) - p++; - q = p + 1; - switch (*p) - { - case '%': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] - { - int *v = va_arg(vl, int *); - *v = lua_tointeger(L, j); // Stack usage [-0, +0, -] - n++; - } - break; - } - case '#': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] - { - double *v = va_arg(vl, double *); - *v = lua_tonumber(L, j); // Stack usage [-0, +0, -] - n++; - } - break; - } - case '$': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isstring(L, j)) // Stack usage [-0, +0, -] - { - char **v = va_arg(vl, char **); - size_t len; - char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m] - - len++; // Cater for the null at the end. - *v = malloc(len); - if (*v) - { - memcpy(*v, temp, len); - n++; - } - } - break; - } - case '!': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] - if (lua_isboolean(L, j)) // Stack usage [-0, +0, -] - { - int *v = va_arg(vl, int *); - *v = lua_toboolean(L, j); // Stack usage [-0, +0, -] - n++; - } - break; - } - default: - { - get = EINA_FALSE; - break; - } - } - - if (get) - { - if (table) - { - // If this is a table, then we pushed a value on the stack, pop it off. - lua_pop(L, 1); // Stack usage [-n, +0, -] - } - else - j++; - count++; - } - p = q; - } - - va_end(vl); - free(f); - if (count > n) - n = 0; - else if (table) - n = 1; - return n; -} - -int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em] -{ - va_list vl; - char *f = strdup(params); - char *p = f; - int n = 0, table = 0, i = -1; - - if (!f) return -1; - - va_start(vl, params); - - while (*p) - { - char *q; - Eina_Bool set = EINA_TRUE; - - while (isspace((int)*p)) - p++; - q = p + 1; - switch (*p) - { - case '%': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushinteger(L, va_arg(vl, int)); // Stack usage [-0, +1, -] - break; - } - case '#': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushnumber(L, va_arg(vl, double)); // Stack usage [-0, +1, -] - break; - } - case '$': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushstring(L, va_arg(vl, char *)); // Stack usage [-0, +1, m] - break; - } - case '!': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushboolean(L, va_arg(vl, int)); // Stack usage [-0, +1, -] - break; - } - case '=': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushvalue(L, va_arg(vl, int)); // Stack usage [-0, +1, -] - break; - } - case '@': - { - int tabl = va_arg(vl, int); - char *field = va_arg(vl, char *); - - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_getfield(L, tabl, field); // Stack usage [-0, +1, e] - break; - } - case '&': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushcfunction(L, va_arg(vl, void *)); // Stack usage [-0, +1, m] - break; - } - case '~': - { - if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] - lua_pushnil(L); // Stack usage [-0, +1, -] - break; - } - case '(': // Just syntax sugar. - { - set = EINA_FALSE; - break; - } - case ')': - { - lua_call(L, n - 1, va_arg(vl, int)); - n = 0; - set = EINA_FALSE; - break; - } - case '{': - { - lua_newtable(L); - table++; - n++; - set = EINA_FALSE; - break; - } - case '}': - { - table--; - set = EINA_FALSE; - break; - } - default: - { - set = EINA_FALSE; - break; - } - } - - if (set) - { - if (table > 0) - lua_settable(L, -3); // Stack usage [-2, +0, e] - else - n++; - } - p = q; - } - - va_end(vl); - free(f); - return n; -} diff --git a/Runnr/Runnr.h b/Runnr/Runnr.h deleted file mode 100644 index dc720ff..0000000 --- a/Runnr/Runnr.h +++ /dev/null @@ -1,15 +0,0 @@ - -#include -#include - -#include - -#include -#include -#include -#include - - -void dumpStack(lua_State *L, int i); -int pull_lua(lua_State *L, int i, char *params, ...); -int push_lua(lua_State *L, char *params, ...); diff --git a/Runnr/build.lua b/Runnr/build.lua deleted file mode 100755 index 4384376..0000000 --- a/Runnr/build.lua +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env lua - -local dir = ... - -if 'nil' == type(dir) then - local build, err = loadfile('../build.lua') - if build then - setfenv(build, getfenv(2)) - build('') - else - print("ERROR - " .. err) - end - dir = workingDir -end - -LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS - -removeFiles(dir, {'Runnr.o', 'libRunnr.so'}) - -runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c Runnr.c') -runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libRunnr.so -o libRunnr.so Runnr.o') diff --git a/build.lua b/build.lua index c6b0748..c7177fa 100755 --- a/build.lua +++ b/build.lua @@ -49,13 +49,20 @@ local buildSub = function (name, dir) end end + +workingDir = readCommand('pwd') +baseDir = workingDir +if 'number' == type(args) then + for i = 1, args do + baseDir = string.gsub(baseDir, '(.*)/.-$', '%1') + end +end + -- Likely this will fail, coz Lua likes to strip out environmont variables. -- On the other hand, there's a more direct way to get to environment variables, it would fail to. CFLAGOPTS = readCommand('echo "$CFLAGOPTS"') -workingDir = readCommand('pwd') --- TODO - -I ../../libraries will be wrong for somethings, but right now those things don't care. -CFLAGS = '-g -Wall -I include -I ../../libraries' +CFLAGS = '-g -Wall -I include -I ' .. baseDir .. '/libraries' CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'luajit') CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'eo') CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'eet') @@ -72,8 +79,8 @@ CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. workingDir .. '\\"' CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. workingDir .. '\\"' CFLAGS = CFLAGS .. ' ' .. CFLAGOPTS -LDFLAGS = pkgConfig('libs-only-L', 'luajit') .. ' -L lib -L /usr/lib -L /lib' -libs = pkgConfig('libs', 'elementary') .. ' ' .. pkgConfig('libs', 'luajit') .. ' -lpthread -lm' +LDFLAGS = '-L ' .. baseDir .. '/libraries ' .. pkgConfig('libs-only-L', 'luajit') .. ' -L /usr/lib -L /lib' +libs = '-lLumbrJack -lRunnr ' .. pkgConfig('libs', 'elementary') .. ' ' .. pkgConfig('libs', 'luajit') .. ' -lpthread -lm' LFLAGS = '-d' EDJE_FLAGS = '-id images -fd fonts' @@ -85,9 +92,8 @@ if 'nil' == type(args) then compileFiles('lemon', 'libraries/lemon', {'lemon'}) print('_______________ BUILDING Irrlicht _______________') -- Irrlicht is an external project that comes with make files anyway, and doesn't otherwise pass the test. - runCommand('Irrlicht', 'libraries/irrlicht-1.8.1/source/Irrlicht', 'make') - buildSub('LumbrJack', 'LumbrJack') - buildSub('Runnr', 'Runnr') + runCommand('Irrlicht','libraries/irrlicht-1.8.1/source/Irrlicht', 'make') + buildSub('libraries', 'libraries') buildSub('LuaSL', 'LuaSL') buildSub('GuiLua', 'ClientHamr/GuiLua') buildSub('extantz', 'ClientHamr/extantz') diff --git a/libraries/LumbrJack.c b/libraries/LumbrJack.c new file mode 100644 index 0000000..9760766 --- /dev/null +++ b/libraries/LumbrJack.c @@ -0,0 +1,82 @@ +/* LumbrJack - a logging library that wraps Eina logging. + +*/ + + +#include "LumbrJack.h" + + +static char dateTime[DATE_TIME_LEN]; + +static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args) +{ + FILE *f = data; + char dt[DATE_TIME_LEN + 1]; + char fileTab[256], funcTab[256]; + + getDateTime(NULL, dt, NULL); + dt[19] = '\0'; + if (12 > strlen(file)) + snprintf(fileTab, sizeof(fileTab), "%s\t\t", file); + else + snprintf(fileTab, sizeof(fileTab), "%s\t", file); + snprintf(funcTab, sizeof(funcTab), "\t%s", fnc); + fprintf(f, "%s ", dt); + if (f == stderr) + eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args); + else if (f == stdout) + eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args); + fflush(f); +} + +int loggingStartup(char *name, int logDom) +{ + if (logDom < 0) + { + logDom = eina_log_domain_register(name, NULL); + if (logDom < 0) + { + EINA_LOG_CRIT("could not register log domain '%s'", name); + return logDom; + } + } + eina_log_level_set(EINA_LOG_LEVEL_DBG); + eina_log_domain_level_set(name, EINA_LOG_LEVEL_DBG); + eina_log_print_cb_set(_ggg_log_print_cb, stderr); + + // Shut up the excess debugging shit from EFL. + eina_log_domain_level_set("eo", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("eldbus", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("eet", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("ecore", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("ecore_audio", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); + eina_log_domain_level_set("ecore_system_upower", EINA_LOG_LEVEL_WARN); + + return logDom; +} + +char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) +{ + struct tm *newTime; + time_t szClock; + char *date = dateTime; + + // Get time in seconds + time(&szClock); + // Convert time to struct tm form + newTime = localtime(&szClock); + + if (nowOut) + *nowOut = newTime; + if (dateOut) + date = dateOut; + if (timeOut) + *timeOut = szClock; + + // format + strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); + return (dateTime); +} diff --git a/libraries/LumbrJack.h b/libraries/LumbrJack.h new file mode 100644 index 0000000..4a3290c --- /dev/null +++ b/libraries/LumbrJack.h @@ -0,0 +1,38 @@ + +#include +#include + +#include + + +#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__) +#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__) +#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__) +#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__) +#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__) + +#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__) +#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__) +#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__) +#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__) +#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__) + +#define D() PD("DEBUG") + + +// "01:03:52 01-01-1973\n\0" +#define DATE_TIME_LEN 21 + + +#ifndef FALSE +// NEVER change this +typedef enum +{ + FALSE = 0, + TRUE = 1 +} boolean; +#endif + + +int loggingStartup(char *name, int logDom); +char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); diff --git a/libraries/README b/libraries/README index 8ef38d3..a26fda1 100644 --- a/libraries/README +++ b/libraries/README @@ -21,3 +21,11 @@ that anymore. luaproc has been hacked up a bit, and will continue to be hacked up. Merged it into LuaSL, so it's no longer here. + +-------------------------------------------------------------------- + +These are the libraries written for the SledjHamr project. + +LumbrJack is a library of logging stuff, coz every one wants to log. + +Runnr is for running Lua scripts. Named (sorta) after a friend of mine. diff --git a/libraries/Runnr.c b/libraries/Runnr.c new file mode 100644 index 0000000..a24e7f5 --- /dev/null +++ b/libraries/Runnr.c @@ -0,0 +1,318 @@ +/* Runnr - a library that deals with running Lua scripts. + +*/ + + +#include "Runnr.h" + + +void dumpStack(lua_State *L, int i) +{ + int type = lua_type(L, i); + + switch (type) + { + case LUA_TNONE : printf("Stack %d is empty\n", i); break; + case LUA_TNIL : printf("Stack %d is a nil\n", i); break; + case LUA_TBOOLEAN : printf("Stack %d is a boolean - %d\n", i, lua_toboolean(L, i)); break; + case LUA_TNUMBER : printf("Stack %d is a number\n - %f", i, lua_tonumber(L, i)); break; + case LUA_TSTRING : printf("Stack %d is a string - %s\n", i, lua_tostring(L, i)); break; + case LUA_TFUNCTION : printf("Stack %d is a function\n", i); break; + case LUA_TTHREAD : printf("Stack %d is a thread\n", i); break; + case LUA_TTABLE : + { + int j; + + printf("Stack %d is a table", i); + lua_getfield(L, i, "_NAME"); + j = lua_gettop(L); + if (lua_isstring(L, j)) + printf(" - %s", lua_tostring(L, j)); + lua_pop(L, 1); + printf("\n"); + break; + } + case LUA_TUSERDATA : printf("Stack %d is a userdata\n", i); break; + case LUA_TLIGHTUSERDATA : printf("Stack %d is a light userdata\n", i); break; + default : printf("Stack %d is unknown\n", i); break; + } +} + + +// These are what the various symbols are for each type - +// int % +// num # +// str $ +// bool ! +// C func & +// table.field @ Expects an integer and a string. +// nil ~ +// table {} Starts and stops filling up a new table. +// ( Just syntax sugar for call. +// call ) Expects an integer, the number of results left after the call. +// FIXME: Still to do, if we ever use them - +// stack = Get a value from the stack, expects a stack index. +// userdata + +// lightuserdata * +// thread ^ + +static char *_push_name(lua_State *L, char *q, int *idx) // Stack usage [-0, +1, e or m] +{ + char *p = q; + char temp = '\0'; + + // A simplistic scan through an identifier, it's wrong, but it's quick, + // and we don't mind that it's wrong, coz this is only internal. + while (isalnum((int)*q)) + q++; + temp = *q; + *q = '\0'; + if (*idx > 0) + lua_getfield(L, *idx, p); // Stack usage [-0, +1, e] + else + { + if (p != q) + lua_pushstring(L, p); // Stack usage [-0, +1, m] + else + { + lua_pushnumber(L, (lua_Number) (0 - (*idx))); + (*idx)--; + } + } + *q = temp; + + return q; +} + +int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage - + // if i is a table + // [-n, +n, e] + // else + // [-0, +0, -] +{ + va_list vl; + char *f = strdup(params); + char *p = f; + int n = 0, j = i, count = 0; + Eina_Bool table = EINA_FALSE; + + if (!f) return -1; + va_start(vl, params); + + if (lua_istable(L, i)) // Stack usage [-0, +0, -] + { + j = -1; + table = EINA_TRUE; + } + + while (*p) + { + char *q; + Eina_Bool get = EINA_TRUE; + + while (isspace((int)*p)) + p++; + q = p + 1; + switch (*p) + { + case '%': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] + if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] + { + int *v = va_arg(vl, int *); + *v = lua_tointeger(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } + case '#': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] + if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] + { + double *v = va_arg(vl, double *); + *v = lua_tonumber(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } + case '$': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] + if (lua_isstring(L, j)) // Stack usage [-0, +0, -] + { + char **v = va_arg(vl, char **); + size_t len; + char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m] + + len++; // Cater for the null at the end. + *v = malloc(len); + if (*v) + { + memcpy(*v, temp, len); + n++; + } + } + break; + } + case '!': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e] + if (lua_isboolean(L, j)) // Stack usage [-0, +0, -] + { + int *v = va_arg(vl, int *); + *v = lua_toboolean(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } + default: + { + get = EINA_FALSE; + break; + } + } + + if (get) + { + if (table) + { + // If this is a table, then we pushed a value on the stack, pop it off. + lua_pop(L, 1); // Stack usage [-n, +0, -] + } + else + j++; + count++; + } + p = q; + } + + va_end(vl); + free(f); + if (count > n) + n = 0; + else if (table) + n = 1; + return n; +} + +int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em] +{ + va_list vl; + char *f = strdup(params); + char *p = f; + int n = 0, table = 0, i = -1; + + if (!f) return -1; + + va_start(vl, params); + + while (*p) + { + char *q; + Eina_Bool set = EINA_TRUE; + + while (isspace((int)*p)) + p++; + q = p + 1; + switch (*p) + { + case '%': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushinteger(L, va_arg(vl, int)); // Stack usage [-0, +1, -] + break; + } + case '#': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushnumber(L, va_arg(vl, double)); // Stack usage [-0, +1, -] + break; + } + case '$': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushstring(L, va_arg(vl, char *)); // Stack usage [-0, +1, m] + break; + } + case '!': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushboolean(L, va_arg(vl, int)); // Stack usage [-0, +1, -] + break; + } + case '=': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushvalue(L, va_arg(vl, int)); // Stack usage [-0, +1, -] + break; + } + case '@': + { + int tabl = va_arg(vl, int); + char *field = va_arg(vl, char *); + + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_getfield(L, tabl, field); // Stack usage [-0, +1, e] + break; + } + case '&': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushcfunction(L, va_arg(vl, void *)); // Stack usage [-0, +1, m] + break; + } + case '~': + { + if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] + lua_pushnil(L); // Stack usage [-0, +1, -] + break; + } + case '(': // Just syntax sugar. + { + set = EINA_FALSE; + break; + } + case ')': + { + lua_call(L, n - 1, va_arg(vl, int)); + n = 0; + set = EINA_FALSE; + break; + } + case '{': + { + lua_newtable(L); + table++; + n++; + set = EINA_FALSE; + break; + } + case '}': + { + table--; + set = EINA_FALSE; + break; + } + default: + { + set = EINA_FALSE; + break; + } + } + + if (set) + { + if (table > 0) + lua_settable(L, -3); // Stack usage [-2, +0, e] + else + n++; + } + p = q; + } + + va_end(vl); + free(f); + return n; +} diff --git a/libraries/Runnr.h b/libraries/Runnr.h new file mode 100644 index 0000000..dc720ff --- /dev/null +++ b/libraries/Runnr.h @@ -0,0 +1,15 @@ + +#include +#include + +#include + +#include +#include +#include +#include + + +void dumpStack(lua_State *L, int i); +int pull_lua(lua_State *L, int i, char *params, ...); +int push_lua(lua_State *L, char *params, ...); diff --git a/libraries/build.lua b/libraries/build.lua new file mode 100755 index 0000000..8b48b70 --- /dev/null +++ b/libraries/build.lua @@ -0,0 +1,24 @@ +#!/usr/bin/env lua + +local dir = ... + +if 'nil' == type(dir) then + local build, err = loadfile('../build.lua') + if build then + setfenv(build, getfenv(2)) + build('') + else + print("ERROR - " .. err) + end + dir = workingDir +end + +LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS + +removeFiles(dir, {'LumbrJack.o', 'libLumbrJack.so', 'Runnr.o', 'libRunnr.so'}) + +runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c LumbrJack.c') +runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libLumbrJack.so -o libLumbrJack.so LumbrJack.o') + +runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c Runnr.c') +runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libRunnr.so -o libRunnr.so Runnr.o') -- cgit v1.1