librespot/core/build.rs

27 lines
917 B
Rust
Raw Normal View History

2022-01-09 00:03:47 +00:00
use rand::{distributions::Alphanumeric, Rng};
use vergen::{vergen, Config, ShaKind, TimestampKind};
2017-08-03 18:58:44 +00:00
fn main() {
2022-01-09 00:03:47 +00:00
let mut config = Config::default();
*config.build_mut().kind_mut() = TimestampKind::DateOnly;
*config.git_mut().enabled_mut() = true;
*config.git_mut().commit_timestamp_mut() = true;
*config.git_mut().commit_timestamp_kind_mut() = TimestampKind::DateOnly;
*config.git_mut().sha_mut() = true;
*config.git_mut().sha_kind_mut() = ShaKind::Short;
*config.git_mut().rerun_on_head_change_mut() = true;
vergen(config).expect("Unable to generate the cargo keys!");
2017-08-03 18:58:44 +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(),
};
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={build_id}");
2017-08-03 18:58:44 +00:00
}