diff --git a/data/core/start.lua b/data/core/start.lua index 330c42f5..a255bb2b 100644 --- a/data/core/start.lua +++ b/data/core/start.lua @@ -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) - local path = package.searchpath(modname, package.cpath) - if not path then return nil end - return system.load_native_plugin, path -end } +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 diff --git a/meson.build b/meson.build index 3fbd9c74..1afedce7 100644 --- a/meson.build +++ b/meson.build @@ -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 #=============================================================================== diff --git a/meson_options.txt b/meson_options.txt index 1cf3e22f..14d4a5b8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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') + diff --git a/src/api/system.c b/src/api/system.c index bcd1b997..b23b219f 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -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 }, - { "load_native_plugin", f_load_native_plugin }, +#ifdef LITE_XL_USE_PLUGIN_API + { "load_native_plugin", f_load_native_plugin }, +#endif { NULL, NULL } };