mirror of https://github.com/koreader/koreader
refactor: move bootstrap code into setupkoenv.lua
add ffi.load patch add kodev prompt commandpull/2338/head
parent
2f5935411a
commit
dae4a5a413
@ -0,0 +1,31 @@
|
||||
-- set search path for 'require()'
|
||||
package.path =
|
||||
"common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" ..
|
||||
package.path
|
||||
package.cpath =
|
||||
"common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" ..
|
||||
package.cpath
|
||||
|
||||
-- set search path for 'ffi.load()'
|
||||
local ffi = require("ffi")
|
||||
ffi.cdef[[
|
||||
char *getenv(const char *name);
|
||||
int putenv(const char *envvar);
|
||||
int _putenv(const char *envvar);
|
||||
]]
|
||||
if ffi.os == "Windows" then
|
||||
ffi.C._putenv("PATH=libs;common;")
|
||||
end
|
||||
local ffi_load = ffi.load
|
||||
-- patch ffi.load for thirdparty luajit libraries
|
||||
ffi.load = function(lib)
|
||||
local loaded, re = pcall(ffi_load, lib)
|
||||
if loaded then return re end
|
||||
|
||||
local lib_path = package.searchpath(lib, "./lib?.so;./libs/lib?.so")
|
||||
if not lib_path then
|
||||
error('Not able to load dynamic library: ' .. lib)
|
||||
else
|
||||
return ffi_load(lib_path)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue