From 8519480fe45be6861a52e87d1708c79437aa517a Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Mon, 20 Nov 2017 10:26:35 +0100 Subject: [PATCH] Use build.rs to properly trigger rebuilds when env vars change, for #44 --- build.rs | 9 +++++++++ src/build_config.rs | 3 +++ 2 files changed, 12 insertions(+) diff --git a/build.rs b/build.rs index 2e1ad6c..9e1a2b7 100644 --- a/build.rs +++ b/build.rs @@ -45,4 +45,13 @@ fn main() { for entry in WalkDir::new("migrations").into_iter().filter_map(|e| e.ok()) { println!("cargo:rerun-if-changed={}", entry.path().display()); } + + // For build_config.rs + for env_var in &[ + "CONTINUOUS_INTEGRATION", + "TRAVIS_BRANCH", + "TRAVIS_COMMIT", + ] { + println!("cargo:rerun-if-env-changed={}", env_var); + } } diff --git a/src/build_config.rs b/src/build_config.rs index dd0f9ac..afdf9dc 100644 --- a/src/build_config.rs +++ b/src/build_config.rs @@ -1,5 +1,8 @@ #![allow(dead_code)] +// The non-CARGO env variables used here must be listed +// in build.rs to properly trigger rebuild on change + pub const PROJECT_NAME: &str = env!("CARGO_PKG_NAME"); lazy_static! {