third_party_rust_cxx/build.rs
xxlight 9908d7bdae cxx and bindgen tests
Issue: https://gitee.com/openharmony/third_party_rust_cxx/issues/I717LF
Signed-off-by: xxlight <xiaoxiaoliang2@huawei.com>
Change-Id: I46fefbe0979305aca135968cf200598ceb7b8f92
2023-05-09 12:02:10 +08:00

33 lines
869 B
Rust

use std::env;
use std::path::Path;
use std::process::Command;
fn main() {
if let Some(rustc) = rustc_version() {
if rustc.minor < 60 {
println!("cargo:warning=The cxx crate requires a rustc version 1.60.0 or newer.");
println!(
"cargo:warning=You appear to be building with: {}",
rustc.version,
);
}
}
}
struct RustVersion {
version: String,
minor: u32,
}
fn rustc_version() -> Option<RustVersion> {
let rustc = env::var_os("RUSTC")?;
let output = Command::new(rustc).arg("--version").output().ok()?;
let version = String::from_utf8(output.stdout).ok()?;
let mut pieces = version.split('.');
if pieces.next() != Some("rustc 1") {
return None;
}
let minor = pieces.next()?.parse().ok()?;
Some(RustVersion { version, minor })
}