Skip to content

Commit

Permalink
Merge pull request #909 from unoplatform/dev/jela/native-adjust
Browse files Browse the repository at this point in the history
Native references adjustements
  • Loading branch information
jeromelaban authored Oct 26, 2024
2 parents 9d59f34 + 5e842b6 commit 61861ee
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
22 changes: 22 additions & 0 deletions doc/features-idbfs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
uid: UnoWasmBootstrap.Features.idbfs
---

# Support for IDBFS

In order to support emulated filesystem using [IDBFS](https://emscripten.org/docs/api_reference/Filesystem-API.html#filesystem-api-idbfs), add the following to your `.csproj`:

```xml
<PropertyGroup>
<WasmShellEnableIDBFS>true</WasmShellEnableIDBFS>
</PropertyGroup>
```

Note that this property is a shortcut to this equivalent configuration:

```xml
<ItemGroup>
<WasmShellExtraEmccFlags Include="-lidbfs.js" />
<WasmShellEmccExportedRuntimeMethod Include="IDBFS" />
</ItemGroup>
```
2 changes: 2 additions & 0 deletions doc/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ items:
href: features-threading.md
- name: Deep linking (routing)
href: features-deep-linking.md
- name: IDBFS Support
href: features-idbfs.md
- name: Pre-compression
href: features-pre-compression.md
- name: Embedded mode
Expand Down
6 changes: 6 additions & 0 deletions doc/using-the-bootstrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ By default, the .NET runtime does not load all resource assemblies, but if you w
</PropertyGroup>
```

### IDBFS

In version 8.x and earlier of the bootstrapper, IDBFS support was enabled by default.

Moving the .NET 9, the default interpreter runtime does not enable it by default. Read this documentation in order to [restore IDBFS support](xref:UnoWasmBootstrap.Features.idbfs).

### Interop

- `Module.mono_bind_static_method` is not available anymore, you'll need to use `Module.getAssemblyExports` instead.
Expand Down
14 changes: 14 additions & 0 deletions src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
BeforeTargets="ResolveStaticWebAssetsConfiguration">

<ItemGroup>
<!-- IDBFS support -->
<WasmShellExtraEmccFlags Condition=" '$(WasmShellEnableIDBFS)' == 'true' " Include="-lidbfs.js" />
<WasmShellEmccExportedRuntimeMethod Condition=" '$(WasmShellEnableIDBFS)' == 'true' " Include="IDBFS" />

<!-- PInvoke compat -->
<_WasmPInvokeModules Include="__Native" />
<_WasmPInvokeModules Include="__Internal" />
Expand Down Expand Up @@ -316,6 +320,16 @@
<WasmAotProfilePath>$([System.IO.Path]::GetFullPath($(_FilteredAotProfile)))</WasmAotProfilePath>
</PropertyGroup>

<PropertyGroup>

<!-- if we found native references, let's enable wasm native build as well -->
<WasmBuildNative Condition="
$(WasmBuildNative) == ''
AND @(NativeFileReference->Count()) > 0"
>true</WasmBuildNative>

</PropertyGroup>

</Target>

<Target Name="GenerateUnoWasmAssets"
Expand Down
7 changes: 4 additions & 3 deletions src/Uno.Wasm.StaticLinking.Shared/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
<WasmShellNativeCompile Include="$(MSBuildThisFileDirectory)test2.cpp" />
</ItemGroup>

<PropertyGroup>
<WasmShellEnableIDBFS>true</WasmShellEnableIDBFS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Web.Services.Description" Version="4.10.0" />
</ItemGroup>
<ItemGroup>
<WasmShellEmccExportedRuntimeMethod Include="GL" />
<WasmShellEmccExportedRuntimeMethod Include="IDBFS" />
<WasmShellEmccExportedRuntimeMethod Include="FS" />

<!-- Based on https://github.com/dotnet/runtime/issues/76077#issuecomment-1260231545 -->
<WasmShellExtraEmccFlags Include="-s LEGACY_GL_EMULATION=1" />
<WasmShellExtraEmccFlags Include="-s USE_CLOSURE_COMPILER=1" />

<WasmShellExtraEmccFlags Include="-lidbfs.js" />
</ItemGroup>

<ItemGroup Condition="'$(UseAOT)'=='true'">
Expand Down

0 comments on commit 61861ee

Please sign in to comment.