Skip to content

Fix build script for dev channel #2753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -69,11 +84,6 @@ fn main() {
print_version_err(&current_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 {
Expand Down