Skip to content

Commit

Permalink
Experimental option to remove oslib at build time.
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglerchris committed Jul 17, 2022
1 parent 10c95b7 commit 9c04d12
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand All @@ -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 }

Expand Down
1 change: 1 addition & 0 deletions crates/rlua-lua54-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ pkg-config = "0.3.24"
default = []
lua54-pkg-config = []
static = []
lua-no-oslib = []
8 changes: 6 additions & 2 deletions crates/rlua-lua54-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))
Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9c04d12

Please sign in to comment.