mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-12-04 05:21:06 +00:00
9908d7bdae
Issue: https://gitee.com/openharmony/third_party_rust_cxx/issues/I717LF Signed-off-by: xxlight <xiaoxiaoliang2@huawei.com> Change-Id: I46fefbe0979305aca135968cf200598ceb7b8f92
33 lines
869 B
Rust
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 })
|
|
}
|