Skip to content

Commit 40f8a8d

Browse files
authored
Backport: surface error when emcc -version failed. (#103967)
1 parent fe9a7b2 commit 40f8a8d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/mono/wasm/build/WasmApp.Native.targets

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,24 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_
426426
<Error Condition="'$(RuntimeEmccVersionRaw)' == ''"
427427
Text="%24(RuntimeEmccVersionRaw) is not set. '$(_EmccPropsPath)' should have set that."/>
428428

429-
<Exec Command="emcc --version" WorkingDirectory="$(_WasmIntermediateOutputPath)" EnvironmentVariables="@(EmscriptenEnvVars)" ConsoleToMsBuild="true" StandardOutputImportance="Low">
429+
<PropertyGroup>
430+
<_EmccVersionCommand>emcc --version</_EmccVersionCommand>
431+
</PropertyGroup>
432+
433+
<Exec Command="$(_EmccVersionCommand)" WorkingDirectory="$(_WasmIntermediateOutputPath)" EnvironmentVariables="@(EmscriptenEnvVars)" ConsoleToMsBuild="true" StandardOutputImportance="Low" IgnoreExitCode="true">
430434
<Output TaskParameter="ConsoleOutput" ItemName="_VersionLines" />
435+
<Output TaskParameter="ExitCode" PropertyName="_EmccVersionExitCode" />
431436
</Exec>
432437

438+
<!-- If `emcc -version` failed, then run it again, so we can surface the output as *Errors*. This allows the errors to show up correctly,
439+
versus trying to use the output lines with the Error task -->
440+
<Exec Condition="$(_EmccVersionExitCode) != '0'"
441+
Command="$(_EmccVersionCommand)"
442+
WorkingDirectory="$(_WasmIntermediateOutputPath)"
443+
EnvironmentVariables="@(EmscriptenEnvVars)"
444+
CustomErrorRegularExpression=".*"
445+
/>
446+
433447
<!-- we want to get the first line from the output, which has the version.
434448
Rest of the lines are the license -->
435449
<ItemGroup>

0 commit comments

Comments
 (0)