-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.rs
29 lines (24 loc) · 644 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
use chrono::prelude::{DateTime, Utc};
use std::process::Command;
fn get_git_rev() -> Option<String> {
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()?;
if output.status.success() {
String::from_utf8(output.stdout).ok()
} else {
None
}
}
fn get_compile_date() -> String {
let system_time = std::time::SystemTime::now();
let date_time: DateTime<Utc> = system_time.into();
format!("{}", date_time.format("%+"))
}
fn main() {
println!("cargo:rustc-env=STATIC_BUILD_DATE={}", get_compile_date());
if let Some(rev) = get_git_rev() {
println!("cargo:rustc-env=GIT_REV={}", rev);
}
}