Rocket

A web framework for Rust. https://rocket.rs (mirror)
git clone git://git.thc420.xyz/Rocket
Log | Files | Refs | README

commit e458df094ffa6e4a793a9b8257950a0409f71487
parent 8434a98d5c37e8889cad76fbd5426736e476f3b6
Author: Sergio Benitez <sb@sergio.bz>
Date:   Fri, 24 May 2019 01:47:49 -0700

Update 'version_check' to 0.9.

Diffstat:
Mcontrib/codegen/Cargo.toml | 2+-
Mcontrib/codegen/build.rs | 57+++++++++++++++++++++------------------------------------
Mcore/codegen/Cargo.toml | 2+-
Mcore/codegen/build.rs | 57+++++++++++++++++++++------------------------------------
Mcore/lib/Cargo.toml | 2+-
Mcore/lib/build.rs | 57+++++++++++++++++++++------------------------------------
6 files changed, 66 insertions(+), 111 deletions(-)

diff --git 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 @@ -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); - - 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))); - }; - - 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.5/guide/getting-started/", - Blue.paint(") for more information.")); + 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."); + + 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.") } - 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 @@ -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.5.0-dev", path = "../lib" } diff --git 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); - - 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))); - }; - - 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.5/guide/getting-started/", - Blue.paint(") for more information.")); + 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."); + + 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.") } - 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 @@ -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 @@ -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); - - 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))); - }; - - 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.5/guide/getting-started/", - Blue.paint(") for more information.")); + 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.") } - 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."); } }