forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
26 lines (23 loc) · 761 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
use chrono::prelude::*;
use std::process::Command;
pub fn main() {
// Set WASMER_GIT_HASH
let git_hash = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok())
.unwrap_or_default();
println!("cargo:rustc-env=WASMER_BUILD_GIT_HASH={}", git_hash);
if git_hash.len() > 5 {
println!(
"cargo:rustc-env=WASMER_BUILD_GIT_HASH_SHORT={}",
&git_hash[..7]
);
} else {
println!("cargo:rustc-env=WASMER_BUILD_GIT_HASH_SHORT=???????");
}
let utc: DateTime<Utc> = Utc::now();
let date = utc.format("%Y-%m-%d").to_string();
println!("cargo:rustc-env=WASMER_BUILD_DATE={}", date);
}