From 2d4eec8f7e435a00087d541eb59adf1219b1d119 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Fri, 24 May 2019 01:47:49 -0700 Subject: [PATCH] Update 'version_check' to 0.9. --- contrib/codegen/Cargo.toml | 2 +- contrib/codegen/build.rs | 53 ++++++++++++++------------------------ core/codegen/Cargo.toml | 2 +- core/codegen/build.rs | 53 ++++++++++++++------------------------ core/lib/Cargo.toml | 2 +- core/lib/build.rs | 53 ++++++++++++++------------------------ 6 files changed, 60 insertions(+), 105 deletions(-) diff --git a/contrib/codegen/Cargo.toml b/contrib/codegen/Cargo.toml index 2746e0f4..3bf56c68 100644 --- a/contrib/codegen/Cargo.toml +++ b/contrib/codegen/Cargo.toml @@ -23,7 +23,7 @@ quote = "0.6" [build-dependencies] yansi = "0.5" -version_check = "0.1.3" +version_check = "0.9.1" [dev-dependencies] compiletest_rs = { version = "0.3", features = ["stable"] } diff --git a/contrib/codegen/build.rs b/contrib/codegen/build.rs index 8b798570..d970e939 100644 --- a/contrib/codegen/build.rs +++ b/contrib/codegen/build.rs @@ -1,55 +1,40 @@ -//! This tiny build script ensures that rocket is not compiled with an -//! incompatible version of rust. +//! Ensures Rocket isn't compiled with an incompatible version of Rust. extern crate yansi; extern crate version_check; -use yansi::Color::{Red, Yellow, Blue}; -use version_check::{supports_features, is_min_version, is_min_date}; +use yansi::{Paint, Color::{Red, Yellow, Blue}}; // Specifies the minimum nightly version needed to compile Rocket. const MIN_DATE: &'static str = "2018-10-05"; const MIN_VERSION: &'static str = "1.31.0-nightly"; +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() { - let ok_channel = supports_features(); - let ok_version = is_min_version(MIN_VERSION); - let ok_date = is_min_date(MIN_DATE); - let triple = (ok_channel, ok_version, ok_date); + if let Some((version, channel, date)) = version_check::triple() { + if !channel.supports_features() { + err!(version, date, "Rocket requires a 'dev' or 'nightly' version of rustc."); - let print_version_err = |version: &str, date: &str| { - eprintln!("{} {}. {} {}.", - "Installed version is:", - Yellow.paint(format!("{} ({})", version, date)), - "Minimum required:", - Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE))); - }; + eprint!("{}", Blue.paint("See the getting started guide (")); + eprint!("https://rocket.rs/v0.5/guide/getting-started/"); + eprintln!("{}", Blue.paint(") for more information.")); - if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple { - if !ok_channel { - eprintln!("{} {}", - Red.paint("Error:").bold(), - "Rocket requires a nightly or dev version of Rust."); - print_version_err(&*version, &*date); - eprintln!("{}{}{}", - Blue.paint("See the getting started guide ("), - "https://rocket.rs/v0.4/guide/getting-started/", - Blue.paint(") for more information.")); panic!("Aborting compilation due to incompatible compiler.") } - if !ok_version || !ok_date { - eprintln!("{} {}", - Red.paint("Error:").bold(), - "Rocket requires a more recent version of rustc."); - eprintln!("{}{}{}", - Blue.paint("Use `"), "rustup update", - Blue.paint("` or your preferred method to update Rust.")); - print_version_err(&*version, &*date); + if !version.at_least(MIN_VERSION) || !date.at_least(MIN_DATE) { + err!(version, date, "Rocket requires a more recent version of rustc."); panic!("Aborting compilation due to incompatible compiler.") } } else { - println!("cargo:warning={}", "Rocket was unable to check rustc compatibility."); + println!("cargo:warning={}", "Rocket was unable to check rustc compiler compatibility."); println!("cargo:warning={}", "Build may fail due to incompatible rustc version."); } } diff --git a/core/codegen/Cargo.toml b/core/codegen/Cargo.toml index b060207c..fba26e91 100644 --- a/core/codegen/Cargo.toml +++ b/core/codegen/Cargo.toml @@ -22,7 +22,7 @@ devise = "0.2" [build-dependencies] yansi = "0.5" -version_check = "0.1.3" +version_check = "0.9.1" [dev-dependencies] rocket = { version = "0.4.1", path = "../lib" } diff --git a/core/codegen/build.rs b/core/codegen/build.rs index 3d953822..1f5c8131 100644 --- a/core/codegen/build.rs +++ b/core/codegen/build.rs @@ -1,55 +1,40 @@ -//! This tiny build script ensures that rocket is not compiled with an -//! incompatible version of rust. +//! Ensures Rocket isn't compiled with an incompatible version of Rust. extern crate yansi; extern crate version_check; -use yansi::Color::{Red, Yellow, Blue}; -use version_check::{supports_features, is_min_version, is_min_date}; +use yansi::{Paint, Color::{Red, Yellow, Blue}}; // Specifies the minimum nightly version needed to compile Rocket. const MIN_DATE: &'static str = "2019-01-13"; const MIN_VERSION: &'static str = "1.33.0-nightly"; +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() { - let ok_channel = supports_features(); - let ok_version = is_min_version(MIN_VERSION); - let ok_date = is_min_date(MIN_DATE); - let triple = (ok_channel, ok_version, ok_date); + if let Some((version, channel, date)) = version_check::triple() { + if !channel.supports_features() { + err!(version, date, "Rocket (codegen) requires a 'dev' or 'nightly' version of rustc."); - let print_version_err = |version: &str, date: &str| { - eprintln!("{} {}. {} {}.", - "Installed version is:", - Yellow.paint(format!("{} ({})", version, date)), - "Minimum required:", - Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE))); - }; + eprint!("{}", Blue.paint("See the getting started guide (")); + eprint!("https://rocket.rs/v0.5/guide/getting-started/"); + eprintln!("{}", Blue.paint(") for more information.")); - if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple { - if !ok_channel { - eprintln!("{} {}", - Red.paint("Error:").bold(), - "Rocket requires a nightly or dev version of Rust."); - print_version_err(&*version, &*date); - eprintln!("{}{}{}", - Blue.paint("See the getting started guide ("), - "https://rocket.rs/v0.4/guide/getting-started/", - Blue.paint(") for more information.")); panic!("Aborting compilation due to incompatible compiler.") } - if !ok_version || !ok_date { - eprintln!("{} {}", - Red.paint("Error:").bold(), - "Rocket requires a more recent version of rustc."); - eprintln!("{}{}{}", - Blue.paint("Use `"), "rustup update", - Blue.paint("` or your preferred method to update Rust.")); - print_version_err(&*version, &*date); + if !version.at_least(MIN_VERSION) || !date.at_least(MIN_DATE) { + err!(version, date, "Rocket (codegen) requires a more recent version of rustc."); panic!("Aborting compilation due to incompatible compiler.") } } else { - println!("cargo:warning={}", "Rocket was unable to check rustc compatibility."); + println!("cargo:warning={}", "Rocket was unable to check rustc compiler compatibility."); println!("cargo:warning={}", "Build may fail due to incompatible rustc version."); } } diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index f2cf807a..d68418e7 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -38,7 +38,7 @@ atty = "0.2" [build-dependencies] yansi = "0.5" -version_check = "0.1.3" +version_check = "0.9.1" [dev-dependencies] # TODO: Find a way to not depend on this. diff --git a/core/lib/build.rs b/core/lib/build.rs index 8db27778..ae6fb744 100644 --- a/core/lib/build.rs +++ b/core/lib/build.rs @@ -1,55 +1,40 @@ -//! This tiny build script ensures that rocket is not compiled with an -//! incompatible version of rust. +//! Ensures Rocket isn't compiled with an incompatible version of Rust. extern crate yansi; extern crate version_check; -use yansi::Color::{Red, Yellow, Blue}; -use version_check::{supports_features, is_min_version, is_min_date}; +use yansi::{Paint, Color::{Red, Yellow, Blue}}; // Specifies the minimum nightly version needed to compile Rocket. const MIN_DATE: &'static str = "2019-04-05"; const MIN_VERSION: &'static str = "1.35.0-nightly"; +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() { - let ok_channel = supports_features(); - let ok_version = is_min_version(MIN_VERSION); - let ok_date = is_min_date(MIN_DATE); - let triple = (ok_channel, ok_version, ok_date); + 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."); - let print_version_err = |version: &str, date: &str| { - eprintln!("{} {}. {} {}.", - "Installed version is:", - Yellow.paint(format!("{} ({})", version, date)), - "Minimum required:", - Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE))); - }; + eprint!("{}", Blue.paint("See the getting started guide (")); + eprint!("https://rocket.rs/v0.5/guide/getting-started/"); + eprintln!("{}", Blue.paint(") for more information.")); - if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple { - if !ok_channel { - eprintln!("{} {}", - Red.paint("Error:").bold(), - "Rocket requires a nightly or dev version of Rust."); - print_version_err(&*version, &*date); - eprintln!("{}{}{}", - Blue.paint("See the getting started guide ("), - "https://rocket.rs/v0.4/guide/getting-started/", - Blue.paint(") for more information.")); panic!("Aborting compilation due to incompatible compiler.") } - if !ok_version || !ok_date { - eprintln!("{} {}", - Red.paint("Error:").bold(), - "Rocket requires a more recent version of rustc."); - eprintln!("{}{}{}", - Blue.paint("Use `"), "rustup update", - Blue.paint("` or your preferred method to update Rust.")); - print_version_err(&*version, &*date); + 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 { - println!("cargo:warning={}", "Rocket was unable to check rustc compatibility."); + println!("cargo:warning={}", "Rocket was unable to check rustc compiler compatibility."); println!("cargo:warning={}", "Build may fail due to incompatible rustc version."); } }