Closed danipen closed 1 year ago
Some progress. I was able to have a working POC:
I basically compiled oniguruma using emcc:
autoreconf -vfi
emconfigure ./configure
emmake make
and included the native references into the WebAssembly project as NativeFileReference
.
<ItemGroup>
<NativeFileReference Include="libonig.a" />
<NativeFileReference Include="onigwrap.c" />
</ItemGroup>
However, I have no idea about how to generate a nuget for TextmateSharp supporting wasm.
Issues:
However, I have no idea about how to generate a nuget for TextmateSharp supporting wasm.
I'm a total beginner with web assembly so I can't speak from experience, but there are a few docs at https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-native-dependencies?view=aspnetcore-6.0#package-native-dependencies-in-a-nuget-package about how it might be done, and I've seen mention elsewhere of using the 'browser-wasm' identifier to include the binaries in a nuget package.
From the links on tha MS article, there is a 'SkiaSharp.NativeAssets.WebAssembly' package that contains the Wasm build of Skia, and a 'SkiaSharp.Views.Blazor' which contains MSBuild files which add the 'NativeFileReference' entries for the .a files, which might be an example of how the properties can be set up?
Yes, I tried this here, with no luck. Not sure if here I need to add the .wasm
or the .a
file in the nuget.
.wasm
file as a reference, I'm not sure about how to generate it..a
, I'm not sure how I can later explicitly tell it's a native reference to the wasm project.There's a note in that MS documentation that says
Prebuilt dependencies typically must be built using the same version of Emscripten used to build the .NET WebAssembly runtime.
So I don't know if distributing the .wasm file is safe there?
For (2), Can you put a TextMateSharp.props file inside the 'build' directory in the nuget package which contains the NativeFileReference
item? e.g. in The SkiaSharp/Blazor package it has:
(However, I'm not sure what the conditions and such should be to control when it's included)
So it seems I need to ship these two files in the nuget...
libonig.a
onigwrap.c
I only need to ship them for browser-wasm
platform ...and I need to include as NativeFileReference
for the project being built.
Honestly...im not sure about the syntax to do that docs are not very verbose.
@Numpsy good news! I got it working here! https://github.com/danipen/TextMateSharp/pull/36
I'll discard this PR.
For the threading issue, it seems that is going to be supported in .net 7 via WasmEnableThreads ...
<PropertyGroup>
<WasmEnableThreads>true</WasmEnableThreads>
</PropertyGroup>
Fixes #9