| 123456789101112131415161718 |
- //! Build identity for the dashboard badge.
- //!
- //! `SM121_VERSION` is passed by the add-on image build (`--build-arg` →
- //! `ENV` in the builder stage). Two things are needed for it to survive a
- //! warm cargo cache: this script must declare the env var as an input, and the
- //! value must reach the compiler as a *generated source*, not through
- //! `option_env!` alone (a cached fingerprint can otherwise keep the old
- //! literal). The value is echoed as a cargo warning so the CI log shows what
- //! the image actually got.
- fn main() {
- println!("cargo:rerun-if-env-changed=SM121_VERSION");
- let version = std::env::var("SM121_VERSION").unwrap_or_else(|_| "dev".into());
- println!("cargo:warning=SM121_VERSION={version}");
- let out = std::path::PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR"))
- .join("build_version.rs");
- std::fs::write(out, format!("pub const VERSION: &str = {version:?};\n"))
- .expect("write build_version.rs");
- }
|