mirror of
https://github.com/lune-org/lune.git
synced 2025-04-19 11:23:57 +01:00
feat: implement base binary system for custom targets
This commit is contained in:
parent
119eecad0d
commit
3d305f7b1f
1 changed files with 15 additions and 2 deletions
|
@ -36,6 +36,9 @@ pub struct BuildCommand {
|
||||||
|
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
pub target: Option<String>,
|
pub target: Option<String>,
|
||||||
|
|
||||||
|
#[clap(short, long)]
|
||||||
|
pub base: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildCommand {
|
impl BuildCommand {
|
||||||
|
@ -51,13 +54,23 @@ impl BuildCommand {
|
||||||
.await
|
.await
|
||||||
.context("failed to read input file")?;
|
.context("failed to read input file")?;
|
||||||
|
|
||||||
let base_exe_path = if let Some(target_inner) = self.target {
|
let base_exe_path = if self.base.is_some() {
|
||||||
|
output_path.set_extension(
|
||||||
|
self.base
|
||||||
|
.clone()
|
||||||
|
.unwrap()
|
||||||
|
.extension()
|
||||||
|
.expect("failed to get extension of base binary"),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.base
|
||||||
|
} else if let Some(target_inner) = self.target {
|
||||||
let target_exe_extension = get_target_exe_extension(target_inner.as_str());
|
let target_exe_extension = get_target_exe_extension(target_inner.as_str());
|
||||||
|
|
||||||
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 = output_path.with_extension(target_exe_extension);
|
output_path.set_extension(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?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue