mirror of
https://github.com/lune-org/lune.git
synced 2025-04-10 21:40:54 +01:00
feat(cli): allow toggling JIT compilation
* Lune now accepts the `LUNE_LUAU_JIT` to toggle JIT compilation of Luau code. * The `Runtime` struct exposes the `with_jit_enabled` method to library consumers.
This commit is contained in:
parent
010cd36375
commit
c70769cc2b
2 changed files with 17 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::process::ExitCode;
|
use std::{env, process::ExitCode};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
@ -43,6 +43,13 @@ impl RunCommand {
|
||||||
// Create a new lune object with all globals & run the script
|
// Create a new lune object with all globals & run the script
|
||||||
let result = Runtime::new()
|
let result = Runtime::new()
|
||||||
.with_args(self.script_args)
|
.with_args(self.script_args)
|
||||||
|
// Enable JIT compilation unless it was requested to be disabled
|
||||||
|
.with_jit(
|
||||||
|
!matches!(
|
||||||
|
env::var("LUNE_LUAU_JIT").ok(),
|
||||||
|
Some(jit_enabled) if jit_enabled == "0" || jit_enabled == "false" || jit_enabled == "off"
|
||||||
|
)
|
||||||
|
)
|
||||||
.run(&script_display_name, strip_shebang(script_contents))
|
.run(&script_display_name, strip_shebang(script_contents))
|
||||||
.await;
|
.await;
|
||||||
Ok(match result {
|
Ok(match result {
|
||||||
|
|
|
@ -131,6 +131,15 @@ impl Runtime {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enables or disables JIT compilation.
|
||||||
|
*/
|
||||||
|
#[must_use]
|
||||||
|
pub fn with_jit(self, enabled: bool) -> Self {
|
||||||
|
self.inner.lua().enable_jit(enabled);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Runs a Lune script inside of the current runtime.
|
Runs a Lune script inside of the current runtime.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue