Skip to content

Commit 2580eda

Browse files
committed
Fix build script for dev channel
1 parent 18a5b90 commit 2580eda

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

build.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ use rustc_version::{version_meta, version_meta_for, Channel, Version, VersionMet
2121
use ansi_term::Colour::Red;
2222

2323
fn main() {
24+
check_rustc_version();
25+
26+
// Forward the profile to the main compilation
27+
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
28+
// Don't rebuild even if nothing changed
29+
println!("cargo:rerun-if-changed=build.rs");
30+
}
31+
32+
fn check_rustc_version() {
2433
let string = include_str!("min_version.txt");
2534
let min_version_meta = version_meta_for(string)
2635
.expect("Could not parse version string in min_version.txt");
@@ -31,10 +40,17 @@ fn main() {
3140
let min_date_str = min_version_meta.clone().commit_date
3241
.expect("min_version.txt does not contain a rustc commit date");
3342

43+
// Dev channel (rustc built from git) does not have any date or commit information in rustc -vV
44+
// `current_version_meta.commit_date` would crash, so we return early here.
45+
if current_version_meta.channel == Channel::Dev {
46+
return
47+
}
48+
3449
let current_version = current_version_meta.clone().semver;
3550
let current_date_str = current_version_meta.clone().commit_date
3651
.expect("current rustc version information does not contain a rustc commit date");
3752

53+
3854
let print_version_err = |version: &Version, date: &str| {
3955
eprintln!("> {} {}. {} {}.\n",
4056
"Installed rustc version is:",
@@ -69,11 +85,6 @@ fn main() {
6985
print_version_err(&current_version, &*current_date_str);
7086
panic!("Aborting compilation due to incompatible compiler.")
7187
}
72-
73-
// Forward the profile to the main compilation
74-
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
75-
// Don't rebuild even if nothing changed
76-
println!("cargo:rerun-if-changed=build.rs");
7788
}
7889

7990
fn correct_channel(version_meta: &VersionMeta) -> bool {

0 commit comments

Comments
 (0)