mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 19:59:36 +00:00
- Incremental builds (object caching by mtime) - `build.kind` with `staticlib` support - Custom output directory via `build.target`
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use crate::platform;
|
|
use crate::utils::fs::check_dir;
|
|
use crate::utils::log::warn;
|
|
use std::path::Path;
|
|
use std::process::Command;
|
|
|
|
pub fn run_binary(project_name: &str, profile: &str, target_dir: Option<&str>) -> i32 {
|
|
let bin_path = platform::bin_path(profile, project_name, target_dir);
|
|
if Path::new(&bin_path).exists() {
|
|
return Command::new(bin_path)
|
|
.status()
|
|
.map(|status| status.code().unwrap_or(1))
|
|
.unwrap_or(1);
|
|
}
|
|
|
|
if target_dir.is_none()
|
|
&& check_dir(Some(&format!("target/{profile}")))
|
|
.unwrap_or_default()
|
|
.contains(&profile.to_string())
|
|
{
|
|
warn("Launch of the latest release");
|
|
return Command::new(platform::bin_path(profile, project_name, target_dir))
|
|
.status()
|
|
.map(|status| status.code().unwrap_or(1))
|
|
.unwrap_or(1);
|
|
}
|
|
|
|
if target_dir.is_some() && Path::new(&bin_path).exists() {
|
|
warn("Launch of the latest release");
|
|
return Command::new(bin_path)
|
|
.status()
|
|
.map(|status| status.code().unwrap_or(1))
|
|
.unwrap_or(1);
|
|
}
|
|
|
|
1
|
|
}
|