diff --git a/Cargo.toml b/Cargo.toml index e5e8a2f5..ed225bc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,8 @@ system-lua54=["rlua-lua54-sys", "rlua-lua54-sys/lua54-pkg-config"] system-lua53=["rlua-lua53-sys", "rlua-lua53-sys/lua53-pkg-config"] system-lua51=["rlua-lua51-sys", "rlua-lua51-sys/lua51-pkg-config"] +# Remove Lua's os lib +lua-no-oslib=["rlua-lua54-sys/lua-no-oslib"] # Enabled functions from the math module that have been deprecated lua-compat-mathlib = [] @@ -32,7 +34,7 @@ libc = { version = "0.2" } num-traits = { version = "0.2.14" } bitflags = { version = "1.0.4" } bstr = {version = "0.2", features = ["std"], default_features = false } -rlua-lua54-sys = { version = "0.1.2", optional = true } +rlua-lua54-sys = { optional = true, path = "crates/rlua-lua54-sys" } rlua-lua53-sys = { version = "0.1.2", optional = true } rlua-lua51-sys = { version = "0.1.2", optional = true } diff --git a/crates/rlua-lua54-sys/Cargo.toml b/crates/rlua-lua54-sys/Cargo.toml index f9cba30e..a8228b6d 100644 --- a/crates/rlua-lua54-sys/Cargo.toml +++ b/crates/rlua-lua54-sys/Cargo.toml @@ -22,3 +22,4 @@ pkg-config = "0.3.24" default = [] lua54-pkg-config = [] static = [] +lua-no-oslib = [] diff --git a/crates/rlua-lua54-sys/build.rs b/crates/rlua-lua54-sys/build.rs index 658ef518..47c7621d 100644 --- a/crates/rlua-lua54-sys/build.rs +++ b/crates/rlua-lua54-sys/build.rs @@ -42,7 +42,6 @@ fn main() { .file(lua_dir.join("ldump.c")) .file(lua_dir.join("lfunc.c")) .file(lua_dir.join("lgc.c")) - .file(lua_dir.join("linit.c")) .file(lua_dir.join("liolib.c")) .file(lua_dir.join("llex.c")) .file(lua_dir.join("lmathlib.c")) @@ -51,7 +50,6 @@ fn main() { .file(lua_dir.join("loadlib.c")) .file(lua_dir.join("lobject.c")) .file(lua_dir.join("lopcodes.c")) - .file(lua_dir.join("loslib.c")) .file(lua_dir.join("lparser.c")) .file(lua_dir.join("lstate.c")) .file(lua_dir.join("lstring.c")) @@ -64,6 +62,12 @@ fn main() { .file(lua_dir.join("lvm.c")) .file(lua_dir.join("lzio.c")); + if !cfg!(feature = "lua-no-oslib") { + cc_config_build = cc_config_build + .file(lua_dir.join("loslib.c")) + .file(lua_dir.join("linit.c")); + } + cc_config_build .out_dir(dst.join("lib")) .compile("liblua5.4.a"); diff --git a/src/lua.rs b/src/lua.rs index 0077bc3d..9702d020 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -782,6 +782,7 @@ unsafe fn load_from_std_lib(state: *mut ffi::lua_State, lua_mod: StdLib) { if lua_mod.contains(StdLib::IO) { requiref(state, cstr!("io"), Some(ffi::luaopen_io), 1); } + #[cfg(feature = "lua-no-oslib")] if lua_mod.contains(StdLib::OS) { requiref(state, cstr!("os"), Some(ffi::luaopen_os), 1); }