1 // Copyright © 2020 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 use std::process::Command; 7 8 fn main() { 9 let mut version = "v".to_owned() + env!("CARGO_PKG_VERSION"); 10 11 if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() { 12 if git_out.status.success() { 13 if let Ok(git_out_str) = String::from_utf8(git_out.stdout) { 14 version = git_out_str; 15 } 16 } 17 } 18 19 // This println!() has a special behavior, as it will set the environment 20 // variable BUILD_VERSION, so that it can be reused from the binary. 21 // Particularly, this is used from src/main.rs to display the exact 22 // version. 23 println!("cargo:rustc-env=BUILD_VERSION={version}"); 24 } 25