mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 16:19:37 +00:00
Added:
- Incremental builds (object caching by mtime) - `build.kind` with `staticlib` support - Custom output directory via `build.target`
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
use crate::cli::build::build;
|
||||
use crate::config::{PROFILE, flags};
|
||||
use crate::core::config::Config;
|
||||
use crate::platform;
|
||||
use crate::core::runner::run_binary;
|
||||
use crate::utils::fs::check_dir;
|
||||
use crate::utils::log::{error, warn};
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn run(args: &[String]) -> i32 {
|
||||
let mut active_profile = PROFILE.to_string();
|
||||
@@ -28,6 +26,10 @@ pub fn run(args: &[String]) -> i32 {
|
||||
.get("package.name")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
let build_kind = config
|
||||
.get("build.kind")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
let target_dir = config
|
||||
.get("build.target")
|
||||
.and_then(|v| v.as_str())
|
||||
@@ -49,40 +51,23 @@ pub fn run(args: &[String]) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
if build_kind.trim() == "staticlib" {
|
||||
error("Cannot run static library");
|
||||
return 1;
|
||||
}
|
||||
let build_status = build(args);
|
||||
let bin_path = platform::bin_path(&active_profile, project_name, target_dir);
|
||||
let bin_path = crate::platform::bin_path(&active_profile, project_name, target_dir);
|
||||
if build_status == 0 {
|
||||
println!("\n {} {}", colored("Running", BOLD_GREEN), bin_path);
|
||||
println!("--------------------------------");
|
||||
return Command::new(bin_path)
|
||||
.status()
|
||||
.map(|status| status.code().unwrap_or(1))
|
||||
.unwrap_or(1);
|
||||
return run_binary(project_name, &active_profile, target_dir);
|
||||
}
|
||||
|
||||
if target_dir.is_none()
|
||||
&& check_dir(Some(&format!("target/{active_profile}")))
|
||||
.unwrap_or_default()
|
||||
.contains(&active_profile)
|
||||
{
|
||||
warn("Launch of the latest release");
|
||||
return Command::new(platform::bin_path(
|
||||
&active_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);
|
||||
let fallback_code = run_binary(project_name, &active_profile, target_dir);
|
||||
if fallback_code != 1 {
|
||||
return fallback_code;
|
||||
}
|
||||
|
||||
error("Fix errors in the code to run the project");
|
||||
0
|
||||
1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user