From 909fd6e2c4369020707782e20656069fbb3030d1 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 20 May 2014 23:34:25 +1000 Subject: Found a way to deal with the PACKAGE_* stuff outside of Elm. It's undocumented. --- src/LuaSL/LuaSL.h | 1 - src/LuaSL/LuaSL_compile.c | 4 ++-- src/LuaSL/LuaSL_main.c | 26 ++++++-------------------- src/LuaSL/build.lua | 7 ------- 4 files changed, 8 insertions(+), 30 deletions(-) (limited to 'src/LuaSL') diff --git a/src/LuaSL/LuaSL.h b/src/LuaSL/LuaSL.h index d43d6cd..299477b 100644 --- a/src/LuaSL/LuaSL.h +++ b/src/LuaSL/LuaSL.h @@ -1,7 +1,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #else -//#define PACKAGE_EXAMPLES_DIR "." #define __UNUSED__ #endif diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index 4fe5671..afe7ec0 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c @@ -2194,9 +2194,9 @@ boolean compilerSetup(gameGlobals *ourGlobals) } // Compile the constants. - snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", PACKAGE_LIB_DIR); + snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", prefix_lib_get()); system(buf); - snprintf(buf, sizeof(buf), "%s/constants.lsl", PACKAGE_LIB_DIR); + snprintf(buf, sizeof(buf), "%s/constants.lsl", prefix_lib_get()); compileLSL(ourGlobals, NULL, "FAKE_SID", buf, TRUE); return TRUE; diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 32ed090..2c40348 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c @@ -4,7 +4,7 @@ #include "SledjHamr.h" -int logDom; // Our logging domain. +int logDom = -1; // Our logging domain. static int CPUs = 4; static Eina_Strbuf *clientStream; @@ -61,7 +61,7 @@ static void resetScript(script *victim) gettimeofday(&me->startTime, NULL); strncpy(me->SID, victim->SID, sizeof(me->SID)); strncpy(me->fileName, victim->fileName, sizeof(me->fileName)); - me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; + me->name = &me->fileName[strlen(prefix_data_get())]; me->game = ourGlobals; me->client = victim->client; eina_hash_add(ourGlobals->scripts, me->SID, me); @@ -205,7 +205,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D temp++; temp[0] = '\0'; - name = &file[sizeof(PACKAGE_DATA_DIR)]; + name = &file[strlen(prefix_data_get())]; PD("Compiling %s, %s.", SID, name); if (compileLSL(ourGlobals, ev->client, SID, file, FALSE)) { @@ -214,7 +214,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D gettimeofday(&me->startTime, NULL); strncpy(me->SID, SID, sizeof(me->SID)); strncpy(me->fileName, file, sizeof(me->fileName)); - me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; + me->name = &me->fileName[strlen(prefix_data_get())]; me->game = ourGlobals; me->client = ev->client; eina_hash_add(ourGlobals->scripts, me->SID, me); @@ -275,30 +275,15 @@ static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_De int main(int argc, char **argv) { gameGlobals ourGlobals; - char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; int result = EXIT_FAILURE; - // Sigh, Elm has this great thing for dealing with bin, lib, and data directories, but this is not an Elm app, - // And Elm is too heavy for just that little bit. - // So just duplicate a bit of what we need here. Sorta. - getcwd(cwd, PATH_MAX); - env = getenv("LUA_CPATH"); - if (!env) env = ""; - sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, PACKAGE_LIB_DIR, PACKAGE_LIB_DIR, cwd); - setenv("LUA_CPATH", temp, 1); - - env = getenv("LUA_PATH"); - if (!env) env = ""; - sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, PACKAGE_LIB_DIR, cwd); - setenv("LUA_PATH", temp, 1); - memset(&ourGlobals, 0, sizeof(gameGlobals)); ourGlobals.address = "127.0.0.1"; ourGlobals.port = 8211; if (eina_init()) { - logDom = loggingStartup("LuaSL", logDom); + logDom = HamrTime(argv[0], main, logDom); ourGlobals.scripts = eina_hash_string_superfast_new(NULL); ourGlobals.names = eina_hash_string_superfast_new(NULL); if (ecore_init()) @@ -356,6 +341,7 @@ int main(int argc, char **argv) } else PC("Failed to init ecore!"); + pantsOff(logDom); } else fprintf(stderr, "Failed to init eina!"); diff --git a/src/LuaSL/build.lua b/src/LuaSL/build.lua index 084a39c..de16c2b 100755 --- a/src/LuaSL/build.lua +++ b/src/LuaSL/build.lua @@ -19,11 +19,4 @@ removeFiles(dir, {'../../LuaSL', '*.o', '*.output', '*.backup', 'LuaSL_lexer.h', -- Run lemon first, flex depends on it to define the symbol values. runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y') runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l') - --- While SledHamr.c does this, we can't use that here, coz LuaSL is not an Elm app. -CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. bin_d .. '\\"' -CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"' -CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' -CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' - compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') -- cgit v1.1