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
|
|
|
|
2017-06-02 04:44:31 +00:00
|
|
|
extern crate yansi;
|
2017-01-15 09:16:47 +00:00
|
|
|
extern crate version_check;
|
|
|
|
|
2019-05-24 08:47:49 +00:00
|
|
|
use yansi::{Paint, Color::{Red, Yellow, Blue}};
|
2017-01-15 09:16:47 +00:00
|
|
|
|
|
|
|
// Specifies the minimum nightly version needed to compile Rocket.
|
2018-12-09 19:24:37 +00:00
|
|
|
const MIN_DATE: &'static str = "2019-04-05";
|
|
|
|
const MIN_VERSION: &'static str = "1.35.0-nightly";
|
2017-01-15 09:16:47 +00:00
|
|
|
|
2019-05-24 08:47:49 +00:00
|
|
|
macro_rules! err {
|
|
|
|
($version:expr, $date:expr, $msg:expr) => (
|
|
|
|
eprintln!("{} {}", Red.paint("Error:").bold(), Paint::new($msg).bold());
|
|
|
|
eprintln!("Installed version: {}", Yellow.paint(format!("{} ({})", $version, $date)));
|
|
|
|
eprintln!("Minimum required: {}", Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-01-15 09:16:47 +00:00
|
|
|
fn main() {
|
2019-05-24 08:47:49 +00:00
|
|
|
if let Some((version, channel, date)) = version_check::triple() {
|
|
|
|
if !channel.supports_features() {
|
|
|
|
err!(version, date, "Rocket (core) requires a 'dev' or 'nightly' version of rustc.");
|
|
|
|
|
|
|
|
eprint!("{}", Blue.paint("See the getting started guide ("));
|
|
|
|
eprint!("https://rocket.rs/v0.5/guide/getting-started/");
|
|
|
|
eprintln!("{}", Blue.paint(") for more information."));
|
|
|
|
|
2017-01-15 09:16:47 +00:00
|
|
|
panic!("Aborting compilation due to incompatible compiler.")
|
|
|
|
}
|
|
|
|
|
2019-05-24 08:47:49 +00:00
|
|
|
if !version.at_least(MIN_VERSION) || !date.at_least(MIN_DATE) {
|
|
|
|
err!(version, date, "Rocket (core) 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.");
|
|
|
|
}
|
|
|
|
}
|