Use the vergen crate to generate version information

* Add depend on the `vergen` crate (only use the `build`, `git` and
  `gitcl` features)
* Add the build script `build.rs` to setup the environment variables
  from the build system
This commit is contained in:
Paul van Tilburg 2023-05-29 15:28:11 +02:00 committed by Paul van Tilburg
parent 9742331f6d
commit ab6001f072
3 changed files with 30 additions and 0 deletions

18
Cargo.lock generated
View File

@ -17,6 +17,12 @@ dependencies = [
"libc",
]
[[package]]
name = "anyhow"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "approx"
version = "0.5.1"
@ -1847,6 +1853,7 @@ dependencies = [
"reqwest",
"rocket",
"thiserror",
"vergen",
]
[[package]]
@ -2274,6 +2281,17 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vergen"
version = "8.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b3c89c2c7e50f33e4d35527e5bf9c11d6d132226dbbd1753f0fbe9f19ef88c6"
dependencies = [
"anyhow",
"rustversion",
"time 0.3.20",
]
[[package]]
name = "version_check"
version = "0.9.4"

View File

@ -22,6 +22,9 @@ reqwest = { version = "0.11.9", features = ["json"] }
rocket = { version = "0.5.0-rc.3", features = ["json"] }
thiserror = "1.0.31"
[build-dependencies]
vergen = { version = "8.2.1", default-features = false, features = ["build", "git", "gitcl"] }
[dev-dependencies]
assert_float_eq = "1.1.3"
assert_matches = "1.5.0"

9
build.rs Normal file
View File

@ -0,0 +1,9 @@
use std::error::Error;
use vergen::EmitBuilder;
fn main() -> Result<(), Box<dyn Error>> {
// Generate the `cargo:` instructions to fill the appropriate environment variables.
EmitBuilder::builder().all_build().all_git().emit()?;
Ok(())
}