diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a9e3096..4f169ad 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,8 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- with:
- submodules: 'true'
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
@@ -25,7 +23,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Prepare WASM SDKs
- run: dotnet msbuild src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets /t:PrepareWasmSdks
+ run: dotnet msbuild src/WitBindgen/build/WitBindgen.targets /t:PrepareWasmSdks
- name: Build
run: dotnet build --no-restore /p:BuildNumber=${{ github.run_number }}
- name: Test
diff --git a/.gitmodules b/.gitmodules
index 482af39..9b0a752 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
[submodule "modules/wit-bindgen"]
path = modules/wit-bindgen
- url = https://github.com/jsturtevant/wit-bindgen.git
+ url = https://github.com/bytecodealliance/wit-bindgen.git
[submodule "modules/wasm-tools"]
path = modules/wasm-tools
- url = https://github.com/dicej/wasm-tools.git
+ url = https://github.com/bytecodealliance/wasm-tools.git
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2337951..42e78a7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,18 +3,16 @@ Open an issue detailing the issue you've encountered or feature you would like t
Bug fixes and new features must be submitted using a pull request and pass CI to be included in the project.
-## Building the project locally
+## Building
Requires [.NET 8+](https://dotnet.microsoft.com/en-us/download)
```
-dotnet msbuild src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets /t:PrepareWasmSdks
-git submodule update --init
+## needed to avoid errors with multiple projects calling and downloading the sdks at same time (https://github.com/bytecodealliance/componentize-dotnet/issues/8)
+dotnet msbuild src/WitBindgen/build/WitBindgen.targets /t:PrepareWasmSdks
dotnet build
```
-If you are experiencing issues with values not being updated, try running `dotnet clean` and using the steps above
-
## Testing
Run the tests:
@@ -23,5 +21,59 @@ Run the tests:
dotnet test
```
+> tip: If you've already built the project you can speed up the tests by running `dotnet test --no-build`
+
+## Build Wasm tools locally
+
+> requires [rust](https://www.rust-lang.org/tools/install)
+
+The project is configured by default to pull tools such as [wit-bindgen](https://github.com/bytecodealliance/wit-bindgen) from their releases. It is possible to use custom builds of these tools via submodules:
+
+```
+## get submodules
+git submodule update --int
+
+## get latest code from configured branch
+git submodule update --recursive --remote
+
+## optional, change the branch for the project
+cd modules/
+git checkout
+```
+
+Modify the [WasmComponentSdk.csproj](./src/WasmComponent.Sdk/WasmComponent.Sdk.csproj) to enable building from source:
+
+```
+true
+```
+
+Modify the [WitBindgen.csproj](./src/WitBindgen/WitBindgen.csproj) to enable building from source:
+
+```
+true
+```
+
+And then follow the [project build steps](#building).
+
+### Debugging
+
+Create a msbuild debug log:
+
+```
+dotnet build /bl
+```
+
+View the log with https://www.msbuildlog.com/.
+
+Learn more at [trouble shooting techniques](https://learn.microsoft.com/en-us/visualstudio/ide/msbuild-logs?view=vs-2022) for msbuild.
+
## Getting help
-While we work on improving the documentation for contributing, if you have any questions please drop a note in the [c# zulip chat](https://bytecodealliance.zulipchat.com/#narrow/stream/407028-C.23.2F.2Enet-collaboration).
\ No newline at end of file
+
+> If you have any questions please drop a note in the [c# zulip chat](https://bytecodealliance.zulipchat.com/#narrow/stream/407028-C.23.2F.2Enet-collaboration).
+
+This project uses MSbuild and .NET Project SDKS. Learn more about this tooling in:
+
+- [MSbuild docs](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild?view=vs-2022)
+- [.NET Project SDKS](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview)
+- [Creating Reliable Builds](https://learn.microsoft.com/en-us/archive/msdn-magazine/2009/february/msbuild-best-practices-for-creating-reliable-builds-part-1#id0090093)
+
diff --git a/modules/wasm-tools b/modules/wasm-tools
index bf7cdb2..ebfcffd 160000
--- a/modules/wasm-tools
+++ b/modules/wasm-tools
@@ -1 +1 @@
-Subproject commit bf7cdb29ea67f21b6a82790acfb447082f6bafbf
+Subproject commit ebfcffd2f8ac71dcbd3eb43edf8a91984b03f6f3
diff --git a/modules/wit-bindgen b/modules/wit-bindgen
index a16ee4a..2645c4f 160000
--- a/modules/wit-bindgen
+++ b/modules/wit-bindgen
@@ -1 +1 @@
-Subproject commit a16ee4a081cdd65d91cfc781e13e482cc5e84c22
+Subproject commit 2645c4f7ddefa0844a91b214267b1674e45d4884
diff --git a/samples/calculator/Adder/OperationsImpl.cs b/samples/calculator/Adder/OperationsImpl.cs
index 93d45f5..0f6bb96 100644
--- a/samples/calculator/Adder/OperationsImpl.cs
+++ b/samples/calculator/Adder/OperationsImpl.cs
@@ -1,6 +1,6 @@
-namespace wit_computer.Wit.exports.example.calculator.Operations;
+namespace ComputerWorld.wit.exports.example.calculator;
-public class OperationsImpl : Operations
+public class OperationsImpl : IOperations
{
public static int Add(int left, int right)
{
diff --git a/samples/calculator/CalculatorComposed/CalculatorComposed.csproj b/samples/calculator/CalculatorComposed/CalculatorComposed.csproj
index 66e9367..6ecf788 100644
--- a/samples/calculator/CalculatorComposed/CalculatorComposed.csproj
+++ b/samples/calculator/CalculatorComposed/CalculatorComposed.csproj
@@ -17,8 +17,8 @@
- ../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/CalculatorHost.component.wasm
- ../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/Adder.component.wasm
+ ../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/calculatorhost-component.wasm
+ ../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/adder-component.wasm
diff --git a/samples/calculator/CalculatorHost/Program.cs b/samples/calculator/CalculatorHost/Program.cs
index 3d99ad5..9c5a12f 100644
--- a/samples/calculator/CalculatorHost/Program.cs
+++ b/samples/calculator/CalculatorHost/Program.cs
@@ -1,4 +1,4 @@
-using wit_hostapp.Wit.imports.example.calculator.Operations;
+using HostappWorld.wit.imports.example.calculator;
var left = 123;
var right = 456;
diff --git a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj
index 6d01628..ff1c896 100644
--- a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj
+++ b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj
@@ -9,10 +9,10 @@
- true
- 1.0.51
- https://github.com/bytecodealliance/wasm-tools/releases/download/wasm-tools-$(PrebuiltWasmToolsVersion)/wasm-tools-$(PrebuiltWasmToolsVersion)
- 14.0.4
+ false
+ 1.209.1
+ https://github.com/bytecodealliance/wasm-tools/releases/download/v$(PrebuiltWasmToolsVersion)/wasm-tools-$(PrebuiltWasmToolsVersion)
+ 21.0.1
$(MSBuildThisFileDirectory)..\..\modules\wasm-tools\
@@ -68,13 +68,10 @@
-
+
-
-
-
-
+
diff --git a/src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets b/src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets
index 1b42574..732d1b6 100644
--- a/src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets
+++ b/src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets
@@ -1,24 +1,4 @@
-
-
-
-
- 20.0
- https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz
- https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz
- https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz
- $([System.IO.Path]::Combine("$([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))", ".wasi-sdk", "wasi-sdk-$(WasiSdkVersion)"))
-
- 3.1.23
- https://github.com/emscripten-core/emsdk/archive/refs/tags/$(EmSdkVersion).zip
-
- $([System.IO.Path]::Combine("$([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))", ".emsdk", "emsdk-$(EmSdkVersion)"))
- $(EMSDK)
-
-
@@ -33,66 +13,11 @@
reactor
command
$(MSBuildThisFileDirectory)../tools/wasi-wasm/wasi_snapshot_preview1.$(WasiPreview1AdapterType).wasm
- $(NativeOutputPath)$(TargetName).component.wasm
-
-
-
-
-
- $(EmscriptenRoot)
- $(WasiSdkRoot)
-
-
-
-
-
-
-
- $([System.IO.Path]::Combine($([System.IO.Path]::GetTempPath()), $([System.IO.Path]::GetRandomFileName())))
+
+ $(NativeOutputPath)$(TargetName.ToLower())-component.wasm
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $([System.IO.Path]::Combine($([System.IO.Path]::GetTempPath()), $([System.IO.Path]::GetRandomFileName())))
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/WitBindgen/WitBindgen.csproj b/src/WitBindgen/WitBindgen.csproj
index 52858e5..9ea6483 100644
--- a/src/WitBindgen/WitBindgen.csproj
+++ b/src/WitBindgen/WitBindgen.csproj
@@ -9,12 +9,14 @@
- true
- 0.14.0
- https://github.com/bytecodealliance/wit-bindgen/releases/download/wit-bindgen-cli-$(PrebuiltWitBindgenVersion)/wit-bindgen-v$(PrebuiltWitBindgenVersion)
-
+ false
+ 0.26.0
+ https://github.com/bytecodealliance/wit-bindgen/releases/download/v$(PrebuiltWitBindgenVersion)/wit-bindgen-$(PrebuiltWitBindgenVersion)
$(MSBuildThisFileDirectory)..\..\modules\wit-bindgen\
+
+ $(MSBuildThisFileDirectory)tools\version-$(PrebuiltWitBindgenVersion)
+
true
false
@@ -50,8 +52,10 @@
-
+
+
+
diff --git a/src/WitBindgen/build/WitBindgen.targets b/src/WitBindgen/build/WitBindgen.targets
index ef9604a..29d9d05 100644
--- a/src/WitBindgen/build/WitBindgen.targets
+++ b/src/WitBindgen/build/WitBindgen.targets
@@ -1,7 +1,91 @@
+
+ native-aot
+
+
+ 20.0
+ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz
+ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz
+ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz
+ $([System.IO.Path]::Combine("$([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))", ".wasi-sdk", "wasi-sdk-$(WasiSdkVersion)"))
+
+ 3.1.61
+ https://github.com/emscripten-core/emsdk/archive/refs/tags/$(EmSdkVersion).zip
+
+ $([System.IO.Path]::Combine("$([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))", ".emsdk", "emsdk-$(EmSdkVersion)"))
+ $(EMSDK)
+
+
+
+
+
+ $(EmscriptenRoot)
+ $(EmscriptenRoot)\upstream\emscripten\emcc.bat
+ $(WasiSdkRoot)
+
+
+
+
+
+
+
+ $([System.IO.Path]::Combine($([System.IO.Path]::GetTempPath()), $([System.IO.Path]::GetRandomFileName())))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $([System.IO.Path]::Combine($([System.IO.Path]::GetTempPath()), $([System.IO.Path]::GetRandomFileName())))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DependsOnTargets="PrepareWasmSdks; WitCompile_GetDependencies; WitCompile_InvokeTool">
@@ -29,8 +113,15 @@
-
+
+
+
+
+
+
+
+
diff --git a/test/E2ETest/PackageTest/PackageTest.csproj b/test/E2ETest/PackageTest/PackageTest.csproj
index 32bbca3..35813e5 100644
--- a/test/E2ETest/PackageTest/PackageTest.csproj
+++ b/test/E2ETest/PackageTest/PackageTest.csproj
@@ -30,18 +30,21 @@
+
-
-
+
+
+
-
+
+
+
-
diff --git a/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj b/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
index bb4da0d..46e70a9 100644
--- a/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
+++ b/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
@@ -33,11 +33,11 @@
- ../E2EProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/E2EProducer.component.wasm
+ ../E2EProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/e2eproducer-component.wasm
-
+
diff --git a/test/E2ETest/testapps/E2EConsumer/Program.cs b/test/E2ETest/testapps/E2EConsumer/Program.cs
index 31bf273..db95c0d 100644
--- a/test/E2ETest/testapps/E2EConsumer/Program.cs
+++ b/test/E2ETest/testapps/E2EConsumer/Program.cs
@@ -1,5 +1,5 @@
using System.Runtime.InteropServices;
-using wit_consumer.Wit.imports.test.producerConsumer.Operations;
+using ConsumerWorld.wit.imports.test.producerConsumer;
Console.WriteLine($"Hello, world on {RuntimeInformation.OSArchitecture}");
diff --git a/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj b/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj
index 2655942..f9cd312 100644
--- a/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj
+++ b/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj
@@ -6,7 +6,7 @@
net8.0
enable
enable
- false
+ false
true
wasi-wasm
diff --git a/test/E2ETest/testapps/E2EProducer/OperationsImpl.cs b/test/E2ETest/testapps/E2EProducer/OperationsImpl.cs
index 8fd4dd5..2b65805 100644
--- a/test/E2ETest/testapps/E2EProducer/OperationsImpl.cs
+++ b/test/E2ETest/testapps/E2EProducer/OperationsImpl.cs
@@ -1,6 +1,6 @@
-namespace wit_producer.Wit.exports.test.producerConsumer.Operations;
+namespace ProducerWorld.wit.exports.test.producerConsumer;
-public class OperationsImpl : Operations
+public class OperationsImpl : IOperations
{
public static int Add(int left, int right)
{
diff --git a/test/WasmComponentSdkTest/WasmComponentSdkTest/SimpleProducerConsumerTest.cs b/test/WasmComponentSdkTest/WasmComponentSdkTest/SimpleProducerConsumerTest.cs
index 43b9f85..fecdd40 100644
--- a/test/WasmComponentSdkTest/WasmComponentSdkTest/SimpleProducerConsumerTest.cs
+++ b/test/WasmComponentSdkTest/WasmComponentSdkTest/SimpleProducerConsumerTest.cs
@@ -19,14 +19,14 @@ public class SimpleProducerConsumerTest
[Fact]
public void CanBuildComponentWithImport()
{
- var witInfo = GetWitInfo(FindModulePath($"../testapps/SimpleConsumer/bin/{Config}", "SimpleConsumer.component.wasm"));
+ var witInfo = GetWitInfo(FindModulePath($"../testapps/SimpleConsumer/bin/{Config}", "simpleconsumer-component.wasm"));
Assert.Contains("import test:producer-consumer/operations", witInfo);
}
[Fact]
public void CanBuildComponentWithExport()
{
- var witInfo = GetWitInfo(FindModulePath($"../testapps/SimpleProducer/bin/{Config}", "SimpleProducer.component.wasm"));
+ var witInfo = GetWitInfo(FindModulePath($"../testapps/SimpleProducer/bin/{Config}", "simpleproducer-component.wasm"));
Assert.Contains("export test:producer-consumer/operations", witInfo);
}
diff --git a/test/WasmComponentSdkTest/testapps/SimpleConsumer/Program.cs b/test/WasmComponentSdkTest/testapps/SimpleConsumer/Program.cs
index 31bf273..db95c0d 100644
--- a/test/WasmComponentSdkTest/testapps/SimpleConsumer/Program.cs
+++ b/test/WasmComponentSdkTest/testapps/SimpleConsumer/Program.cs
@@ -1,5 +1,5 @@
using System.Runtime.InteropServices;
-using wit_consumer.Wit.imports.test.producerConsumer.Operations;
+using ConsumerWorld.wit.imports.test.producerConsumer;
Console.WriteLine($"Hello, world on {RuntimeInformation.OSArchitecture}");
diff --git a/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj b/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj
index e50f00d..dee9ac3 100644
--- a/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj
+++ b/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj
@@ -31,7 +31,7 @@
- ../SimpleProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/SimpleProducer.component.wasm
+ ../SimpleProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/simpleproducer-component.wasm
diff --git a/test/WasmComponentSdkTest/testapps/SimpleProducer/OperationsImpl.cs b/test/WasmComponentSdkTest/testapps/SimpleProducer/OperationsImpl.cs
index 8fd4dd5..2b65805 100644
--- a/test/WasmComponentSdkTest/testapps/SimpleProducer/OperationsImpl.cs
+++ b/test/WasmComponentSdkTest/testapps/SimpleProducer/OperationsImpl.cs
@@ -1,6 +1,6 @@
-namespace wit_producer.Wit.exports.test.producerConsumer.Operations;
+namespace ProducerWorld.wit.exports.test.producerConsumer;
-public class OperationsImpl : Operations
+public class OperationsImpl : IOperations
{
public static int Add(int left, int right)
{
diff --git a/test/WasmtimeCliFetcher/FetchWasmtime.targets b/test/WasmtimeCliFetcher/FetchWasmtime.targets
index c0c2696..5a4dd36 100644
--- a/test/WasmtimeCliFetcher/FetchWasmtime.targets
+++ b/test/WasmtimeCliFetcher/FetchWasmtime.targets
@@ -1,6 +1,6 @@
- 14.0.4
+ 21.0.1
mingw
linux
@@ -10,15 +10,21 @@
$(MSBuildThisFileDirectory)tools\wasmtime
$(WasmtimeExe).exe
+
+
+ $(MSBuildThisFileDirectory)tools\version-$(WasmtimeVersion)
.tar.gz
.zip
https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-$(WasmtimeTarget)$(WasmtimeUrlExtension)
-
-
-
+
+
+
+
+
+
diff --git a/test/WitBindgenTest/WitBindgenTest/CodeGenerationTest.cs b/test/WitBindgenTest/WitBindgenTest/CodeGenerationTest.cs
index c36aff4..b449260 100644
--- a/test/WitBindgenTest/WitBindgenTest/CodeGenerationTest.cs
+++ b/test/WitBindgenTest/WitBindgenTest/CodeGenerationTest.cs
@@ -1,5 +1,5 @@
-using wit_my_funcs;
-using wit_producer;
+using MyFuncsWorld;
+using ProducerWorld;
using Xunit;
namespace WitBindgenTest;
@@ -14,7 +14,7 @@ public void GeneratesSimpleImport()
LibraryUsingWit.Code.CallSimpleDoSomething());
// Currently, it generates [DllImport("*", ...)] so validate that
- Assert.StartsWith("Unable to load DLL '*'", ex.Message);
+ Assert.StartsWith("Unable to load DLL", ex.Message);
}
[Fact]
diff --git a/test/WitBindgenTest/testapps/LibraryUsingWit/Code.cs b/test/WitBindgenTest/testapps/LibraryUsingWit/Code.cs
index a7dd70c..add2c31 100644
--- a/test/WitBindgenTest/testapps/LibraryUsingWit/Code.cs
+++ b/test/WitBindgenTest/testapps/LibraryUsingWit/Code.cs
@@ -4,6 +4,7 @@ public class Code
{
public static void CallSimpleDoSomething()
{
- wit_my_funcs.exports.MyFuncsWorld.DoSomething();
+ MyFuncsWorld.exports.MyFuncsWorld.DoSomething();
}
+
}
diff --git a/test/WitBindgenTest/testapps/LibraryUsingWit/MyFuncsWorldImpl.cs b/test/WitBindgenTest/testapps/LibraryUsingWit/MyFuncsWorldImpl.cs
index 07e28d8..6937880 100644
--- a/test/WitBindgenTest/testapps/LibraryUsingWit/MyFuncsWorldImpl.cs
+++ b/test/WitBindgenTest/testapps/LibraryUsingWit/MyFuncsWorldImpl.cs
@@ -1,6 +1,6 @@
-namespace wit_my_funcs;
+using MyFuncsWorld;
-public class MyFuncsWorldImpl : MyFuncsWorld
+public class MyFuncsWorldImpl : IMyFuncsWorld
{
public static int GetNumber()
{
diff --git a/test/WitBindgenTest/testapps/LibraryUsingWit/SomeStuffImpl.cs b/test/WitBindgenTest/testapps/LibraryUsingWit/SomeStuffImpl.cs
index db50b91..bfa1d96 100644
--- a/test/WitBindgenTest/testapps/LibraryUsingWit/SomeStuffImpl.cs
+++ b/test/WitBindgenTest/testapps/LibraryUsingWit/SomeStuffImpl.cs
@@ -1,10 +1,8 @@
// I don't think this namespace should be so different to the one in MyFuncsWorldImpl,
// but currently that's what the codegen requires
-using wit_producer.Wit.exports.test.multipleWorlds.SomeStuff;
+using ProducerWorld.wit.exports.test.multipleWorlds;
-namespace wit_producer;
-
-public class SomeStuffImpl : SomeStuff
+public class SomeStuffImpl : ISomeStuff
{
public static int GetNumber()
{