Skip to content

Commit 0462549

Browse files
committed
build.rs: Add support for embedding Buildroot hashes when built via Buildroot
1 parent 1806f01 commit 0462549

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

build.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::env;
12
use std::io;
23
use std::io::Write;
34
use std::process::Command;
@@ -12,7 +13,11 @@ fn main() {
1213
.output()
1314
.unwrap();
1415
let mut result = String::from_utf8(output.stdout).unwrap();
15-
if !Command::new("git")
16+
if result.is_empty() {
17+
result = env::var("BUILDROOT_COMMIT").unwrap_or_default();
18+
result.truncate(7);
19+
result = format!("br#{}", result); // add buildroot prefix
20+
} else if !Command::new("git")
1621
.args(&["diff", "--quiet"])
1722
.status()
1823
.expect("failed to execute process")
@@ -27,6 +32,10 @@ fn main() {
2732
.output()
2833
.unwrap();
2934
result = String::from_utf8(output.stdout).unwrap().replace("-", "");
35+
if result.is_empty() {
36+
result = env::var("AA_PROXY_COMMIT").unwrap_or_default();
37+
result.truncate(7);
38+
}
3039
_ = write!(&mut stdout, "cargo:rustc-env=GIT_DATE={}\n", result);
3140

3241
output = Command::new("date")

0 commit comments

Comments
 (0)