build.rs 588 B

12345678910111213141516171819
  1. extern crate rand;
  2. extern crate vergen;
  3. use rand::distributions::Alphanumeric;
  4. use rand::Rng;
  5. use vergen::{generate_cargo_keys, ConstantsFlags};
  6. fn main() {
  7. let mut flags = ConstantsFlags::all();
  8. flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE);
  9. generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!");
  10. let mut rng = rand::thread_rng();
  11. let build_id: String = ::std::iter::repeat(())
  12. .map(|()| rng.sample(Alphanumeric))
  13. .take(8)
  14. .collect();
  15. println!("cargo:rustc-env=VERGEN_BUILD_ID={}", build_id);
  16. }