2022-01-09 00:03:47 +00:00
|
|
|
use rand::{distributions::Alphanumeric, Rng};
|
2024-08-28 11:13:29 +00:00
|
|
|
use vergen_gitcl::{BuildBuilder, Emitter, GitclBuilder};
|
2017-08-03 18:58:44 +00:00
|
|
|
|
2024-08-28 11:13:29 +00:00
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
let gitcl = GitclBuilder::default()
|
|
|
|
.sha(true) // outputs 'VERGEN_GIT_SHA', and sets the 'short' flag true
|
|
|
|
.commit_date(true) // outputs 'VERGEN_GIT_COMMIT_DATE'
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
let build = BuildBuilder::default()
|
|
|
|
.build_date(true) // outputs 'VERGEN_BUILD_DATE'
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
Emitter::default()
|
|
|
|
.add_instructions(&build)?
|
|
|
|
.add_instructions(&gitcl)?
|
2023-04-12 20:29:25 +00:00
|
|
|
.emit()
|
|
|
|
.expect("Unable to generate the cargo keys!");
|
2022-07-27 21:31:11 +00:00
|
|
|
let build_id = match std::env::var("SOURCE_DATE_EPOCH") {
|
2022-05-21 19:36:56 +00:00
|
|
|
Ok(val) => val,
|
|
|
|
Err(_) => rand::thread_rng()
|
|
|
|
.sample_iter(Alphanumeric)
|
|
|
|
.take(8)
|
|
|
|
.map(char::from)
|
|
|
|
.collect(),
|
|
|
|
};
|
2021-02-13 17:43:24 +00:00
|
|
|
|
2023-01-27 22:15:51 +00:00
|
|
|
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={build_id}");
|
2024-08-28 11:13:29 +00:00
|
|
|
Ok(())
|
2017-08-03 18:58:44 +00:00
|
|
|
}
|