32 lines
952 B
Rust
32 lines
952 B
Rust
use std::process::Command;
|
|
|
|
fn main() {
|
|
const MIN_VERSION: (u32, u32, u32) = (1, 75, 0);
|
|
|
|
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
|
|
let output = Command::new(&rustc)
|
|
.arg("--version")
|
|
.output()
|
|
.expect("failed to invoke rustc");
|
|
|
|
let version_line = String::from_utf8_lossy(&output.stdout);
|
|
let version_str = version_line.split_whitespace().nth(1).unwrap_or("0.0.0");
|
|
let sanitized = version_str.split('-').next().unwrap_or(version_str);
|
|
|
|
let mut parts = sanitized
|
|
.split('.')
|
|
.map(|part| part.parse::<u32>().unwrap_or(0));
|
|
let current = (
|
|
parts.next().unwrap_or(0),
|
|
parts.next().unwrap_or(0),
|
|
parts.next().unwrap_or(0),
|
|
);
|
|
|
|
if current < MIN_VERSION {
|
|
panic!(
|
|
"owlen requires rustc {}.{}.{} or newer (found {version_line})",
|
|
MIN_VERSION.0, MIN_VERSION.1, MIN_VERSION.2
|
|
);
|
|
}
|
|
}
|