refactor: minor cleanup & formatting

This commit is contained in:
Erica Marigold 2024-03-04 13:56:22 +05:30
parent 3d305f7b1f
commit 7e40851a79
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1
2 changed files with 13 additions and 10 deletions

View file

@ -65,12 +65,19 @@ impl BuildCommand {
self.base self.base
} else if let Some(target_inner) = self.target { } else if let Some(target_inner) = self.target {
let target_exe_extension = get_target_exe_extension(target_inner.as_str()); let target_exe_extension = match target_inner.as_str() {
"windows-x86_64" => "exe",
_ => "bin",
};
let path = let path =
TARGET_BASE_DIR.join(format!("lune-{}.{}", target_inner, target_exe_extension)); TARGET_BASE_DIR.join(format!("lune-{}.{}", target_inner, target_exe_extension));
output_path.set_extension(target_exe_extension); output_path.set_extension(if target_exe_extension == "bin" {
""
} else {
target_exe_extension
});
if !TARGET_BASE_DIR.exists() { if !TARGET_BASE_DIR.exists() {
fs::create_dir_all(TARGET_BASE_DIR.to_path_buf()).await?; fs::create_dir_all(TARGET_BASE_DIR.to_path_buf()).await?;
@ -184,10 +191,3 @@ async fn write_executable_file_to(path: impl AsRef<Path>, bytes: impl AsRef<[u8]
Ok(()) Ok(())
} }
fn get_target_exe_extension(target: &str) -> &str {
match target {
"windows-x86_64" => "exe",
_ => "bin",
}
}

View file

@ -49,7 +49,10 @@ impl Metadata {
/** /**
Creates a patched standalone binary from the given script contents. Creates a patched standalone binary from the given script contents.
*/ */
pub async fn create_env_patched_bin(base_exe_path: Option<PathBuf>, script_contents: impl Into<Vec<u8>>) -> Result<Vec<u8>> { pub async fn create_env_patched_bin(
base_exe_path: Option<PathBuf>,
script_contents: impl Into<Vec<u8>>,
) -> Result<Vec<u8>> {
let mut patched_bin = fs::read(base_exe_path.unwrap_or(CURRENT_EXE.to_path_buf())).await?; let mut patched_bin = fs::read(base_exe_path.unwrap_or(CURRENT_EXE.to_path_buf())).await?;
// Compile luau input into bytecode // Compile luau input into bytecode