Update 'version_check' to 0.9.

This commit is contained in:
Sergio Benitez 2019-05-24 01:47:49 -07:00
parent be829bd891
commit 2d4eec8f7e
6 changed files with 60 additions and 105 deletions

View File

@ -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"] }

View File

@ -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.");
}
}

View File

@ -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" }

View File

@ -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.");
}
}

View File

@ -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.

View File

@ -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.");
}
}