Skip to content
Permalink
Browse files

build.rs: fix with rustc not built from Git

I couldn't build hyperx because my rustc (from Nixpkgs) has a version
output looks like this:

    rustc 1.34.2

There's no Git information in parentheses after the version. I assume
that this is because it was not built from a Git checkout.

To fix this, I made it so that if no space occurs after the "rustc "
prefix, the whole remaining string is used as the version.
  • Loading branch information
alyssais authored and dekellum committed Jun 1, 2019
1 parent fe2bdd1 commit b764a2f770f3781fb00995cb6de235e7ec1c0a1f
Showing with 10 additions and 10 deletions.
  1. +10 −10 build.rs
@@ -37,17 +37,17 @@ fn rustc_version() -> Vec<u16> {
let out = String::from_utf8(out.stdout).unwrap();
for l in out.lines() {
if l.starts_with("rustc ") {
let v = &l[6..];
let mut v = &l[6..];
if let Some(e) = v.find(" ") {
let v = &v[..e];
let mut vp = v.split("-");
if let Some(v) = vp.next() {
let vs: Vec<u16> = v.split(".")
.filter_map(|vss| vss.parse().ok())
.collect();
if !vs.is_empty() {
return vs;
}
v = &v[..e];
}
let mut vp = v.split("-");
if let Some(v) = vp.next() {
let vs: Vec<u16> = v.split(".")
.filter_map(|vss| vss.parse().ok())
.collect();
if !vs.is_empty() {
return vs;
}
}
}

0 comments on commit b764a2f

Please sign in to comment.
You can’t perform that action at this time.