main: Display git commit hash with the '--version' option

Add a build-script to propagate the git commit hash to other crates at
compile time through environment variables, and display the hash along
with the '--version' option.

Fixes #729

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen
2020-02-12 21:11:03 -08:00
committed by Sebastien Boeuf
parent bdb92f9ace
commit ebd83699dc
3 changed files with 27 additions and 2 deletions

View File

@@ -6,7 +6,7 @@
extern crate vmm;
extern crate vmm_sys_util;
#[macro_use(crate_version, crate_authors)]
#[macro_use(crate_authors)]
extern crate clap;
use clap::{App, Arg, ArgGroup, ArgMatches};
@@ -78,7 +78,9 @@ fn create_app<'a, 'b>(
api_server_path: &'a str,
) -> App<'a, 'b> {
App::new("cloud-hypervisor")
.version(crate_version!())
// 'BUILT_VERSION' is set by the build script 'build.rs' at
// compile time
.version(env!("BUILT_VERSION"))
.author(crate_authors!())
.about("Launch a cloud-hypervisor VMM.")
.group(ArgGroup::with_name("vm-config").multiple(true))