-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
13 lines (12 loc) · 844 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
fn run(cmd: &mut Command) -> String {
cmd.output().map_or("".to_string(), |d| String::from_utf8_lossy(&d.stdout).parse().unwrap())
}
fn main() {
println!("cargo:rustc-env=GK_SERVER_COMMIT_MSG={}", run(Command::new("git").arg("show").arg("-s").arg("--format=%s")));
println!("cargo:rustc-env=GK_SERVER_COMMIT_HASH={}", run(Command::new("git").arg("rev-parse").arg("--short").arg("HEAD")));
println!("cargo:rustc-env=GK_SERVER_BRANCH={}", run(Command::new("git").arg("rev-parse").arg("--abbrev-ref").arg("HEAD")));
println!("cargo:rustc-env=GK_SERVER_COMMITTER={}", run(Command::new("git").arg("show").arg("-s").arg("--format=%an")));
println!("cargo:rustc-env=GK_SERVER_COMPILED_AT={}", SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs())
}