2019-05-24 08:47:49 +00:00
|
|
|
//! Ensures Rocket isn't compiled with an incompatible version of Rust.
|
2017-01-15 09:16:47 +00:00
|
|
|
|
2020-07-17 14:36:38 +00:00
|
|
|
use yansi::{Paint, Color::{Red, Yellow}};
|
2017-01-15 09:16:47 +00:00
|
|
|
|
2020-07-17 14:36:38 +00:00
|
|
|
const MIN_VERSION: &'static str = "1.45.0";
|
2017-01-15 09:16:47 +00:00
|
|
|
|
2019-05-24 08:47:49 +00:00
|
|
|
macro_rules! err {
|
2020-07-17 14:36:38 +00:00
|
|
|
($version:expr, $msg:expr) => (
|
2019-05-24 08:47:49 +00:00
|
|
|
eprintln!("{} {}", Red.paint("Error:").bold(), Paint::new($msg).bold());
|
2020-07-17 14:36:38 +00:00
|
|
|
eprintln!("Installed version: {}", Yellow.paint(format!("{}", $version)));
|
|
|
|
eprintln!("Minimum required: {}", Yellow.paint(format!("{}", MIN_VERSION)));
|
2019-05-24 08:47:49 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-01-15 09:16:47 +00:00
|
|
|
fn main() {
|
2020-07-17 14:36:38 +00:00
|
|
|
if let Some(version) = version_check::Version::read() {
|
|
|
|
if !version.at_least(MIN_VERSION) {
|
|
|
|
err!(version, "Rocket requires a more recent version of rustc.");
|
2017-01-15 09:16:47 +00:00
|
|
|
panic!("Aborting compilation due to incompatible compiler.")
|
|
|
|
}
|
|
|
|
} else {
|
2019-05-24 08:47:49 +00:00
|
|
|
println!("cargo:warning={}", "Rocket was unable to check rustc compiler compatibility.");
|
2017-01-15 09:16:47 +00:00
|
|
|
println!("cargo:warning={}", "Build may fail due to incompatible rustc version.");
|
|
|
|
}
|
|
|
|
}
|