Skip to content

Commit

Permalink
Rerun build script only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
cyqsimon authored and Enselic committed Nov 2, 2023
1 parent 282be3a commit d0b9fba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ use crate::util::render_template;

/// Generate manpage and shell completions for the bat application.
pub fn gen_man_and_comp() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=assets/manual/");
println!("cargo:rerun-if-changed=assets/completions/");

println!("cargo:rerun-if-env-changed=PROJECT_NAME");
println!("cargo:rerun-if-env-changed=PROJECT_EXECUTABLE");
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
println!("cargo:rerun-if-env-changed=BAT_ASSETS_GEN_DIR");

// Read environment variables.
let project_name = env::var("PROJECT_NAME").unwrap_or("bat".into());
let executable_name = env::var("PROJECT_EXECUTABLE").unwrap_or(project_name.clone());
Expand Down
4 changes: 4 additions & 0 deletions build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ mod application;
mod util;

fn main() -> anyhow::Result<()> {
// only watch manually-designated files
// see: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed
println!("cargo:rerun-if-changed=build/");

#[cfg(feature = "application")]
application::gen_man_and_comp()?;

Expand Down

0 comments on commit d0b9fba

Please sign in to comment.