Rocket/core/lib/build.rs

25 lines
973 B
Rust
Raw Normal View History

2019-05-24 08:47:49 +00:00
//! Ensures Rocket isn't compiled with an incompatible version of Rust.
use yansi::{Paint, Color::{Red, Yellow}};
fn main() {
2021-06-30 20:36:23 +00:00
const MIN_VERSION: &str = "1.46.0";
2020-10-22 02:56:12 +00:00
if let Some(version) = version_check::Version::read() {
if !version.at_least(MIN_VERSION) {
2020-10-22 02:56:12 +00:00
let msg = "Rocket requires a more recent version of rustc.";
eprintln!("{} {}", Red.paint("Error:").bold(), Paint::new(msg).bold());
2021-06-30 20:36:23 +00:00
eprintln!("Installed version: {}", Yellow.paint(version));
eprintln!("Minimum required: {}", Yellow.paint(MIN_VERSION));
panic!("Aborting compilation due to incompatible compiler.")
}
} else {
2021-06-30 20:36:23 +00:00
println!("cargo:warning=Rocket was unable to check rustc compiler compatibility.");
println!("cargo:warning=Build may fail due to incompatible rustc version.");
}
if let Some(true) = version_check::is_feature_flaggable() {
println!("cargo:rustc-cfg=nightly");
}
}