Custom output directory via build.target

This commit is contained in:
2026-02-23 13:51:53 +08:00
parent e0fd729635
commit cb8a3b2001
15 changed files with 91 additions and 31 deletions

View File

@@ -1,3 +1,6 @@
pub fn bin_path(profile: &str, name: &str) -> String {
format!("./target/{profile}/{name}")
pub fn bin_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
match target_dir {
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
None => format!("./target/{profile}/{name}"),
}
}

View File

@@ -1,3 +1,6 @@
pub fn bin_path(profile: &str, name: &str) -> String {
format!("./target/{profile}/{name}")
pub fn bin_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
match target_dir {
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
None => format!("./target/{profile}/{name}"),
}
}

View File

@@ -5,21 +5,24 @@ pub mod macos;
#[cfg(target_os = "windows")]
pub mod windows;
pub fn bin_path(profile: &str, name: &str) -> String {
pub fn bin_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
#[cfg(target_os = "linux")]
{
linux::bin_path(profile, name)
linux::bin_path(profile, name, target_dir)
}
#[cfg(target_os = "macos")]
{
return macos::bin_path(profile, name);
return macos::bin_path(profile, name, target_dir);
}
#[cfg(target_os = "windows")]
{
return windows::bin_path(profile, name);
return windows::bin_path(profile, name, target_dir);
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
{
format!("./target/{profile}/{name}")
match target_dir {
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
None => format!("./target/{profile}/{name}"),
}
}
}

View File

@@ -1,3 +1,6 @@
pub fn bin_path(profile: &str, name: &str) -> String {
format!("./target/{profile}/{name}.exe")
pub fn bin_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
match target_dir {
Some(dir) => format!("{}/{}.exe", dir.trim_end_matches('/'), name),
None => format!("./target/{profile}/{name}.exe"),
}
}