2022-02-11 02:02:03 +00:00
|
|
|
// Copyright © 2020 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
|
|
|
#[macro_use(crate_version)]
|
|
|
|
extern crate clap;
|
|
|
|
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut git_human_readable = "v".to_owned() + crate_version!();
|
2022-09-20 08:46:19 +00:00
|
|
|
if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() {
|
2022-02-11 02:02:03 +00:00
|
|
|
if git_out.status.success() {
|
|
|
|
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
|
|
|
git_human_readable = git_out_str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This println!() has a special behavior, as it will set the environment
|
2022-02-16 23:06:45 +00:00
|
|
|
// variable GIT_HUMAN_READABLE, so that it can be reused from the binary.
|
2022-02-11 02:02:03 +00:00
|
|
|
// Particularly, this is used from the main.rs to display the exact
|
|
|
|
// version information.
|
|
|
|
println!("cargo:rustc-env=GIT_HUMAN_READABLE={}", git_human_readable);
|
|
|
|
}
|