diff options
author | David Walter Seikel | 2014-05-20 23:34:25 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-20 23:34:25 +1000 |
commit | 909fd6e2c4369020707782e20656069fbb3030d1 (patch) | |
tree | 15590f94950be42916fff1b3ba00124bce157751 /src/LuaSL | |
parent | The results of a session with valgrind. (diff) | |
download | SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.zip SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.tar.gz SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.tar.bz2 SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.tar.xz |
Found a way to deal with the PACKAGE_* stuff outside of Elm. It's undocumented.
Diffstat (limited to 'src/LuaSL')
-rw-r--r-- | src/LuaSL/LuaSL.h | 1 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_compile.c | 4 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 26 | ||||
-rwxr-xr-x | src/LuaSL/build.lua | 7 |
4 files changed, 8 insertions, 30 deletions
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 @@ | |||
1 | #ifdef HAVE_CONFIG_H | 1 | #ifdef HAVE_CONFIG_H |
2 | #include "config.h" | 2 | #include "config.h" |
3 | #else | 3 | #else |
4 | //#define PACKAGE_EXAMPLES_DIR "." | ||
5 | #define __UNUSED__ | 4 | #define __UNUSED__ |
6 | #endif | 5 | #endif |
7 | 6 | ||
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) | |||
2194 | } | 2194 | } |
2195 | 2195 | ||
2196 | // Compile the constants. | 2196 | // Compile the constants. |
2197 | snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", PACKAGE_LIB_DIR); | 2197 | snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", prefix_lib_get()); |
2198 | system(buf); | 2198 | system(buf); |
2199 | snprintf(buf, sizeof(buf), "%s/constants.lsl", PACKAGE_LIB_DIR); | 2199 | snprintf(buf, sizeof(buf), "%s/constants.lsl", prefix_lib_get()); |
2200 | compileLSL(ourGlobals, NULL, "FAKE_SID", buf, TRUE); | 2200 | compileLSL(ourGlobals, NULL, "FAKE_SID", buf, TRUE); |
2201 | 2201 | ||
2202 | return TRUE; | 2202 | 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 @@ | |||
4 | #include "SledjHamr.h" | 4 | #include "SledjHamr.h" |
5 | 5 | ||
6 | 6 | ||
7 | int logDom; // Our logging domain. | 7 | int logDom = -1; // Our logging domain. |
8 | static int CPUs = 4; | 8 | static int CPUs = 4; |
9 | static Eina_Strbuf *clientStream; | 9 | static Eina_Strbuf *clientStream; |
10 | 10 | ||
@@ -61,7 +61,7 @@ static void resetScript(script *victim) | |||
61 | gettimeofday(&me->startTime, NULL); | 61 | gettimeofday(&me->startTime, NULL); |
62 | strncpy(me->SID, victim->SID, sizeof(me->SID)); | 62 | strncpy(me->SID, victim->SID, sizeof(me->SID)); |
63 | strncpy(me->fileName, victim->fileName, sizeof(me->fileName)); | 63 | strncpy(me->fileName, victim->fileName, sizeof(me->fileName)); |
64 | me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; | 64 | me->name = &me->fileName[strlen(prefix_data_get())]; |
65 | me->game = ourGlobals; | 65 | me->game = ourGlobals; |
66 | me->client = victim->client; | 66 | me->client = victim->client; |
67 | eina_hash_add(ourGlobals->scripts, me->SID, me); | 67 | 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 | |||
205 | temp++; | 205 | temp++; |
206 | temp[0] = '\0'; | 206 | temp[0] = '\0'; |
207 | 207 | ||
208 | name = &file[sizeof(PACKAGE_DATA_DIR)]; | 208 | name = &file[strlen(prefix_data_get())]; |
209 | PD("Compiling %s, %s.", SID, name); | 209 | PD("Compiling %s, %s.", SID, name); |
210 | if (compileLSL(ourGlobals, ev->client, SID, file, FALSE)) | 210 | if (compileLSL(ourGlobals, ev->client, SID, file, FALSE)) |
211 | { | 211 | { |
@@ -214,7 +214,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D | |||
214 | gettimeofday(&me->startTime, NULL); | 214 | gettimeofday(&me->startTime, NULL); |
215 | strncpy(me->SID, SID, sizeof(me->SID)); | 215 | strncpy(me->SID, SID, sizeof(me->SID)); |
216 | strncpy(me->fileName, file, sizeof(me->fileName)); | 216 | strncpy(me->fileName, file, sizeof(me->fileName)); |
217 | me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; | 217 | me->name = &me->fileName[strlen(prefix_data_get())]; |
218 | me->game = ourGlobals; | 218 | me->game = ourGlobals; |
219 | me->client = ev->client; | 219 | me->client = ev->client; |
220 | eina_hash_add(ourGlobals->scripts, me->SID, me); | 220 | 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 | |||
275 | int main(int argc, char **argv) | 275 | int main(int argc, char **argv) |
276 | { | 276 | { |
277 | gameGlobals ourGlobals; | 277 | gameGlobals ourGlobals; |
278 | char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; | ||
279 | int result = EXIT_FAILURE; | 278 | int result = EXIT_FAILURE; |
280 | 279 | ||
281 | // Sigh, Elm has this great thing for dealing with bin, lib, and data directories, but this is not an Elm app, | ||
282 | // And Elm is too heavy for just that little bit. | ||
283 | // So just duplicate a bit of what we need here. Sorta. | ||
284 | getcwd(cwd, PATH_MAX); | ||
285 | env = getenv("LUA_CPATH"); | ||
286 | if (!env) env = ""; | ||
287 | sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, PACKAGE_LIB_DIR, PACKAGE_LIB_DIR, cwd); | ||
288 | setenv("LUA_CPATH", temp, 1); | ||
289 | |||
290 | env = getenv("LUA_PATH"); | ||
291 | if (!env) env = ""; | ||
292 | sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, PACKAGE_LIB_DIR, cwd); | ||
293 | setenv("LUA_PATH", temp, 1); | ||
294 | |||
295 | memset(&ourGlobals, 0, sizeof(gameGlobals)); | 280 | memset(&ourGlobals, 0, sizeof(gameGlobals)); |
296 | ourGlobals.address = "127.0.0.1"; | 281 | ourGlobals.address = "127.0.0.1"; |
297 | ourGlobals.port = 8211; | 282 | ourGlobals.port = 8211; |
298 | 283 | ||
299 | if (eina_init()) | 284 | if (eina_init()) |
300 | { | 285 | { |
301 | logDom = loggingStartup("LuaSL", logDom); | 286 | logDom = HamrTime(argv[0], main, logDom); |
302 | ourGlobals.scripts = eina_hash_string_superfast_new(NULL); | 287 | ourGlobals.scripts = eina_hash_string_superfast_new(NULL); |
303 | ourGlobals.names = eina_hash_string_superfast_new(NULL); | 288 | ourGlobals.names = eina_hash_string_superfast_new(NULL); |
304 | if (ecore_init()) | 289 | if (ecore_init()) |
@@ -356,6 +341,7 @@ int main(int argc, char **argv) | |||
356 | } | 341 | } |
357 | else | 342 | else |
358 | PC("Failed to init ecore!"); | 343 | PC("Failed to init ecore!"); |
344 | pantsOff(logDom); | ||
359 | } | 345 | } |
360 | else | 346 | else |
361 | fprintf(stderr, "Failed to init eina!"); | 347 | 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', | |||
19 | -- Run lemon first, flex depends on it to define the symbol values. | 19 | -- Run lemon first, flex depends on it to define the symbol values. |
20 | runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y') | 20 | runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y') |
21 | runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l') | 21 | runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l') |
22 | |||
23 | -- While SledHamr.c does this, we can't use that here, coz LuaSL is not an Elm app. | ||
24 | CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. bin_d .. '\\"' | ||
25 | CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"' | ||
26 | CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' | ||
27 | CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' | ||
28 | |||
29 | compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') | 22 | compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') |