-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
35 lines (29 loc) · 978 Bytes
/
build.rs
File metadata and controls
35 lines (29 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Generates static build info.
use std::process::Command;
use anyhow::Error;
use vergen::{BuildBuilder, CargoBuilder, Emitter, RustcBuilder, SysinfoBuilder};
fn main() -> Result<(), Error> {
{
let git_hash = std::env::var("GIT_COMMIT").unwrap_or_else(|_| {
let output = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
String::from_utf8(output.stdout).unwrap()
});
println!("cargo:rustc-env=GIT_HASH={}", git_hash.trim());
}
{
let build = BuildBuilder::all_build()?;
let cargo = CargoBuilder::all_cargo()?;
let rustc = RustcBuilder::all_rustc()?;
let si = SysinfoBuilder::all_sysinfo()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&cargo)?
.add_instructions(&rustc)?
.add_instructions(&si)?
.emit()?;
}
Ok(())
}