-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
26 lines (23 loc) · 852 Bytes
/
build.rs
File metadata and controls
26 lines (23 loc) · 852 Bytes
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
use std::process::Command;
fn main() {
let git_sha = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|o| {
if o.status.success() {
String::from_utf8(o.stdout).ok()
} else {
None
}
})
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| "unknown".to_string());
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string());
let build_time =
std::env::var("OPENAGENT_BUILD_TIME_UTC").unwrap_or_else(|_| "unknown".to_string());
println!("cargo:rustc-env=OPENAGENT_GIT_SHA={git_sha}");
println!("cargo:rustc-env=OPENAGENT_TARGET={target}");
println!("cargo:rustc-env=OPENAGENT_BUILD_TIME_UTC={build_time}");
}