-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
42 lines (41 loc) · 1.1 KB
/
Copy pathbuild.rs
File metadata and controls
42 lines (41 loc) · 1.1 KB
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
36
37
38
39
40
41
42
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()
)
}