Add build option to disable plugin API

This is a temporary solution to easity recover compatibility with
LuaJIT. The native plugin API doesn't isn't currently compatible
with LuaJIT and the compatibility layer we are using.
This commit is contained in:
Francesco Abbate 2021-10-03 17:22:05 +02:00
parent 847856f92d
commit 24ea6b07ec
4 changed files with 22 additions and 9 deletions

View File

@ -20,11 +20,13 @@ package.path = DATADIR .. '/?/init.lua;' .. package.path
package.path = USERDIR .. '/?.lua;' .. package.path
package.path = USERDIR .. '/?/init.lua;' .. package.path
local dynamic_suffix = PLATFORM == "Mac OS X" and 'lib' or (PLATFORM == "Windows" and 'dll' or 'so')
package.cpath = DATADIR .. '/?.' .. dynamic_suffix .. ";" .. USERDIR .. '/?.' .. dynamic_suffix
package.native_plugins = {}
package.searchers = { package.searchers[1], package.searchers[2], function(modname)
if system.load_native_plugin then
local dynamic_suffix = PLATFORM == "Mac OS X" and 'lib' or (PLATFORM == "Windows" and 'dll' or 'so')
package.cpath = DATADIR .. '/?.' .. dynamic_suffix .. ";" .. USERDIR .. '/?.' .. dynamic_suffix
package.native_plugins = {}
package.searchers = { package.searchers[1], package.searchers[2], function(modname)
local path = package.searchpath(modname, package.cpath)
if not path then return nil end
return system.load_native_plugin, path
end }
end }
end

View File

@ -28,6 +28,11 @@ lite_cargs = []
if get_option('renderer') or host_machine.system() == 'darwin'
lite_cargs += '-DLITE_USE_SDL_RENDERER'
endif
if get_option('plugin-api')
lite_cargs += '-DLITE_XL_USE_PLUGIN_API'
endif
#===============================================================================
# Linker Settings
#===============================================================================

View File

@ -2,3 +2,5 @@ option('bundle', type : 'boolean', value : false, description: 'Build a macOS bu
option('source-only', type : 'boolean', value : false, description: 'Configure source files only, doesn\'t checks for dependencies')
option('portable', type : 'boolean', value : false, description: 'Portable install')
option('renderer', type : 'boolean', value : false, description: 'Use SDL renderer')
option('plugin-api', type : 'boolean', value : true, description: 'Enable native plugin API')

View File

@ -651,6 +651,7 @@ static int f_set_window_opacity(lua_State *L) {
return 1;
}
#ifdef LITE_XL_USE_PLUGIN_API
// Symbol table for native plugin loading. Allows for a statically
// bound lua library to be used by native plugins.
typedef struct {
@ -730,6 +731,7 @@ static int f_load_native_plugin(lua_State *L) {
return result;
}
#endif
static const luaL_Reg lib[] = {
@ -758,7 +760,9 @@ static const luaL_Reg lib[] = {
{ "exec", f_exec },
{ "fuzzy_match", f_fuzzy_match },
{ "set_window_opacity", f_set_window_opacity },
#ifdef LITE_XL_USE_PLUGIN_API
{ "load_native_plugin", f_load_native_plugin },
#endif
{ NULL, NULL }
};