Files
wasmer/lib/cli/build.rs
2022-10-04 15:32:10 +02:00

28 lines
792 B
Rust

use chrono::prelude::*;
use std::process::Command;
pub fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=WASMER_INSTALL_PREFIX");
// 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[..5]
);
}
let utc: DateTime<Utc> = Utc::now();
let date = utc.format("%Y-%m-%d").to_string();
println!("cargo:rustc-env=WASMER_BUILD_DATE={}", date);
}