Skip to content

Commit 2358c59

Browse files
authored
[wasm] Allow to build browser in library mode (#106388)
1 parent a38ab4c commit 2358c59

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/mono/browser/build/BrowserWasmApp.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@
6363
<ProjectCapability Include="DotNetCoreWeb"/>
6464
</ItemGroup>
6565

66+
<!-- When trimming non-exe projects, root the whole intermediate assembly. -->
67+
<Target Name="_RootEntireIntermediateAssembly" AfterTargets="PrepareForILLink" BeforeTargets="_RunILLink" Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And '$(OutputType)' == 'Library'">
68+
<ItemGroup>
69+
<TrimmerRootAssembly Condition="'%(Identity)' == '@(IntermediateAssembly)'">
70+
<RootMode>all</RootMode>
71+
</TrimmerRootAssembly>
72+
</ItemGroup>
73+
</Target>
74+
6675
<Target Name="_GetWasmGenerateAppBundleDependencies">
6776
<Warning Condition="'$(InvariantGlobalization)' == 'true' and '$(HybridGlobalization)' == 'true'" Text="%24(HybridGlobalization) has no effect when %24(InvariantGlobalization) is set to true." />
6877
<Warning Condition="'$(WasmIcuDataFileName)' != '' and '$(HybridGlobalization)' == 'true'" Text="%24(WasmIcuDataFileName) has no effect when %24(HybridGlobalization) is set to true." />

src/mono/browser/runtime/driver.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,12 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
180180
free (user_data);
181181
}
182182

183+
static int runtime_initialized = 0;
184+
183185
EMSCRIPTEN_KEEPALIVE void
184186
mono_wasm_load_runtime (int debug_level)
185187
{
188+
runtime_initialized = 1;
186189
const char *interp_opts = "";
187190

188191
#ifndef INVARIANT_GLOBALIZATION
@@ -227,6 +230,15 @@ mono_wasm_load_runtime (int debug_level)
227230
bindings_initialize_internals();
228231
}
229232

233+
int initialize_runtime()
234+
{
235+
if (runtime_initialized == 1)
236+
return 0;
237+
mono_wasm_load_runtime (0);
238+
239+
return 0;
240+
}
241+
230242
EMSCRIPTEN_KEEPALIVE void
231243
mono_wasm_invoke_jsexport (MonoMethod *method, void* args)
232244
{

0 commit comments

Comments
 (0)