-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
47 lines (42 loc) · 1.04 KB
/
build.rs
File metadata and controls
47 lines (42 loc) · 1.04 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
43
44
45
46
47
/*
* Copyright (c) 2024 Jonathan "Nath" Schild. Licensed under the EUPL-1.2
*/
use std::{env, process::Command};
fn main() {
let hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.unwrap()
.stdout;
println!(
"cargo:rustc-env=BUILD_HASH={}",
String::from_utf8(hash).unwrap()
);
let epoch = Command::new("date")
.args(["-u", "+%s"])
.output()
.unwrap()
.stdout;
println!(
"cargo:rustc-env=BUILD_EPOCH={}",
String::from_utf8(epoch).unwrap()
);
let date = Command::new("date")
.args(["-u", "-Iseconds"])
.output()
.unwrap()
.stdout;
println!(
"cargo:rustc-env=BUILD_DATE={}",
String::from_utf8(date).unwrap()
);
let rustc = Command::new(env::var("RUSTC").unwrap())
.args(["--version"])
.output()
.unwrap()
.stdout;
println!(
"cargo:rustc-env=BUILD_RUSTC={}",
String::from_utf8(rustc).unwrap()
)
}