mirror of
https://github.com/lune-org/lune.git
synced 2025-04-10 21:40:54 +01:00
refactor: let Metadata::create_env_patched_bin
handle compiler
defaults In the previous commit, I had moved `LuaCompiler` construction into the CLI command, which was not necessary. This reverts that.
This commit is contained in:
parent
0070f132b0
commit
d889031cc1
2 changed files with 8 additions and 12 deletions
|
@ -10,7 +10,6 @@ use async_zip::base::read::seek::ZipFileReader;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use console::style;
|
use console::style;
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use mlua::Compiler;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
|
@ -69,16 +68,9 @@ impl BuildCommand {
|
||||||
style("Compile").green().bold(),
|
style("Compile").green().bold(),
|
||||||
style(input_path_displayed).underlined()
|
style(input_path_displayed).underlined()
|
||||||
);
|
);
|
||||||
let patched_bin = Metadata::create_env_patched_bin(
|
let patched_bin = Metadata::create_env_patched_bin(base_exe_path, source_code.clone())
|
||||||
base_exe_path,
|
.await
|
||||||
source_code.clone(),
|
.context("failed to create patched binary")?;
|
||||||
Compiler::new()
|
|
||||||
.set_optimization_level(2)
|
|
||||||
.set_coverage_level(0)
|
|
||||||
.set_debug_level(1),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.context("failed to create patched binary")?;
|
|
||||||
|
|
||||||
// And finally write the patched binary to the output file
|
// And finally write the patched binary to the output file
|
||||||
println!(
|
println!(
|
||||||
|
|
|
@ -51,8 +51,12 @@ impl Metadata {
|
||||||
pub async fn create_env_patched_bin(
|
pub async fn create_env_patched_bin(
|
||||||
base_exe_path: PathBuf,
|
base_exe_path: PathBuf,
|
||||||
script_contents: impl Into<Vec<u8>>,
|
script_contents: impl Into<Vec<u8>>,
|
||||||
compiler: LuaCompiler,
|
|
||||||
) -> Result<Vec<u8>> {
|
) -> Result<Vec<u8>> {
|
||||||
|
let compiler = LuaCompiler::new()
|
||||||
|
.set_optimization_level(2)
|
||||||
|
.set_coverage_level(0)
|
||||||
|
.set_debug_level(1);
|
||||||
|
|
||||||
let mut patched_bin = fs::read(base_exe_path).await?;
|
let mut patched_bin = fs::read(base_exe_path).await?;
|
||||||
|
|
||||||
// Compile luau input into bytecode
|
// Compile luau input into bytecode
|
||||||
|
|
Loading…
Add table
Reference in a new issue