forked from wasix-org/cargo-wasix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
25 lines (22 loc) · 760 Bytes
/
build.rs
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
use std::process::Command;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output() {
if output.status.success() {
let sha = String::from_utf8(output.stdout).unwrap();
let output = Command::new("git")
.arg("show")
.arg("-s")
.arg("--format=%ci")
.arg("HEAD")
.output()
.unwrap();
let date = String::from_utf8(output.stdout).unwrap();
println!(
"cargo:rustc-env=GIT_INFO={} {}",
&sha.trim()[0..10],
date.split_whitespace().next().unwrap(),
)
}
}
}