Quellcode durchsuchen

build: rebuild when SM121_VERSION changes (option_env! alone does not invalidate cargo's cache)

The add-on's builder stage keeps target/ on a cache mount, so a warm build
reused the cached crate and both 1.3.6 and 1.3.7 images baked the old 'dev'
string even though the build arg was passed. cargo:rerun-if-env-changed makes
the crate recompile when the version changes.
Alexander Korolev vor 6 Stunden
Ursprung
Commit
89553b26ac
1 geänderte Dateien mit 10 neuen und 0 gelöschten Zeilen
  1. 10 0
      build.rs

+ 10 - 0
build.rs

@@ -0,0 +1,10 @@
+//! Rebuild the crate when the build identity changes.
+//!
+//! `option_env!("SM121_VERSION")` is baked at compile time, but cargo does not
+//! treat an env var as an input on its own — without this line a cached build
+//! keeps the old value (the add-on's 1.3.6/1.3.7 images both shipped "dev"
+//! from a warm `target/` cache mount). `cargo:rerun-if-env-changed` makes the
+//! crate recompile whenever the version passed by the CI changes.
+fn main() {
+    println!("cargo:rerun-if-env-changed=SM121_VERSION");
+}