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/GuiLua/GuiLua.c | 10 +----- src/GuiLua/GuiLua.h | 1 + src/GuiLua/skang.c | 6 ++-- src/GuiLua/test_c.c | 3 +- src/LuaSL/LuaSL.h | 1 - src/LuaSL/LuaSL_compile.c | 4 +-- src/LuaSL/LuaSL_main.c | 26 ++++----------- src/LuaSL/build.lua | 7 ---- src/extantz/Evas_3D_demo.c | 8 ++--- src/extantz/ephysics_demo.c | 4 +-- src/extantz/extantz.c | 27 +++++---------- src/extantz/extantz.h | 1 + src/extantz/woMan.c | 6 ++-- src/libraries/LumbrJack.c | 81 ++++++++++++++++++++++++++++++++++++++++++--- src/libraries/LumbrJack.h | 19 +++++++++++ src/libraries/SledjHamr.h | 8 ----- src/libraries/build.lua | 11 +++--- src/libraries/winFang.c | 40 ++-------------------- src/libraries/winFang.h | 11 ------ src/love/build.lua | 6 ---- src/love/love.c | 17 +++++----- src/purkle/purkle.c | 2 +- 22 files changed, 149 insertions(+), 150 deletions(-) (limited to 'src') diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 5815b45..1ffbc0f 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c @@ -142,12 +142,10 @@ and ordinary elementary widgets. Proper introspection can come later. */ -#include "LumbrJack.h" #include "GuiLua.h" #include "Runnr.h" -static int logDom; // Our logging domain. const char *glName = "ourGuiLua"; /* Sooo, how to do this - @@ -373,7 +371,6 @@ int luaopen_GuiLua(lua_State *L) printf("**********************require GuiLua\n"); // In theory this function only ever gets called once. - logDom = loggingStartup("GuiLua", logDom); elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE); @@ -474,18 +471,13 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent, EPhysics_World *world) PE("Error running - skang.loopWindow()"); GuiLuaDel(result); result = NULL; - if (logDom >= 0) - { - eina_log_domain_unregister(logDom); - logDom = -1; - } // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. elm_shutdown(); } } else - fprintf(stderr, "Failed to start Lua!\n"); + PE("Failed to start Lua!"); return result; } diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h index d82d244..216ce8a 100644 --- a/src/GuiLua/GuiLua.h +++ b/src/GuiLua/GuiLua.h @@ -2,6 +2,7 @@ #define _GUILUA_H_ +#include "LumbrJack.h" #include "Runnr.h" #include "winFang.h" diff --git a/src/GuiLua/skang.c b/src/GuiLua/skang.c index c116f30..3aee0e2 100644 --- a/src/GuiLua/skang.c +++ b/src/GuiLua/skang.c @@ -1,11 +1,13 @@ -#include "SledjHamr.h" #include "GuiLua.h" +int logDom = -1; + EAPI_MAIN int elm_main(int argc, char **argv) { - HamrTime(elm_main, "GuiLua"); + logDom = HamrTime(argv[0], elm_main, logDom); GuiLuaDo(argc, argv, NULL, NULL); + pantsOff(logDom); return 0; } diff --git a/src/GuiLua/test_c.c b/src/GuiLua/test_c.c index e85814b..ed680b0 100644 --- a/src/GuiLua/test_c.c +++ b/src/GuiLua/test_c.c @@ -10,7 +10,6 @@ http://lua-users.org/lists/lua-l/2008-01/msg00671.html */ -//#include "LumbrJack.h" #include "Runnr.h" #include "GuiLua.h" @@ -23,7 +22,7 @@ static int cfunc (lua_State *L) double arg1 = luaL_checknumber(L, 1); const char *arg2 = luaL_checkstring(L, 2); - printf("Inside %s.cfunc(%f, %s)\n", ourName, arg1, arg2); + PI("Inside %s.cfunc(%f, %s)\n", ourName, arg1, arg2); return 0; } 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'}, '') diff --git a/src/extantz/Evas_3D_demo.c b/src/extantz/Evas_3D_demo.c index 3dda9ef..6cb673b 100644 --- a/src/extantz/Evas_3D_demo.c +++ b/src/extantz/Evas_3D_demo.c @@ -286,7 +286,7 @@ static void _cube_setup(globals *ourGlobals, Scene_Data *scene) evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) ); - snprintf(buf, sizeof(buf), "%s/normal_lego.png", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/normal_lego.png", prefix_data_get()); scene->texture_normal = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, evas_3d_texture_file_set(buf, NULL) ); @@ -354,7 +354,7 @@ static void _sonic_setup(globals *ourGlobals, Scene_Data *scene) char buf[PATH_MAX]; // Setup an MD2 mesh. - snprintf(buf, sizeof(buf), "%s/sonic.png", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/sonic.png", prefix_data_get()); scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, evas_3d_texture_file_set(buf, NULL), evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), @@ -375,7 +375,7 @@ static void _sonic_setup(globals *ourGlobals, Scene_Data *scene) evas_3d_material_shininess_set(50.0) ); - snprintf(buf, sizeof(buf), "%s/sonic.md2", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/sonic.md2", prefix_data_get()); scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, buf, NULL), evas_3d_mesh_frame_material_set(0, scene->material2), @@ -397,7 +397,7 @@ static void _earth_setup(globals *ourGlobals, Scene_Data *scene) char buf[PATH_MAX]; // Setup earth material. - snprintf(buf, sizeof(buf), "%s/EarthDiffuse.png", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/EarthDiffuse.png", prefix_data_get()); scene->texture_diffuse = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, evas_3d_texture_file_set(buf, NULL), evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR) diff --git a/src/extantz/ephysics_demo.c b/src/extantz/ephysics_demo.c index a0bf4d0..89dda99 100644 --- a/src/extantz/ephysics_demo.c +++ b/src/extantz/ephysics_demo.c @@ -32,7 +32,7 @@ EPhysics_World *ephysicsAdd(globals *ourGlobals) ephysics_body_restitution_set(boundary, 1); ephysics_body_friction_set(boundary, 0); - sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME); + sprintf(buf, "%s/%s.edj", prefix_data_get(), EPHYSICS_TEST_THEME); box1 = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win, elm_obj_image_file_set(buf, "blue-cube"), evas_obj_size_set(70, 70), @@ -49,7 +49,7 @@ EPhysics_World *ephysicsAdd(globals *ourGlobals) ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1); eo_unref(box1); - sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME); + sprintf(buf, "%s/%s.edj", prefix_data_get(), EPHYSICS_TEST_THEME); box2 = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win, elm_obj_image_file_set(buf, "purple-cube"), evas_obj_size_set(70, 70), diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index fa38251..a27118b 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -2,14 +2,13 @@ #include "extantz.h" #include "SledjHamr.h" -#include "LumbrJack.h" static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo); static void on_pixels(void *data, Evas_Object *obj); -static int logDom; // Our logging domain. +int logDom = -1; // Our logging domain. globals ourGlobals; static Eina_Strbuf *serverStream; @@ -120,7 +119,7 @@ static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev) PW("Failed to connect to a world server, starting our own."); // TODO - Should use Ecore_Exe for this sort of thing. - sprintf(buf, "%s/love &", elm_app_bin_dir_get()); + sprintf(buf, "%s/love &", prefix_bin_get()); system(buf); count = 0; } @@ -555,6 +554,8 @@ EAPI_MAIN int elm_main(int argc, char **argv) char buf[PATH_MAX * 2]; // Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. + logDom = HamrTime(argv[0], elm_main, logDom); + /* Set the locale according to the system pref. * If you don't do so the file selector will order the files list in * a case sensitive manner @@ -564,13 +565,6 @@ EAPI_MAIN int elm_main(int argc, char **argv) elm_need_ethumb(); elm_need_efreet(); - HamrTime(elm_main, "extantz"); - fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get()); - fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get()); - fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); - fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); - - logDom = loggingStartup("extantz", logDom); ourGlobals.running = 1; @@ -643,7 +637,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) // Override the background image #if 1 - snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/sky_03.jpg", prefix_data_get()); ourGlobals.mainWindow->bg = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals.mainWindow->win, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), elm_obj_image_fill_outside_set(EINA_TRUE), @@ -652,7 +646,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) ); elm_win_resize_object_add(ourGlobals.mainWindow->win, ourGlobals.mainWindow->bg); #else - snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/sky_03.jpg", prefix_data_get()); eo_do(ourGlobals.mainWindow->bg, elm_obj_image_file_set(buf, NULL), evas_obj_color_set(255, 255, 255, 255) @@ -673,7 +667,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) woMan_add(&ourGlobals); ourGlobals.purkle = GuiLuaLoad("purkle", ourGlobals.mainWindow, ourGlobals.world); ourGlobals.LSLGuiMess = GuiLuaLoad("LSLGuiMess", ourGlobals.mainWindow, ourGlobals.world); - ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); + ourGlobals.files = filesAdd(&ourGlobals, (char *) prefix_data_get(), EINA_TRUE, EINA_FALSE); // Try to connect to the love server we started before. serverStream = eina_strbuf_new(); @@ -701,11 +695,8 @@ EAPI_MAIN int elm_main(int argc, char **argv) winFangDel(ourGlobals.mainWindow); } - if (logDom >= 0) - { - eina_log_domain_unregister(logDom); - logDom = -1; - } + pantsOff(logDom); + logDom = -1; elm_shutdown(); diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index a41f4e0..ca62bdc 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -6,6 +6,7 @@ #define DO_GEARS 0 +#include "LumbrJack.h" #include "winFang.h" #include "GuiLua.h" #include "scenri.h" diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index ef10631..09e7e2d 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -35,8 +35,8 @@ static Elm_Genlist_Item_Class *grid_gic = NULL; static Elm_Genlist_Item_Class *account_gic = NULL; static Elm_Genlist_Item_Class *viewer_gic = NULL; -//static const char *img1 = PACKAGE_DATA_DIR "plant_01.jpg"; -//static const char *img2 = PACKAGE_DATA_DIR "sky_01.jpg"; +//static const char *img1 = "plant_01.jpg"; +//static const char *img2 = "sky_01.jpg"; static const char *img3 = "rock_01.jpg"; @@ -264,7 +264,7 @@ winFang *woMan_add(globals *ourGlobals) evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(nf); - sprintf(buf, "%s/%s", elm_app_data_dir_get(), img3); + sprintf(buf, "%s/%s", prefix_data_get(), img3); tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it); // TODO - This strdup leaks, but this is just temporary test code anyway, it will go away. tab = _content_image_new(me->win, strdup(buf)); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it); diff --git a/src/libraries/LumbrJack.c b/src/libraries/LumbrJack.c index 8d08622..56d4c50 100644 --- a/src/libraries/LumbrJack.c +++ b/src/libraries/LumbrJack.c @@ -4,11 +4,82 @@ #include "LumbrJack.h" +#include static char dateTime[DATE_TIME_LEN]; +static Eina_Prefix *prefix = NULL; -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) + +int HamrTime(char *argv0, void *main, int logDom) +{ + Eina_Array *path; + char *env, name[PATH_MAX], cwd[PATH_MAX], temp[PATH_MAX * 2]; + int i, len = strlen(argv0); + + if (!eina_init()) + { + printf("Can't load eina library, nothing else will work!\n"); + exit(0); + } + + // Coz eina_file_split splits the string in place, instead of making a copy first. + snprintf(temp, sizeof(temp), "%s", argv0); + path = eina_file_split(temp); + snprintf(name, sizeof(name), "%s", (char *) eina_array_data_get(path, eina_array_count(path) - 1)); + logDom = loggingStartup(name, logDom); + eina_array_free(path); + + temp[len] = 0; + cwd[len] = 0; + for (i = 0; i < len; i++) + { + temp[i] = toupper(name[i]); + cwd[i] = tolower(name[i]); + } + + if (!(prefix = eina_prefix_new(argv0, main, temp, cwd, "checkme.txt", PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, PACKAGE_DATA_DIR, PACKAGE_LOCALE_DIR))) + { + PC("Can't find application prefix!"); + } + + PD("%s is installed in %s", name, eina_prefix_get(prefix)); + PD("The binaries are in %s", eina_prefix_bin_get(prefix)); + PD("The data files are in %s", eina_prefix_data_get(prefix)); + PD("The libraries are in %s", eina_prefix_lib_get(prefix)); + PD("The locale files are in %s", eina_prefix_locale_get(prefix)); + + getcwd(cwd, PATH_MAX); + env = getenv("LUA_CPATH"); + if (!env) env = ""; + sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, eina_prefix_lib_get(prefix), eina_prefix_lib_get(prefix), cwd); + setenv("LUA_CPATH", temp, 1); + + env = getenv("LUA_PATH"); + if (!env) env = ""; + sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, eina_prefix_lib_get(prefix), cwd); + setenv("LUA_PATH", temp, 1); + + return logDom; +} + +const char *prefix_get() {return eina_prefix_get(prefix);} +const char *prefix_bin_get() {return eina_prefix_bin_get(prefix);} +const char *prefix_data_get() {return eina_prefix_data_get(prefix);} +const char *prefix_lib_get() {return eina_prefix_lib_get(prefix);} +const char *prefix_locale_get() {return eina_prefix_locale_get(prefix);} + +void pantsOff(int logDom) +{ + if (logDom >= 0) + eina_log_domain_unregister(logDom); + + eina_prefix_free(prefix); + + eina_shutdown(); +} + +static void _logPrint(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]; @@ -31,9 +102,11 @@ static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, co int loggingStartup(char *name, int logDom) { + eina_log_threads_enable(); + if (logDom < 0) { - logDom = eina_log_domain_register(name, NULL); + logDom = eina_log_domain_register(name, EINA_COLOR_ORANGE); if (logDom < 0) { EINA_LOG_CRIT("could not register log domain '%s'", name); @@ -42,7 +115,7 @@ int loggingStartup(char *name, int 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); + eina_log_print_cb_set(_logPrint, stderr); // Shut up the excess debugging shit from EFL. eina_log_domain_level_set("eo", EINA_LOG_LEVEL_WARN); @@ -83,7 +156,7 @@ char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) *timeOut = szClock; // format - strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); + strftime(date, DATE_TIME_LEN, "%Y-%m-%d %H:%M:%S\r", newTime); return (dateTime); } diff --git a/src/libraries/LumbrJack.h b/src/libraries/LumbrJack.h index 1912bef..74249ed 100644 --- a/src/libraries/LumbrJack.h +++ b/src/libraries/LumbrJack.h @@ -2,6 +2,15 @@ #define _LUMBRJACK_H_ +#define EFL_API_OVERRIDE 1 +/* Enable access to unstable EFL API that are still in beta */ +#define EFL_BETA_API_SUPPORT 1 +/* Enable access to unstable EFL EO API. */ +#define EFL_EO_API_SUPPORT 1 + +#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*array)) + + #include #include @@ -31,6 +40,16 @@ typedef enum #endif +extern int logDom; + +int HamrTime(char *argv0, void *main, int logDom); +const char *prefix_get(void); +const char *prefix_bin_get(void); +const char *prefix_data_get(void); +const char *prefix_lib_get(void); +const char *prefix_locale_get(void); +void pantsOff(int logDom); + int loggingStartup(char *name, int logDom); char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); float timeDiff(struct timeval *now, struct timeval *then); diff --git a/src/libraries/SledjHamr.h b/src/libraries/SledjHamr.h index 6c63bcc..7ce32b9 100644 --- a/src/libraries/SledjHamr.h +++ b/src/libraries/SledjHamr.h @@ -2,20 +2,12 @@ #define _SLEDJHAMR_H_ -#define EFL_API_OVERRIDE 1 -/* Enable access to unstable EFL API that are still in beta */ -#define EFL_BETA_API_SUPPORT 1 -/* Enable access to unstable EFL EO API. */ -#define EFL_EO_API_SUPPORT 1 - #include #include #include -#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*array)) - Ecore_Con_Server *reachOut(char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del); void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...); void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...); diff --git a/src/libraries/build.lua b/src/libraries/build.lua index 45c436d..76e9d94 100755 --- a/src/libraries/build.lua +++ b/src/libraries/build.lua @@ -13,6 +13,12 @@ if 'nil' == type(dir) then dir = workingDir end +-- For EFL apps, these are all centrally controlled in libLumbrJack. +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 .. '\\"' + LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS removeFiles(dir, {'LumbrJack.o', lib_d .. '/libLumbrJack.so', 'Runnr.o', lib_d .. '/libRunnr.so', 'SledjHamr.o', lib_d .. '/libSledjHamr.so', '../../media/winFang.edj', 'winFang.o', lib_d .. '/libwinFang.so'}) @@ -23,11 +29,6 @@ runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libLumbrJack.so runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c Runnr.c') runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libRunnr.so -o ' .. lib_d .. '/libRunnr.so Runnr.o') --- For Elm apps, these are all centrally controlled in libSledjHamr. -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 .. '\\"' runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c SledjHamr.c') runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libSledjHamr.so -o ' .. lib_d .. '/libSledjHamr.so SledjHamr.o') diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c index bfd9327..9319a18 100644 --- a/src/libraries/winFang.c +++ b/src/libraries/winFang.c @@ -1,41 +1,7 @@ +#include "LumbrJack.h" #include "winFang.h" -void HamrTime(void *elm_main, char *domain) -{ - char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; - - elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); - elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); - elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR); - elm_app_compile_locale_set(PACKAGE_LOCALE_DIR); - // Do this after the above calls, but before changing the working directory, or screwing with argv[0]. - // It tries to set up the package paths depending on where the executable is, so things are relocatable. - // First argument is the elm_main() function that Elementary starts us from. - // Second argument should be a lower case string used as the "domain", which is different from the log domain. - // It's used lower case as part of the data directory path. - // So, if prefix is /usr/local, then the system data dir is /usr/local/share, - // and this apps data dir is /usr/local/share/"domain". - // It's used upper case as part of environment variables to override directory paths at run time. - // So "DOMAIN"_PREFIX, "DOMAIN"_BIN_DIR, "DOMAIN"_LIB_DIR, "DOMAIN"_DATA_DIR, and "DOMAIN"_LOCALE_DIR - // Third argument is the name of a file it can check for to make sure it found the correct path. - // This file is looked for in the data dir. - elm_app_info_set(elm_main, domain, "checkme.txt"); - // Once this is all setup, the code can do - - // elm_app_prefix_dir_get(); // or bin, lib, data, locale. - - getcwd(cwd, PATH_MAX); - env = getenv("LUA_CPATH"); - if (!env) env = ""; - sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, elm_app_lib_dir_get(), elm_app_lib_dir_get(), cwd); - setenv("LUA_CPATH", temp, 1); - - env = getenv("LUA_PATH"); - if (!env) env = ""; - sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, elm_app_lib_dir_get(), cwd); - setenv("LUA_PATH", temp, 1); -} - static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { Evas_Object *test; @@ -244,7 +210,7 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch x = 0; y = 0; } - snprintf(buf, sizeof(buf), "%s/winFang.edj", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/winFang.edj", prefix_data_get()); result->layout = eo_add(ELM_OBJ_LAYOUT_CLASS, obj, evas_obj_size_set(w, h), evas_obj_position_set(x, y), @@ -275,7 +241,7 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch eo_unref(obj); // Create corner handles. - snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); + snprintf(buf, sizeof(buf), "%s/pt.png", prefix_data_get()); for (i = 0; i < 4; i++) { int cx = result->x, cy = result->y; diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h index f3f4170..7a84a7e 100644 --- a/src/libraries/winFang.h +++ b/src/libraries/winFang.h @@ -2,15 +2,6 @@ #define _WINFANG_H_ -#define EFL_API_OVERRIDE 1 -/* Enable access to unstable EFL API that are still in beta */ -#define EFL_BETA_API_SUPPORT 1 -/* Enable access to unstable EFL EO API. */ -#define EFL_EO_API_SUPPORT 1 - -#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*array)) - - #include #include #include @@ -89,8 +80,6 @@ typedef struct _Widget Evas_Smart_Cb on_del; } Widget; -void HamrTime(void *elm_main, char *domain); - winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); void winFangHide(winFang *win); void winFangShow(winFang *win); diff --git a/src/love/build.lua b/src/love/build.lua index f4ae37f..5ecca31 100755 --- a/src/love/build.lua +++ b/src/love/build.lua @@ -18,10 +18,4 @@ removeFiles(dir, {'../../love', '*.o', '../../media/love.edj'}) runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' love.edc ../../media/love.edj') --- While SledHamr.c does this, we can't use that here, coz love 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('../../love', dir, {'love'}, '') diff --git a/src/love/love.c b/src/love/love.c index 0e4ac40..1f885bc 100644 --- a/src/love/love.c +++ b/src/love/love.c @@ -55,7 +55,7 @@ typedef struct _script } script; -int logDom; // Our logging domain. +int logDom = -1; // Our logging domain. //static int CPUs = 4; static Eina_Strbuf *LuaSLStream; static Eina_Strbuf *clientStream; @@ -166,7 +166,7 @@ static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev) // Compile and run scripts. gettimeofday(&startTime, NULL); - snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/Test sim/objects", prefix_data_get()); eina_file_dir_list(buf, EINA_TRUE, dirList_compile, data); return ECORE_CALLBACK_RENEW; @@ -413,7 +413,7 @@ static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *e temp++; temp[0] = '\0'; lineNo = atoi(line); - snprintf(key, sizeof(key), "%s/Test sim/objects/onefang%%27s%%20test%%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/%s", PACKAGE_DATA_DIR, notecard); + snprintf(key, sizeof(key), "%s/Test sim/objects/onefang%%27s%%20test%%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/%s", prefix_data_get(), notecard); fd = open(key, O_RDONLY); if (-1 != fd) @@ -493,7 +493,7 @@ static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) char buf[PATH_MAX]; PW("Failed to connect to a script server, starting our own."); - sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); + sprintf(buf, "%s/LuaSL &", prefix_bin_get()); system(buf); count = 0; } @@ -618,7 +618,7 @@ int main(int argc, char **argv) if (eina_init()) { - logDom = loggingStartup("love", logDom); + logDom = HamrTime(argv[0], main, logDom); ourGlobals.scripts = eina_hash_string_superfast_new(NULL); if (ecore_con_init()) @@ -703,7 +703,7 @@ int main(int argc, char **argv) evas_object_focus_set(ourGlobals.bg, EINA_TRUE); ourGlobals.edje = edje_object_add(ourGlobals.canvas); - snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "love"); + snprintf(buf, sizeof(buf), "%s/%s.edj", prefix_data_get(), "love"); if (!edje_object_file_set(ourGlobals.edje, buf, group)) { int err = edje_object_load_error_get(ourGlobals.edje); @@ -720,7 +720,7 @@ int main(int argc, char **argv) evas_object_resize(ourGlobals.edje, WIDTH, HEIGHT); evas_object_show(ourGlobals.edje); - snprintf(buf, sizeof(buf), "%s/bubble_sh.png", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/bubble_sh.png", prefix_data_get()); for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) { sh = evas_object_image_filled_add(ourGlobals.canvas); @@ -730,7 +730,7 @@ int main(int argc, char **argv) evas_object_data_set(ourGlobals.bg, names[(i * 2) + 1], sh); } - snprintf(buf, sizeof(buf), "%s/bubble.png", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/bubble.png", prefix_data_get()); for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) { bub = evas_object_image_filled_add(ourGlobals.canvas); @@ -779,6 +779,7 @@ int main(int argc, char **argv) PC("Failed to init ecore_con!"); eina_hash_free(ourGlobals.scripts); + pantsOff(logDom); } else fprintf(stderr, "Failed to init eina!"); diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c index 444a77a..ec8997b 100644 --- a/src/purkle/purkle.c +++ b/src/purkle/purkle.c @@ -61,7 +61,7 @@ static int say(lua_State *L) if (server) sendForth(server, id, buf); else - printf("PURKLE NOT SAY, no where to send %s", buf); + PW("PURKLE NOT SAY, no where to send %s", buf); } return 0; } -- cgit v1.1