use std::path::Path;
use anyhow::Result;
use crate::subprocess_utils::{check_call, check_call_ve};
fn is_build_disabled() -> bool {
Path::new(".disable").exists()
}
pub fn build_bootstrap(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
check_call("python", &["bootstrap.py"])?;
Ok(true)
}
pub fn build_pydmt(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
check_call("pydmt", &["build"])?;
Ok(true)
}
pub fn build_make(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
check_call("make", &[])?;
Ok(true)
}
pub fn build_venv_make(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
check_call_ve(&["make"])?;
Ok(true)
}
pub fn build_venv_pydmt(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
check_call_ve(&["pydmt", "build"])?;
Ok(true)
}
pub fn build_pydmt_build_venv(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
check_call("pydmt", &["build_venv"])?;
Ok(true)
}
pub fn build_cargo(project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
if !project.join("Cargo.toml").exists() {
return Ok(false);
}
check_call("cargo", &["build"])?;
check_call("cargo", &["build", "--release"])?;
Ok(true)
}
pub fn build_cargo_publish(project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
if !project.join("Cargo.toml").exists() {
return Ok(false);
}
check_call("cargo", &["publish"])?;
Ok(true)
}
pub fn build_rsbuild(_project: &Path) -> Result<bool> {
if is_build_disabled() {
return Ok(false);
}
if !Path::new("rsbuild.toml").exists() {
return Ok(false);
}
check_call("rsbuild", &["--quiet", "build"])?;
Ok(true)
}