Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Allow to build browser in library mode #106388

Merged
merged 13 commits into from
Oct 3, 2024
9 changes: 9 additions & 0 deletions src/mono/browser/build/BrowserWasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
<ProjectCapability Include="DotNetCoreWeb"/>
</ItemGroup>

<!-- When trimming non-exe projects, root the whole intermediate assembly. -->
<Target Name="_RootEntireIntermediateAssembly" AfterTargets="PrepareForILLink" BeforeTargets="_RunILLink" Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And '$(OutputType)' == 'Library'">
<ItemGroup>
<TrimmerRootAssembly Condition="'%(Identity)' == '@(IntermediateAssembly)'">
<RootMode>all</RootMode>
</TrimmerRootAssembly>
</ItemGroup>
</Target>

<Target Name="_GetWasmGenerateAppBundleDependencies">
<Warning Condition="'$(InvariantGlobalization)' == 'true' and '$(HybridGlobalization)' == 'true'" Text="%24(HybridGlobalization) has no effect when %24(InvariantGlobalization) is set to true." />
<Warning Condition="'$(WasmIcuDataFileName)' != '' and '$(HybridGlobalization)' == 'true'" Text="%24(WasmIcuDataFileName) has no effect when %24(HybridGlobalization) is set to true." />
Expand Down
12 changes: 12 additions & 0 deletions src/mono/browser/runtime/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
free (user_data);
}

static int runtime_initialized = 0;

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (int debug_level)
{
runtime_initialized = 1;
const char *interp_opts = "";

#ifndef INVARIANT_GLOBALIZATION
Expand Down Expand Up @@ -227,6 +230,15 @@ mono_wasm_load_runtime (int debug_level)
bindings_initialize_internals();
}

int initialize_runtime()
{
if (runtime_initialized == 1)
return 0;
mono_wasm_load_runtime (0);

return 0;
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_invoke_jsexport (MonoMethod *method, void* args)
{
Expand Down
Loading