summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-11-20 13:08:27 -0500
committerAaron Hill <aa1ronham@gmail.com>2019-11-20 13:08:27 -0500
commitf10ee11f7043cb38fff02d9085b26009f2fc66aa (patch)
tree41e5c13d689629f7210cacbfdc507f1c78884355 /build.rs
parentbd48043eecd82318bb6f1f922fc25d1cfaa4d741 (diff)
downloadrust-libc-f10ee11f7043cb38fff02d9085b26009f2fc66aa.tar.gz
Fix build.rs failing with a rustc built from a tarball
Fixes #1601
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/build.rs b/build.rs
index 420e159651..f447c0ef9c 100644
--- a/build.rs
+++ b/build.rs
@@ -103,9 +103,16 @@ fn rustc_minor_nightly() -> Option<(u32, bool)> {
}
let minor = pieces.next();
- let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1));
- let nightly =
- nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly");
+
+ // If `rustc` was built from a tarball, its version string
+ // will have neither a git hash nor a commit date
+ // (e.g. "rustc 1.39.0"). Treat this case as non-nightly,
+ // since a nightly build should either come from CI
+ // or a git checkout
+ let nightly_raw = otry!(pieces.next()).split('-').nth(1);
+ let nightly = nightly_raw
+ .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly"))
+ .unwrap_or(false);
let minor = otry!(otry!(minor).parse().ok());
Some((minor, nightly))