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
3 changes: 2 additions & 1 deletion src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,12 @@ private void EmitNativeToInterp(StreamWriter w, List<PInvokeCallback> callbacks)
sb.Append(") { \n");
if (!is_void)
sb.Append($" {MapType(method.ReturnType)} res;\n");

#if TARGET_WASI
mkhamoyan marked this conversation as resolved.
Show resolved Hide resolved
if (_isLibraryMode && HasAttribute(method, "System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute"))
{
sb.Append($" initialize_runtime(); \n");
}
#endif

// In case when null force interpreter to initialize the pointers
sb.Append($" if (!(WasmInterpEntrySig_{cb_index})wasm_native_to_interp_ftndescs [{cb_index}].func) {{\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>

<Delete Files="@(_LinkedResolvedFileToPublishCandidate)" />
<ItemGroup>
<TrimmerRootAssembly Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And '%(Identity)' == '@(IntermediateAssembly)' And '$(OutputType)' == 'Library'">
<RootMode>all</RootMode>
</TrimmerRootAssembly>
</ItemGroup>
mkhamoyan marked this conversation as resolved.
Show resolved Hide resolved
<ILLink AssemblyPaths="@(ManagedAssemblyToLink)"
ReferenceAssemblyPaths="@(ReferencePath)"
RootAssemblyNames="@(TrimmerRootAssembly)"
Expand Down
Loading