From efe8e65dd9c8f50e754e7cb17cd69d0092cc4d63 Mon Sep 17 00:00:00 2001 From: chrox Date: Thu, 19 Feb 2015 01:37:36 +0800 Subject: [PATCH] refactoring search path --- reader.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/reader.lua b/reader.lua index 0c703ed6e..7864b68fd 100755 --- a/reader.lua +++ b/reader.lua @@ -1,18 +1,28 @@ #!./luajit +-- load default settings require "defaults" pcall(dofile, "defaults.persistent.lua") -package.path = "?.lua;common/?.lua;frontend/?.lua" -package.cpath = "?.so;common/?.so;common/?.dll;/usr/lib/lua/?.so" +-- set search path for 'require()' +package.path = "common/?.lua;frontend/?.lua;" .. package.path +package.cpath = "common/?.so;common/?.dll;/usr/lib/lua/?.so;" .. package.cpath + +-- set search path for 'ffi.load()' local ffi = require("ffi") +local util = require("ffi/util") +ffi.cdef[[ + char *getenv(const char *name); + int putenv(const char *envvar); + int _putenv(const char *envvar); +]] if ffi.os == "Windows" then - ffi.cdef[[ - int _putenv(const char *envvar); - ]] ffi.C._putenv("PATH=libs;common;") - --ffi.C._putenv("EMULATE_READER_W=480") - --ffi.C._putenv("EMULATE_READER_H=600") +else + ffi.C.putenv("LD_LIBRARY_PATH=" + .. util.realpath("libs") .. ":" + .. util.realpath("common") ..":" + .. ffi.string(ffi.C.getenv("LD_LIBRARY_PATH"))) end local DocSettings = require("docsettings")