From 364f42d78d5227c6d31360a4fe6ba3503256133a Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sun, 13 May 2018 10:11:52 +0200 Subject: [PATCH] Fix build script for dev channel --- build.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index c13eed1f585..913f7b4ee89 100644 --- a/build.rs +++ b/build.rs @@ -21,6 +21,15 @@ use rustc_version::{version_meta, version_meta_for, Channel, Version, VersionMet use ansi_term::Colour::Red; fn main() { + check_rustc_version(); + + // Forward the profile to the main compilation + println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); + // Don't rebuild even if nothing changed + println!("cargo:rerun-if-changed=build.rs"); +} + +fn check_rustc_version() { let string = include_str!("min_version.txt"); let min_version_meta = version_meta_for(string) .expect("Could not parse version string in min_version.txt"); @@ -31,6 +40,12 @@ fn main() { let min_date_str = min_version_meta.clone().commit_date .expect("min_version.txt does not contain a rustc commit date"); + // Dev channel (rustc built from git) does not have any date or commit information in rustc -vV + // `current_version_meta.commit_date` would crash, so we return early here. + if current_version_meta.channel == Channel::Dev { + return + } + let current_version = current_version_meta.clone().semver; let current_date_str = current_version_meta.clone().commit_date .expect("current rustc version information does not contain a rustc commit date"); @@ -69,11 +84,6 @@ fn main() { print_version_err(¤t_version, &*current_date_str); panic!("Aborting compilation due to incompatible compiler.") } - - // Forward the profile to the main compilation - println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); - // Don't rebuild even if nothing changed - println!("cargo:rerun-if-changed=build.rs"); } fn correct_channel(version_meta: &VersionMeta) -> bool {