Add feature for registering bundled Lua modules
Enabled by default.
This commit is contained in:
1 parent
9b98c65060
commit
f3c065debd
4 files changed
+28
-16
No files matched your search
+6
-2
@@ -14,7 +14,7 @@ anyhow = "1.0"
|
||||
arboard = { version = "3.6.1", default-features = false }
|
||||
bytemuck = "1.23.2"
|
||||
clap = { version = "4.5.46", features = ["derive"] }
|
||||
curl = "0.4.51"
|
||||
curl = { version = "0.4.51", optional = true }
|
||||
dds = "0.2.0"
|
||||
directories = "6.0.0"
|
||||
env_logger = "0.11"
|
||||
@@ -24,7 +24,7 @@ flate2 = "1.1.2"
|
||||
glob = "0.3.3"
|
||||
image = { version = "0.25.8", default-features = false, features = ["rayon", "jpeg", "png", "webp"] }
|
||||
log = "0.4"
|
||||
luautf8-rs = { git = "https://github.com/meehl/luautf8-rs.git", rev = "dc74b734e5285108068cf2ffb674c1dc840073c1", features = ["luajit"] }
|
||||
luautf8-rs = { git = "https://github.com/meehl/luautf8-rs.git", rev = "dc74b734e5285108068cf2ffb674c1dc840073c1", features = ["luajit"], optional = true }
|
||||
mlua = { version = "0.12.0", features = ["luajit", "anyhow"] }
|
||||
nohash-hasher = "0.2.0"
|
||||
num-traits = "0.2.19"
|
||||
@@ -47,4 +47,8 @@ zstd = "0.13.3"
|
||||
smithay-clipboard = "0.7.3"
|
||||
|
||||
[features]
|
||||
default = ["bundled-lua-modules"]
|
||||
# Register Rust implementations of the Lua modules required by PoB's Lua code.
|
||||
# Disable this to use the original C libraries.
|
||||
bundled-lua-modules = ["dep:curl", "dep:luautf8-rs"]
|
||||
profile-with-puffin = ["profiling/profile-with-puffin", "dep:puffin_http"]
|
||||
+2
-7
@@ -10,10 +10,7 @@ use crate::{
|
||||
draw_commands::DrawCommandRecorder,
|
||||
fonts::Fonts,
|
||||
input::InputState,
|
||||
pob::{
|
||||
modules::{luacurl, luasocket},
|
||||
subscript::{NativeMultiValue, SubscriptEvent, SubscriptManager},
|
||||
},
|
||||
pob::subscript::{NativeMultiValue, SubscriptEvent, SubscriptManager},
|
||||
renderer::textures::TextureManager,
|
||||
stage::{StageEvent, StageFrameOutput, StageTransition},
|
||||
util::{append_lua_package_dir, change_working_directory},
|
||||
@@ -128,9 +125,7 @@ impl PathOfBuilding {
|
||||
api::register_globals(&lua)?;
|
||||
|
||||
// register modules
|
||||
lua.register_module("lua-utf8", luautf8::create_module(&lua)?)?;
|
||||
lua.register_module("socket", luasocket::create_module(&lua)?)?;
|
||||
lua.register_module("lcurl.safe", luacurl::create_module(&lua)?)?;
|
||||
modules::register(&lua)?;
|
||||
|
||||
Ok(lua)
|
||||
}
|
||||
|
||||
@@ -1,2 +1,20 @@
|
||||
#[cfg(feature = "bundled-lua-modules")]
|
||||
pub mod luacurl;
|
||||
#[cfg(feature = "bundled-lua-modules")]
|
||||
pub mod luasocket;
|
||||
|
||||
use mlua::{Lua, Result as LuaResult};
|
||||
|
||||
/// Registers Rust implementations of the Lua modules required by PoB's Lua code.
|
||||
pub fn register(lua: &Lua) -> LuaResult<()> {
|
||||
lua.register_module("lua-utf8", luautf8::create_module(lua)?)?;
|
||||
lua.register_module("socket", luasocket::create_module(lua)?)?;
|
||||
lua.register_module("lcurl.safe", luacurl::create_module(lua)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Nothing is registered so Lua resolves the required modules through `package.cpath`.
|
||||
#[cfg(not(feature = "bundled-lua-modules"))]
|
||||
pub fn register(_lua: &Lua) -> LuaResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
pob::modules::{luacurl, luasocket},
|
||||
util::append_lua_package_dir,
|
||||
};
|
||||
use crate::{pob::modules, util::append_lua_package_dir};
|
||||
use anyhow::{Result, anyhow};
|
||||
use mlua::{Integer, IntoLuaMulti, Lua, MultiValue, Number, Value};
|
||||
use std::{
|
||||
@@ -145,9 +142,7 @@ impl Subscript {
|
||||
append_lua_package_dir(&lua, &script_dir.join("lua"))?;
|
||||
|
||||
// register modules
|
||||
lua.register_module("lua-utf8", luautf8::create_module(&lua)?)?;
|
||||
lua.register_module("socket", luasocket::create_module(&lua)?)?;
|
||||
lua.register_module("lcurl.safe", luacurl::create_module(&lua)?)?;
|
||||
modules::register(&lua)?;
|
||||
|
||||
// register a proxy for each allowed blocking call.
|
||||
// forwards the call to the main thread and blocks on `reply_rx` until the main thread
|
||||
|
||||
Reference in new issue
Block a user