Skip to content

Commit

Permalink
Auto merge of #3498 - kleisauke:emscripten-git-compat, r=JohnTitor
Browse files Browse the repository at this point in the history
Improve the version parser of Emscripten

Some Emscripten versions come with `-git` attached, so trim any non-numeric chars from the end of the string.

See: rust-lang/rust#119250.
  • Loading branch information
bors committed Dec 29, 2023
2 parents 6a203e9 + 538911e commit d8f8f57
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion build.rs
Expand Up @@ -274,7 +274,12 @@ fn emcc_version_code() -> Option<u64> {
return None;
}
let version = stdout.unwrap();
let mut pieces = version.trim().split('.');

// Some Emscripten versions come with `-git` attached, so trim any
// non-numeric chars from the end of the string.
let mut pieces = version
.trim_end_matches(|c: char| !c.is_ascii_digit())
.split('.');

let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
Expand Down

0 comments on commit d8f8f57

Please sign in to comment.