Skip to content

Commit be7e554

Browse files
authored
Merge pull request #2753 from phansch/fix_build_script_for_dev_channel
Fix build script for dev channel
2 parents 29a900d + 364f42d commit be7e554

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

build.rs

Lines changed: 15 additions & 5 deletions
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,6 +40,12 @@ 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");
@@ -69,11 +84,6 @@ fn main() {
6984
print_version_err(&current_version, &*current_date_str);
7085
panic!("Aborting compilation due to incompatible compiler.")
7186
}
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");
7787
}
7888

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

0 commit comments

Comments
 (0)