2020-02-13 05:11:03 +00:00
|
|
|
// Copyright © 2020 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() {
|
2023-01-06 16:33:32 +00:00
|
|
|
let mut version = "v".to_owned() + env!("CARGO_PKG_VERSION");
|
2020-09-04 21:31:38 +00:00
|
|
|
|
2022-09-20 08:46:19 +00:00
|
|
|
if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() {
|
2020-09-04 21:31:38 +00:00
|
|
|
if git_out.status.success() {
|
|
|
|
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
|
|
|
version = git_out_str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-13 05:11:03 +00:00
|
|
|
|
|
|
|
// This println!() has a special behavior, as it will set the environment
|
2023-04-07 08:15:23 +00:00
|
|
|
// variable BUILD_VERSION, so that it can be reused from the binary.
|
2020-02-13 05:11:03 +00:00
|
|
|
// Particularly, this is used from src/main.rs to display the exact
|
|
|
|
// version.
|
2023-04-07 08:15:23 +00:00
|
|
|
println!("cargo:rustc-env=BUILD_VERSION={version}");
|
2020-02-13 05:11:03 +00:00
|
|
|
}
|