summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-11-03 13:20:27 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-11-03 13:20:54 +0000
commit8077e14fd6362dfb3ab29f54b77019f89c1d8687 (patch)
tree81ac90f3c6bf0846cba55851f657acd2e554c183
parent652e2f688bb7c7057e69a4740181c12f17aa4e1d (diff)
downloadefl-8077e14fd6362dfb3ab29f54b77019f89c1d8687.tar.gz
elua: support for environment variable library path lookups in util.lib_load
This allows us to get rid of the LD_LIBRARY_PATH hack and thus make it more cross-plaform as well as fix some bad behavior (with the hack it still looked up the systemwide library if present instead of preferring in-tree)
-rw-r--r--src/Makefile_Elua_Helper.am2
-rw-r--r--src/bin/elua/core/util.lua12
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Makefile_Elua_Helper.am b/src/Makefile_Elua_Helper.am
index aa14f92883..d6f383c927 100644
--- a/src/Makefile_Elua_Helper.am
+++ b/src/Makefile_Elua_Helper.am
@@ -2,7 +2,7 @@ if HAVE_ELUA_BIN
ELUA_GEN = @elua_bin@ :lualian
_ELUA_GEN_DEP = @elua_bin@
else
-ELUA_GEN = LD_LIBRARY_PATH=$(top_builddir)/src/lib/eolian/.libs \
+ELUA_GEN = ELUA_EOLIAN_LIBRARY_PATH=$(top_builddir)/src/lib/eolian/.libs \
EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/elua/elua${EXEEXT} :lualian
_ELUA_GEN_DEP = bin/elua/elua${EXEEXT}
endif
diff --git a/src/bin/elua/core/util.lua b/src/bin/elua/core/util.lua
index 02b89a33f5..78db3abaf1 100644
--- a/src/bin/elua/core/util.lua
+++ b/src/bin/elua/core/util.lua
@@ -71,7 +71,17 @@ local loaded_libc = {}
M.lib_load = function(libname)
local lib = loaded_libs[libname]
if not lib then
- lib = ffi.load(libname)
+ local ev = os.getenv("ELUA_" .. libname:upper() .. "_LIBRARY_PATH")
+ if not ev or ev == "" then
+ lib = ffi.load(libname)
+ else
+ if ffi.os == "Windows" then
+ lib = ffi.load(ev .. "\\" .. libname .. ".dll")
+ else
+ lib = ffi.load(ev .. "/lib" .. libname .. ".so")
+ end
+ -- XXX: perhaps check here if it's loaded and fallback to default?
+ end
loaded_libs[libname] = lib
loaded_libc[libname] = 0
end