Skip to content

Commit

Permalink
[wasm] Allow to build browser in library mode (#106388)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhamoyan authored Oct 3, 2024
1 parent a38ab4c commit 2358c59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 2358c59

Please sign in to comment.