q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8077e14fd6362dfb3ab29f54b77019f89c1d8687

commit 8077e14fd6362dfb3ab29f54b77019f89c1d8687
Author: Daniel Kolesa <d.kol...@samsung.com>
Date:   Mon Nov 3 13:20:27 2014 +0000

    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)
---
 src/Makefile_Elua_Helper.am |  2 +-
 src/bin/elua/core/util.lua  | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/Makefile_Elua_Helper.am b/src/Makefile_Elua_Helper.am
index aa14f92..d6f383c 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 02b89a3..78db3ab 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

-- 


Reply via email to