refactor: move bootstrap code into setupkoenv.lua

add ffi.load patch
add kodev prompt command
This commit is contained in:
Qingping Hou
2016-11-12 23:44:06 -08:00
parent 2f5935411a
commit dae4a5a413
5 changed files with 44 additions and 26 deletions

View File

@@ -14,37 +14,19 @@ io.stdout:flush()
-- load default settings
require "defaults"
require("defaults")
local DataStorage = require("datastorage")
pcall(dofile, DataStorage:getDataDir() .. "/defaults.persistent.lua")
-- 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
require("setupkoenv")
-- 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.C._putenv("PATH=libs;common;")
end
local _ = require("gettext")
-- read settings and check for language override
-- has to be done before requiring other files because
-- they might call gettext on load
G_reader_settings = require("luasettings"):open(
DataStorage:getDataDir().."/settings.reader.lua")
local lang_locale = G_reader_settings:readSetting("language")
local _ = require("gettext")
if lang_locale then
_.changeLang(lang_locale)
end