From c5e0b6fa03e2a9a824383dd03c940ff093279035 Mon Sep 17 00:00:00 2001 From: rabite Date: Sun, 30 Jun 2019 11:41:32 +0200 Subject: [PATCH] check for nightly compiler in build.rs --- Cargo.lock | 25 +++++++++++++++++++++++++ Cargo.toml | 4 ++++ build.rs | 26 ++++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 040fb91..6ae7afd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,6 +463,7 @@ dependencies = [ "parse-ansi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pathbuftools 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "signal-notify 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "systemstat 0.1.4 (git+https://github.com/myfreeweb/systemstat?tag=v0.1.4)", "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1118,6 +1119,14 @@ name = "rustc-demangle" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "same-file" version = "1.0.4" @@ -1136,6 +1145,19 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "signal-notify" version = "0.1.3" @@ -1499,9 +1521,12 @@ dependencies = [ "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum signal-notify 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "847fbedad7c2e6fbb6077befa1fa61a6336658eaae2d9fe66cb94a0024742f4e" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" diff --git a/Cargo.toml b/Cargo.toml index 4a146b5..da390ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,10 @@ pathbuftools = "0.1" clap = "2.33" mime = "0.3.13" +[build-dependencies] +termion = "1.5.1" +rustc_version = "0.2.3" + [features] default = ["video"] video = [] diff --git a/build.rs b/build.rs index 07f1acb..6134a9c 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,26 @@ +extern crate termion; +extern crate rustc_version; + +use rustc_version::{version_meta, Channel}; + use std::process::Command; -fn main() { + +fn main() -> Result<(),()> { + // Bail out if compiler isn't a nightly + if let Ok(false) = version_meta().map(|m| m.channel == Channel::Nightly) { + eprint!("{}", termion::color::Fg(termion::color::Red)); + eprint!("{}", termion::style::Bold); + eprint!("{}", termion::style::Underline); + eprintln!("NIHGTLY COMPILER required"); + eprintln!("Please install a nighlty compiler to proceed: https://rustup.rs/"); + eprint!("{}", termion::style::Reset); + eprintln!("rustup toolchain install nightly"); + eprintln!("source ~/.cargo/env"); + + return Err(()); + } + // rename so we can just extract this into config dir later Command::new("cp") .args("-a extra hunter".split(" ")) @@ -15,5 +35,7 @@ fn main() { // delete directory we just compressed std::fs::remove_dir_all("hunter") - .expect("Couldn't delete temporary config directory \"hunter\"") + .expect("Couldn't delete temporary config directory \"hunter\""); + + return Ok(()); }