Rerun build script only when necessary

This commit is contained in:
cyqsimon 2023-11-02 23:29:42 +08:00 committed by Martin Nordholts
parent 79a03b4299
commit 5498c24c33
2 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,14 @@ use crate::util::render_template;
/// Generate manpage and shell completions for the bat application. /// Generate manpage and shell completions for the bat application.
pub fn gen_man_and_comp() -> anyhow::Result<()> { 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. // Read environment variables.
let project_name = env::var("PROJECT_NAME").unwrap_or("bat".into()); let project_name = env::var("PROJECT_NAME").unwrap_or("bat".into());
let executable_name = env::var("PROJECT_EXECUTABLE").unwrap_or(project_name.clone()); let executable_name = env::var("PROJECT_EXECUTABLE").unwrap_or(project_name.clone());

View File

@ -3,6 +3,10 @@ mod application;
mod util; mod util;
fn main() -> anyhow::Result<()> { 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")] #[cfg(feature = "application")]
application::gen_man_and_comp()?; application::gen_man_and_comp()?;