-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
35 lines (31 loc) · 1.01 KB
/
build.rs
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
use std::process::Command;
macro_rules! get_command_output {
($cmd:expr, $( $arg:expr ),* ) => {
{
let output = Command::new($cmd)
$( .arg($arg) )*
.output()
.expect("Failed to execute command");
String::from_utf8(output.stdout).expect("Failed to convert output to string")
}
};
}
fn main() {
embuild::espidf::sysenv::output();
let current_date_time = get_command_output!("date", "+%d.%m.%Y %H:%M:%S");
let git_hash = get_command_output!("git", "rev-parse", "--short", "HEAD");
let git_is_tagged = Command::new("git")
.arg("describe")
.arg("--exact-match")
.arg("HEAD")
.output()
.unwrap()
.status
.success();
println!(
"cargo:rustc-env=PWOS_REL_OR_DEV=-{}",
if git_is_tagged { "release" } else { "devel" }
);
println!("cargo:rustc-env=PWOS_COMMIT={git_hash}");
println!("cargo:rustc-env=BUILD_DATE_TIME={current_date_time}");
}