2020-02-13 05:11:03 +00:00
|
|
|
// Copyright © 2020 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
2020-09-04 21:31:38 +00:00
|
|
|
#[macro_use(crate_version)]
|
|
|
|
extern crate clap;
|
|
|
|
|
2020-02-13 05:11:03 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() {
|
2020-10-29 14:23:34 +00:00
|
|
|
let mut version = "v".to_owned() + crate_version!();
|
2020-09-04 21:31:38 +00:00
|
|
|
|
|
|
|
if let Ok(git_out) = Command::new("git").args(&["describe", "--dirty"]).output() {
|
|
|
|
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
|
|
|
|
// variable BUILT_VERSION, so that it can be reused from the binary.
|
|
|
|
// Particularly, this is used from src/main.rs to display the exact
|
|
|
|
// version.
|
2020-09-04 21:31:38 +00:00
|
|
|
println!("cargo:rustc-env=BUILT_VERSION={}", version);
|
2020-02-13 05:11:03 +00:00
|
|
|
}
|