add --force-recompile flag #4
23
src/app.rs
23
src/app.rs
@@ -29,6 +29,9 @@ enum Subcommand {
|
|||||||
Init,
|
Init,
|
||||||
/// Run the local project
|
/// Run the local project
|
||||||
Run {
|
Run {
|
||||||
|
/// Force recompilation of the project
|
||||||
|
#[arg(long, short)]
|
||||||
|
force_recompile: bool,
|
||||||
/// The build mode to use
|
/// The build mode to use
|
||||||
mode: Option<String>,
|
mode: Option<String>,
|
||||||
/// Arguments to pass to the project binary
|
/// Arguments to pass to the project binary
|
||||||
@@ -37,6 +40,9 @@ enum Subcommand {
|
|||||||
},
|
},
|
||||||
/// Build the local project
|
/// Build the local project
|
||||||
Build {
|
Build {
|
||||||
|
/// Force recompilation of the project
|
||||||
|
#[arg(long, short)]
|
||||||
|
force_recompile: bool,
|
||||||
/// The build mode to use
|
/// The build mode to use
|
||||||
mode: Option<String>,
|
mode: Option<String>,
|
||||||
},
|
},
|
||||||
@@ -86,8 +92,12 @@ impl App {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Subcommand::Run { mode, args } => {
|
Subcommand::Run {
|
||||||
match build(&mode) {
|
mode,
|
||||||
|
args,
|
||||||
|
force_recompile,
|
||||||
|
} => {
|
||||||
|
match build(&mode, force_recompile) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error building project: {e}");
|
eprintln!("Error building project: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
@@ -99,7 +109,10 @@ impl App {
|
|||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Subcommand::Build { mode } => match build(&mode) {
|
Subcommand::Build {
|
||||||
|
mode,
|
||||||
|
force_recompile,
|
||||||
|
} => match build(&mode, force_recompile) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error building project: {e}");
|
eprintln!("Error building project: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
@@ -220,7 +233,7 @@ fn get_config() -> Option<crate::config::Config> {
|
|||||||
toml::from_str(&raw).ok()
|
toml::from_str(&raw).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(mode: &Option<String>) -> std::io::Result<()> {
|
fn build(mode: &Option<String>, force_recompile: bool) -> std::io::Result<()> {
|
||||||
let conf = match get_config() {
|
let conf = match get_config() {
|
||||||
Some(conf) => conf,
|
Some(conf) => conf,
|
||||||
None => {
|
None => {
|
||||||
@@ -249,7 +262,7 @@ fn build(mode: &Option<String>) -> std::io::Result<()> {
|
|||||||
|
|
||||||
let old_compute_path = PathBuf::from(format!("target/{}/.build_hash", build_config.name));
|
let old_compute_path = PathBuf::from(format!("target/{}/.build_hash", build_config.name));
|
||||||
|
|
||||||
if old_compute_path.exists() {
|
if old_compute_path.exists() && !force_recompile {
|
||||||
let text = std::fs::read_to_string(old_compute_path)?;
|
let text = std::fs::read_to_string(old_compute_path)?;
|
||||||
|
|
||||||
if hash.trim() == text.trim() {
|
if hash.trim() == text.trim() {
|
||||||
|
|||||||
Reference in New Issue
Block a user