-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
43 lines (36 loc) · 1.28 KB
/
Copy pathbuild.rs
File metadata and controls
43 lines (36 loc) · 1.28 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
use std::process::Command;
fn main() {
// Git short hash
let git_hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_else(|| "unknown".into());
// Dirty flag
let dirty = Command::new("git")
.args(["diff", "--quiet"])
.status()
.map(|s| !s.success())
.unwrap_or(false);
let git_info = if dirty {
format!("{}-dirty", git_hash)
} else {
git_hash
};
// Build timestamp (UTC)
let timestamp = Command::new("date")
.args(["-u", "+%Y-%m-%dT%H:%M:%SZ"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_else(|| "unknown".into());
println!("cargo:rustc-env=SLMRS_GIT_INFO={}", git_info);
println!("cargo:rustc-env=SLMRS_BUILD_TIME={}", timestamp);
// Rebuild when dashboard frontend assets change (rust-embed picks up new files)
println!("cargo:rerun-if-changed=dashboard/build");
// Force rebuild every time so the timestamp is always current.
println!("cargo:rerun-if-changed=FORCE_REBUILD");
}