Skip to content

Commit

Permalink
Simplify emcc_version using -dumpversion flag (#2465)
Browse files Browse the repository at this point in the history
This only returns the version number and no other information.
  • Loading branch information
hoodmane authored Feb 5, 2025
1 parent a9b3831 commit 2861bf1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,19 +1229,13 @@ fn emscripten_version() -> Result<String> {
}

fn emcc_version() -> Result<String> {
use regex::bytes::Regex;
use std::process::Command;

let emcc = Command::new("emcc")
.arg("--version")
.arg("-dumpversion")
.output()
.context("Failed to run emcc to get the version")?;
let pattern = Regex::new(r"^emcc .+? (\d+\.\d+\.\d+).*").unwrap();
let caps = pattern
.captures(&emcc.stdout)
.context("Failed to parse emcc version")?;
let version = caps.get(1).context("Failed to parse emcc version")?;
Ok(String::from_utf8(version.as_bytes().to_vec())?)
Ok(String::from_utf8(emcc.stdout)?.trim().into())
}

#[cfg(test)]
Expand Down

0 comments on commit 2861bf1

Please sign in to comment.