Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2024"
# If this breaks we'll pin to a commit and risk lagging behind Luau
# but mlua's main branch is relatively stable and hasn't broken for us before nor for other projects.
# we need to enable error-send so we can propogate errors across threads in std_thread.rs
mluau = { git = "https://github.com/mluau/mluau.git", features = ["luau", "serialize", "error-send"] }
mluau = { git = "https://github.com/mluau/mluau.git", features = ["luau", "luau-jit", "serialize", "error-send"] }
regex = "1.11.1"
# needed for seal setup (really useful!)
include_dir = { version = "0.7.4" }
Expand Down
21 changes: 21 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ fn main() -> LuaResult<()> {
}
}

fn set_jit(luau: &Lua) -> bool {
let should_jit = match std::env::var("SEAL_NO_JIT") {
Ok(var) if var.to_lowercase() == "true" => false,
Ok(var) if var.to_lowercase() == "false" => true,
Ok(_) => true,
Err(_) => true,
};

if should_jit {
luau.enable_jit(should_jit);
}

should_jit
}

fn resolve_file(requested_path: String, function_name: &'static str) -> LuauLoadResult {
if requested_path.ends_with(".lua") {
return wrap_err!("{}: wrong language! seal only runs .luau files", function_name);
Expand All @@ -174,6 +189,8 @@ fn resolve_file(requested_path: String, function_name: &'static str) -> LuauLoad
return wrap_err!("{}: unable to enable Luau safeenv (sandbox mode) on chunk '{}' due to err: {}", function_name, chunk_name, err);
};

set_jit(&luau);

globals::set_globals(&luau, chunk_name.clone())?;

let mut src = match fs::read_to_string(&chunk_name) {
Expand Down Expand Up @@ -366,7 +383,11 @@ fn seal_standalone(bytecode: Vec<u8>) -> LuauLoadResult {
let luau = Lua::new();
let entry_path = std::env::current_exe().unwrap_or_default();
let entry_path = entry_path.to_string_lossy().into_owned();

set_jit(&luau);

globals::set_globals(&luau, &entry_path)?;

Ok(Some(LuauLoadInfo {
luau,
code: Chunk::Bytecode(bytecode),
Expand Down