mirror of https://github.com/rwf2/Rocket.git
Restrict compilation to nightlies >= 2017-07-09.
This commit is contained in:
parent
c7a2240442
commit
ebb6bb7860
|
@ -22,5 +22,5 @@ log = "^0.3"
|
||||||
compiletest_rs = "^0.2"
|
compiletest_rs = "^0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ansi_term = "^0.9"
|
yansi = "0.3"
|
||||||
version_check = "^0.1"
|
version_check = "0.1.2"
|
||||||
|
|
|
@ -1,46 +1,37 @@
|
||||||
//! This tiny build script ensures that rocket_codegen is not compiled with an
|
//! This tiny build script ensures that rocket_codegen is not compiled with an
|
||||||
//! incompatible version of rust.
|
//! incompatible version of rust.
|
||||||
|
|
||||||
extern crate ansi_term;
|
extern crate yansi;
|
||||||
extern crate version_check;
|
extern crate version_check;
|
||||||
|
|
||||||
use ansi_term::Colour::{Red, Yellow, Blue, White};
|
use yansi::Color::{Red, Yellow, Blue, White};
|
||||||
use version_check::{is_nightly, is_min_version, is_min_date};
|
use version_check::{supports_features, is_min_version, is_min_date};
|
||||||
|
|
||||||
// Specifies the minimum nightly version needed to compile Rocket's codegen.
|
// Specifies the minimum nightly version needed to compile Rocket's codegen.
|
||||||
const MIN_DATE: &'static str = "2017-06-19";
|
const MIN_DATE: &'static str = "2017-07-09";
|
||||||
const MIN_VERSION: &'static str = "1.19.0-nightly";
|
const MIN_VERSION: &'static str = "1.19.0-nightly";
|
||||||
|
|
||||||
// Convenience macro for writing to stderr.
|
|
||||||
macro_rules! printerr {
|
|
||||||
($($arg:tt)*) => ({
|
|
||||||
use std::io::prelude::*;
|
|
||||||
write!(&mut ::std::io::stderr(), "{}\n", format_args!($($arg)*))
|
|
||||||
.expect("Failed to write to stderr.")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let ok_nightly = is_nightly();
|
let ok_channel = supports_features();
|
||||||
let ok_version = is_min_version(MIN_VERSION);
|
let ok_version = is_min_version(MIN_VERSION);
|
||||||
let ok_date = is_min_date(MIN_DATE);
|
let ok_date = is_min_date(MIN_DATE);
|
||||||
|
|
||||||
let print_version_err = |version: &str, date: &str| {
|
let print_version_err = |version: &str, date: &str| {
|
||||||
printerr!("{} {}. {} {}.",
|
eprintln!("{} {}. {} {}.",
|
||||||
White.paint("Installed version is:"),
|
White.paint("Installed version is:"),
|
||||||
Yellow.paint(format!("{} ({})", version, date)),
|
Yellow.paint(format!("{} ({})", version, date)),
|
||||||
White.paint("Minimum required:"),
|
White.paint("Minimum required:"),
|
||||||
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
||||||
};
|
};
|
||||||
|
|
||||||
match (ok_nightly, ok_version, ok_date) {
|
match (ok_channel, ok_version, ok_date) {
|
||||||
(Some(is_nightly), Some((ok_version, version)), Some((ok_date, date))) => {
|
(Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) => {
|
||||||
if !is_nightly {
|
if !ok_channel {
|
||||||
printerr!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.bold().paint("Error:"),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a nightly version of Rust."));
|
White.paint("Rocket requires a nightly or dev version of Rust."));
|
||||||
print_version_err(&*version, &*date);
|
print_version_err(&*version, &*date);
|
||||||
printerr!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("See the getting started guide ("),
|
Blue.paint("See the getting started guide ("),
|
||||||
White.paint("https://rocket.rs/guide/getting-started/"),
|
White.paint("https://rocket.rs/guide/getting-started/"),
|
||||||
Blue.paint(") for more information."));
|
Blue.paint(") for more information."));
|
||||||
|
@ -48,10 +39,10 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ok_version || !ok_date {
|
if !ok_version || !ok_date {
|
||||||
printerr!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.bold().paint("Error:"),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket codegen requires a more recent version of rustc."));
|
White.paint("Rocket codegen requires a more recent version of rustc."));
|
||||||
printerr!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("Use `"),
|
Blue.paint("Use `"),
|
||||||
White.paint("rustup update"),
|
White.paint("rustup update"),
|
||||||
Blue.paint("` or your preferred method to update Rust."));
|
Blue.paint("` or your preferred method to update Rust."));
|
||||||
|
|
|
@ -35,8 +35,8 @@ lazy_static = "0.2"
|
||||||
rocket_codegen = { version = "0.2.8", path = "../codegen" }
|
rocket_codegen = { version = "0.2.8", path = "../codegen" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ansi_term = "^0.9"
|
yansi = "0.3"
|
||||||
version_check = "^0.1"
|
version_check = "0.1.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
testing = []
|
testing = []
|
||||||
|
|
58
lib/build.rs
58
lib/build.rs
|
@ -1,56 +1,52 @@
|
||||||
//! This tiny build script ensures that rocket is not compiled with an
|
//! This tiny build script ensures that rocket is not compiled with an
|
||||||
//! incompatible version of rust.
|
//! incompatible version of rust.
|
||||||
|
|
||||||
extern crate ansi_term;
|
extern crate yansi;
|
||||||
extern crate version_check;
|
extern crate version_check;
|
||||||
|
|
||||||
use ansi_term::Colour::{Red, Yellow, Blue, White};
|
use yansi::Color::{Red, Yellow, Blue, White};
|
||||||
use version_check::{is_nightly, is_min_version};
|
use version_check::{supports_features, is_min_version, is_min_date};
|
||||||
|
|
||||||
// Specifies the minimum nightly version needed to compile Rocket.
|
// Specifies the minimum nightly version needed to compile Rocket.
|
||||||
const MIN_VERSION: &'static str = "1.16.0-nightly";
|
const MIN_DATE: &'static str = "2017-07-09";
|
||||||
|
const MIN_VERSION: &'static str = "1.20.0-nightly";
|
||||||
// Convenience macro for writing to stderr.
|
|
||||||
macro_rules! printerr {
|
|
||||||
($($arg:tt)*) => ({
|
|
||||||
use std::io::prelude::*;
|
|
||||||
write!(&mut ::std::io::stderr(), "{}\n", format_args!($($arg)*))
|
|
||||||
.expect("Failed to write to stderr.")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let (ok_nightly, ok_version) = (is_nightly(), is_min_version(MIN_VERSION));
|
let ok_channel = supports_features();
|
||||||
let print_version_err = |version: &str| {
|
let ok_version = is_min_version(MIN_VERSION);
|
||||||
printerr!("{} {}. {} {}.",
|
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!("{} {}. {} {}.",
|
||||||
White.paint("Installed version is:"),
|
White.paint("Installed version is:"),
|
||||||
Yellow.paint(version),
|
Yellow.paint(format!("{} ({})", version, date)),
|
||||||
White.paint("Minimum required:"),
|
White.paint("Minimum required:"),
|
||||||
Yellow.paint(MIN_VERSION));
|
Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE)));
|
||||||
};
|
};
|
||||||
|
|
||||||
if let (Some(is_nightly), Some((ok_version, version))) = (ok_nightly, ok_version) {
|
if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple {
|
||||||
if !is_nightly {
|
if !ok_channel {
|
||||||
printerr!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.bold().paint("Error:"),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a nightly version of Rust."));
|
White.paint("Rocket requires a nightly or dev version of Rust."));
|
||||||
print_version_err(&*version);
|
print_version_err(&*version, &*date);
|
||||||
printerr!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("See the getting started guide ("),
|
Blue.paint("See the getting started guide ("),
|
||||||
White.paint("https://rocket.rs/guide/getting-started/"),
|
White.paint("https://rocket.rs/guide/getting-started/"),
|
||||||
Blue.paint(") for more information."));
|
Blue.paint(") for more information."));
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ok_version {
|
if !ok_version || !ok_date {
|
||||||
printerr!("{} {}",
|
eprintln!("{} {}",
|
||||||
Red.bold().paint("Error:"),
|
Red.paint("Error:").bold(),
|
||||||
White.paint("Rocket requires a newer version of rustc."));
|
White.paint("Rocket requires a more recent version of rustc."));
|
||||||
printerr!("{}{}{}",
|
eprintln!("{}{}{}",
|
||||||
Blue.paint("Use `"),
|
Blue.paint("Use `"),
|
||||||
White.paint("rustup update"),
|
White.paint("rustup update"),
|
||||||
Blue.paint("` or your preferred method to update Rust."));
|
Blue.paint("` or your preferred method to update Rust."));
|
||||||
print_version_err(&*version);
|
print_version_err(&*version, &*date);
|
||||||
panic!("Aborting compilation due to incompatible compiler.")
|
panic!("Aborting compilation due to incompatible compiler.")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue