mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
dc22910673
Signed-off-by: yubiuser <github@yubiuser.dev>
30 lines
961 B
Rust
30 lines
961 B
Rust
use rand::{distributions::Alphanumeric, Rng};
|
|
use vergen_gitcl::{BuildBuilder, Emitter, GitclBuilder};
|
|
|
|
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)?
|
|
.emit()
|
|
.expect("Unable to generate the cargo keys!");
|
|
let build_id = match std::env::var("SOURCE_DATE_EPOCH") {
|
|
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}");
|
|
Ok(())
|
|
}
|