Rocket/core/lib/build.rs

38 lines
1.6 KiB
Rust
Raw Normal View History

2019-05-24 08:47:49 +00:00
//! Ensures Rocket isn't compiled with an incompatible version of Rust.
2019-05-24 08:47:49 +00:00
use yansi::{Paint, Color::{Red, Yellow, Blue}};
// Specifies the minimum nightly version needed to compile Rocket.
const MIN_DATE: &'static str = "2019-08-20";
const MIN_VERSION: &'static str = "1.39.0-nightly";
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)));
)
}
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."));
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.");
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.");
println!("cargo:warning={}", "Build may fail due to incompatible rustc version.");
}
}