forked from nervosnetwork/capsule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
35 lines (31 loc) · 962 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
26
27
28
29
30
31
32
33
34
35
extern crate includedir_codegen;
use includedir_codegen::Compression;
use std::io::ErrorKind;
fn main() {
// include templates
includedir_codegen::start("FILES")
.dir("templates", Compression::Gzip)
.build("templates.rs")
.unwrap();
let get_command_id = std::process::Command::new("git")
.args([
"describe",
"--dirty",
"--always",
"--match",
"__EXCLUDE__",
"--abbrev=7",
])
.output();
let commit_id = match get_command_id {
Ok(output) => String::from_utf8(output.stdout).expect("commit id"),
Err(err) => {
if let ErrorKind::NotFound = err.kind() {
panic!("error when get commit id: `git` was not found!");
} else {
panic!("error when get commit id: {}", err);
}
}
};
println!("cargo:rustc-env=COMMIT_ID={}", commit_id);
}