mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 19:15:46 +00:00
842515c2f1
Since the top-level Cargo.toml specifies a vmm-sys-util revision but not the sub crates, Cargo.lock points at 2 different crates. cargo vendor copies both of them into the vendor directory but forces the build to use the one coming from the top level driven requirement. Although this is a waste of space, this is a cargo vendor limitation that we have to live with for now. Also, because the dependency onto linux-loader had to be updated, we had to specify a newly introduced feature called "elf". Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
44 lines
1.0 KiB
Rust
44 lines
1.0 KiB
Rust
use std::env;
|
|
use std::process::Command;
|
|
use std::str::{self, FromStr};
|
|
|
|
fn main(){
|
|
let minor = match rustc_minor_version() {
|
|
Some(minor) => minor,
|
|
None => return,
|
|
};
|
|
|
|
// const fn stabilized in Rust 1.31:
|
|
if minor >= 31 {
|
|
println!("cargo:rustc-cfg=bitflags_const_fn");
|
|
}
|
|
}
|
|
|
|
fn rustc_minor_version() -> Option<u32> {
|
|
let rustc = match env::var_os("RUSTC") {
|
|
Some(rustc) => rustc,
|
|
None => return None,
|
|
};
|
|
|
|
let output = match Command::new(rustc).arg("--version").output() {
|
|
Ok(output) => output,
|
|
Err(_) => return None,
|
|
};
|
|
|
|
let version = match str::from_utf8(&output.stdout) {
|
|
Ok(version) => version,
|
|
Err(_) => return None,
|
|
};
|
|
|
|
let mut pieces = version.split('.');
|
|
if pieces.next() != Some("rustc 1") {
|
|
return None;
|
|
}
|
|
|
|
let next = match pieces.next() {
|
|
Some(next) => next,
|
|
None => return None,
|
|
};
|
|
|
|
u32::from_str(next).ok()
|
|
} |