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 split the
version string also on the `-` char.

See: rust-lang/rust#119250.
  • Loading branch information
kleisauke committed Dec 29, 2023
1 parent 9899913 commit c424592
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.rs
Expand Up @@ -274,7 +274,10 @@ 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 split the
// version string also on the `-` char.
let mut pieces = version.trim().split(|c| c == '.' || c == '-');

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 c424592

Please sign in to comment.