From 4dfec82877664786e487c8cee0ca982290968a90 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Tue, 6 May 2014 11:15:50 +0100 Subject: [PATCH] elua: support the EFL_RUN_IN_TREE environment variable --- src/Makefile_Elua.am | 3 ++- src/bin/elua/main.c | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Makefile_Elua.am b/src/Makefile_Elua.am index f818793ce3..7f1e7fa926 100644 --- a/src/Makefile_Elua.am +++ b/src/Makefile_Elua.am @@ -9,7 +9,8 @@ bin_elua_elua_SOURCES = \ bin_elua_elua_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -DELUA_CORE_DIR="\"$(datadir)/elua/core\"" \ -DELUA_MODULES_DIR="\"$(datadir)/elua/modules\"" @ELUA_CFLAGS@ \ - -DLOCALE_DIR=\"@LOCALE_DIR@\" + -DLOCALE_DIR=\"@LOCALE_DIR@\" \ + -DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)\" bin_elua_elua_LDADD = @ELUA_LIBS@ bin_elua_elua_DEPENDENCIES = @ELUA_INTERNAL_LIBS@ diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c index 4b5c1539a1..e2285f8dec 100644 --- a/src/bin/elua/main.c +++ b/src/bin/elua/main.c @@ -95,13 +95,18 @@ static int register_require(lua_State *L) { int n = 2; lua_pushvalue(L, 1); require_ref = luaL_ref(L, LUA_REGISTRYINDEX); - if (!corepath) { - if (noenv || !(corepath = getenv("ELUA_CORE_DIR")) || !corepath[0]) - corepath = ELUA_CORE_DIR; - } - if (!modpath) { - if (noenv || !(modpath = getenv("ELUA_MODULES_DIR")) || !modpath[0]) - modpath = ELUA_MODULES_DIR; + if (getenv("EFL_RUN_IN_TREE")) { + corepath = PACKAGE_BUILD_DIR "/src/bin/elua/core"; + modpath = PACKAGE_BUILD_DIR "/src/bin/elua/modules"; + } else { + if (!corepath) { + if (noenv || !(corepath = getenv("ELUA_CORE_DIR")) || !corepath[0]) + corepath = ELUA_CORE_DIR; + } + if (!modpath) { + if (noenv || !(modpath = getenv("ELUA_MODULES_DIR")) || !modpath[0]) + modpath = ELUA_MODULES_DIR; + } } lua_pushfstring(L, "%s/?.lua;", corepath); EINA_LIST_FOREACH(largs, l, data) { @@ -309,7 +314,13 @@ static int lua_main(lua_State *L) { luaL_openlibs(L); - if (!(coref = coredir)) { + if (getenv("EFL_RUN_IN_TREE")) { + Arg_Data *v = malloc(sizeof(Arg_Data)); + v->type = ARG_LIBDIR; + v->value = PACKAGE_BUILD_DIR "/src/bindings/luajit"; + largs = eina_list_append(largs, v); + coref = PACKAGE_BUILD_DIR "/src/bin/elua/core"; + } else if (!(coref = coredir)) { if (noenv || !(coref = getenv("ELUA_CORE_DIR")) || !coref[0]) { coref = ELUA_CORE_DIR; }