Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/build.rs
1942 views
1
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
// SPDX-License-Identifier: Apache-2.0
3
4
use std::process::Command;
5
6
// this build script is called on en every `devtool build`,
7
// embedding the FIRECRACKER_VERSION directly in the resulting binary
8
fn main() {
9
let firecracker_version = Command::new("git")
10
.args(&["describe", "--dirty"])
11
.output()
12
.ok()
13
.and_then(|output| {
14
if output.status.success() {
15
return Some(output.stdout);
16
}
17
None
18
})
19
.and_then(|version_bytes| String::from_utf8(version_bytes).ok())
20
.map(|version_string| version_string.trim_start_matches('v').to_string())
21
.unwrap_or_else(|| env!("CARGO_PKG_VERSION").to_string());
22
23
println!(
24
"cargo:rustc-env=FIRECRACKER_VERSION={}",
25
firecracker_version
26
);
27
}
28
29