Skip to content

Commit

Permalink
refactor: Add emscripten_verison function
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Feb 17, 2023
1 parent aa1c910 commit d4726f2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,7 @@ impl Target {
}
// Emscripten
(Os::Emscripten, Arch::Wasm32) => {
let os_version = env::var("MATURIN_EMSCRIPTEN_VERSION");
let release = match os_version {
Ok(os_ver) => os_ver,
Err(_) => emcc_version()?,
};
let release = release.replace(['.', '-'], "_");
let release = emscripten_version()?.replace(['.', '-'], "_");
format!("emscripten_{release}_wasm32")
}
(Os::Wasi, Arch::Wasm32) => {
Expand Down Expand Up @@ -783,6 +778,16 @@ pub(crate) fn rustc_macosx_target_version(target: &str) -> (u16, u16) {
rustc_target_version().unwrap_or(fallback_version)
}

/// Emscripten version
fn emscripten_version() -> Result<String> {
let os_version = env::var("MATURIN_EMSCRIPTEN_VERSION");
let release = match os_version {
Ok(os_ver) => os_ver,
Err(_) => emcc_version()?,
};
Ok(release)
}

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

0 comments on commit d4726f2

Please sign in to comment.