MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / main

Function main

cloud-hypervisor/build.rs:9–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7use std::process::Command;
8
9fn main() {
10 let mut version = "v".to_owned() + env!("CARGO_PKG_VERSION");
11
12 if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output()
13 && git_out.status.success()
14 && let Ok(git_out_str) = String::from_utf8(git_out.stdout)
15 {
16 version = git_out_str;
17 // Pop the trailing newline.
18 version.pop();
19 }
20
21 // Append CH_EXTRA_VERSION to version if it is set.
22 if let Ok(extra_version) = env::var("CH_EXTRA_VERSION") {
23 println!("cargo:rerun-if-env-changed=CH_EXTRA_VERSION");
24 version.push_str(&format!("-{extra_version}"));
25 }
26
27 // This println!() has a special behavior, as it will set the environment
28 // variable BUILD_VERSION, so that it can be reused from the binary.
29 // Particularly, this is used from src/main.rs to display the exact
30 // version.
31 println!("cargo:rustc-env=BUILD_VERSION={version}");
32}

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
argsMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected