Skip to content

Commit 1d0327f

Browse files
committed
Report emcc version failure when binary is not found
1 parent 45e3f61 commit 1d0327f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

build.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,27 @@ fn which_freebsd() -> Option<i32> {
235235
}
236236

237237
fn emcc_version_code() -> Option<u64> {
238-
let output = if cfg!(target_os = "windows") {
239-
std::process::Command::new("emcc.bat")
240-
.arg("-dumpversion")
241-
.output()
242-
.ok()
238+
let emcc = if cfg!(target_os = "windows") {
239+
"emcc.bat"
243240
} else {
244-
std::process::Command::new("emcc")
245-
.arg("-dumpversion")
246-
.output()
247-
.ok()
248-
}?;
241+
"emcc"
242+
};
249243

250-
if !output.status.success() {
251-
return None;
244+
let output = Command::new(emcc).arg("-dumpversion").output().ok();
245+
246+
// If we're targeting emscripten, we need to make sure the executable is checked for the right version
247+
let is_targeting_emscripten =
248+
env::var("CARGO_CFG_TARGET_OS").map_or(false, |os| os == "emscripten");
249+
if output.is_none() {
250+
if is_targeting_emscripten {
251+
panic!("Failed to query emcc for version, make sure emcc is installed");
252+
} else {
253+
return None;
254+
}
252255
}
253256

257+
let output = output.unwrap();
258+
254259
let version = String::from_utf8(output.stdout).ok()?;
255260

256261
// Some Emscripten versions come with `-git` attached, so split the

0 commit comments

Comments
 (0)