Skip to content

Commit

Permalink
Improve the version parser of Emscripten
Browse files Browse the repository at this point in the history
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
kleisauke committed Dec 24, 2023
1 parent 9899913 commit 538911e
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 538911e

Please sign in to comment.