use std::path::Path;
use anyhow::Result;
use crate::subprocess_utils::check_call_maybe_ve;
fn is_build_disabled(project: &Path) -> bool {
project.join(".disable").exists()
}
pub fn check_not_disabled(project: &Path) -> Result<bool> {
Ok(!is_build_disabled(project))
}
pub fn check_cargo(project: &Path) -> Result<bool> {
Ok(!is_build_disabled(project) && project.join("Cargo.toml").exists())
}
pub fn check_rsconstruct(project: &Path) -> Result<bool> {
Ok(!is_build_disabled(project) && project.join("rsconstruct.toml").exists())
}
pub fn build_bootstrap(project: &Path, venv: bool) -> Result<bool> {
check_call_maybe_ve(project, venv, "python", &["bootstrap.py"])?;
Ok(true)
}
pub fn build_make(project: &Path, venv: bool) -> Result<bool> {
check_call_maybe_ve(project, venv, "make", &[])?;
Ok(true)
}
pub fn build_cargo(project: &Path, venv: bool) -> Result<bool> {
check_call_maybe_ve(project, venv, "cargo", &["build"])?;
check_call_maybe_ve(project, venv, "cargo", &["build", "--release"])?;
Ok(true)
}
pub fn build_cargo_publish(project: &Path, venv: bool) -> Result<bool> {
check_call_maybe_ve(project, venv, "cargo", &["publish"])?;
Ok(true)
}
pub fn build_rsconstruct(project: &Path, venv: bool) -> Result<bool> {
check_call_maybe_ve(project, venv, "rsconstruct", &["--quiet", "build"])?;
Ok(true)
}