//! The build's identity, for `spectra --version`: `SPECTRA_BUILD` when a release or //! an install sets it (from `oxy describe` in this checkout), else the heads a Flow job is //! building, else "local build". fn main() { println!("cargo:rerun-if-env-changed=SPECTRA_BUILD"); // The heads name the build only when SPECTRA_BUILD does not: a CI job that // sets it stays fresh from one state to the next (oxygenflow#52). if !std::env::var("SPECTRA_BUILD").is_ok_and(|b| !b.trim().is_empty()) { println!("cargo:rerun-if-env-changed=FLOW_HEADS"); } let build = std::env::var("SPECTRA_BUILD") .ok() .map(|b| b.trim().to_string()) .filter(|b| !b.is_empty()) .or_else(|| { std::env::var("FLOW_HEADS") .ok() .and_then(|h| h.split('+').next().map(|x| format!("flow #{}", &x[..12.min(x.len())]))) .filter(|b| b.len() > "flow #".len()) }) .unwrap_or_else(|| "local build".into()); println!("cargo:rustc-env=SPECTRA_BUILD_ID={build}"); println!("cargo:rustc-env=SPECTRA_VERSION_LONG={} ({build})", std::env::var("CARGO_PKG_VERSION").unwrap()); }