2015-05-09 10:07:24 +00:00
|
|
|
extern crate vergen;
|
2017-02-09 01:27:52 +00:00
|
|
|
extern crate protobuf_macros;
|
2017-07-17 12:31:06 +00:00
|
|
|
extern crate rand;
|
2016-03-07 18:16:43 +00:00
|
|
|
|
2017-07-17 12:31:06 +00:00
|
|
|
use rand::Rng;
|
2017-02-09 01:27:52 +00:00
|
|
|
use std::env;
|
|
|
|
use std::path::PathBuf;
|
2017-07-17 12:31:06 +00:00
|
|
|
use std::fs::OpenOptions;
|
|
|
|
use std::io::Write;
|
2015-04-25 20:32:07 +00:00
|
|
|
|
|
|
|
fn main() {
|
2017-02-09 01:27:52 +00:00
|
|
|
|
|
|
|
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
2017-07-17 12:31:06 +00:00
|
|
|
|
|
|
|
vergen::vergen(vergen::OutputFns::all()).unwrap();
|
|
|
|
|
|
|
|
let build_id: String = rand::thread_rng()
|
|
|
|
.gen_ascii_chars()
|
|
|
|
.take(8)
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
let mut version_file =
|
|
|
|
OpenOptions::new()
|
|
|
|
.write(true)
|
|
|
|
.append(true)
|
|
|
|
.open(&out.join("version.rs"))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let build_id_fn = format!("
|
|
|
|
/// Generate a random build id.
|
|
|
|
pub fn build_id() -> &'static str {{
|
|
|
|
\"{}\"
|
|
|
|
}}
|
|
|
|
", build_id);
|
|
|
|
|
|
|
|
if let Err(e) = version_file.write_all(build_id_fn.as_bytes()) {
|
|
|
|
println!("{}", e);
|
|
|
|
}
|
|
|
|
|
2017-02-09 01:27:52 +00:00
|
|
|
protobuf_macros::expand("src/lib.in.rs", &out.join("lib.rs")).unwrap();
|
2015-04-25 20:32:07 +00:00
|
|
|
|
2017-02-22 14:27:54 +00:00
|
|
|
println!("cargo:rerun-if-changed=src/lib.in.rs");
|
|
|
|
println!("cargo:rerun-if-changed=src/spirc.rs");
|
|
|
|
println!("cargo:rerun-if-changed=src/connection");
|
|
|
|
|
|
|
|
}
|