Files
coursebank/build.rs
T

23 lines
907 B
Rust

// SPDX-License-Identifier: Prosperity-3.0.0
// Copyright Scientific Computing Studio
// Source: https://git.scient.ing/education/coursebank
//! Chooses the version string compiled into the binary.
//!
//! Normal and release builds use the version from `Cargo.toml`. Nightly builds
//! set `COURSEBANK_VERSION` (to a git-derived string; see
//! `scripts/nightly-version.sh`) so `coursebank --version` reflects how far the
//! build is past the last release rather than an unreleased number.
use std::env;
fn main() {
let version = match env::var("COURSEBANK_VERSION") {
Ok(v) if !v.trim().is_empty() => v,
_ => env::var("CARGO_PKG_VERSION").expect("cargo always sets CARGO_PKG_VERSION"),
};
println!("cargo:rustc-env=COURSEBANK_VERSION={version}");
println!("cargo:rerun-if-env-changed=COURSEBANK_VERSION");
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
}