Skip to content

Commit

Permalink
Changes to enable the build on Linux (#40)
Browse files Browse the repository at this point in the history
* build on linux

* remove package mapping

* Add linux to yml, lowercase more component names

* syntax

* name artifacts with os

* name artifacts with os typo

* address some feedback, Bytecode case, prepare for Mac

* add back Bytecode files

* add comment about zip packaging on Linux

* add back packageSourceMapping

* try forward slash
  • Loading branch information
yowl authored Sep 6, 2024
1 parent 8be07d5 commit 81d9da1
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ on:

jobs:
build:
runs-on: windows-latest
name: Build with Dotnet ${{ matrix.dotnet }}
runs-on: ${{ matrix.os }}
name: Build on ${{ matrix.os }} with Dotnet ${{ matrix.dotnet }}
strategy:
matrix:
dotnet: [ '8.x', '9.0.100-preview.4.24267.66']
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup .NET
Expand All @@ -36,7 +37,8 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
name: nuget-packages-${{ matrix.os }}
path: artifacts/*.nupkg
if-no-files-found: error
if: ${{ matrix.dotnet == '8.x' }} # only need one package published https://github.com/actions/upload-artifact?tab=readme-ov-file#not-uploading-to-the-same-artifact

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ obj/
.vs/
artifacts/
test/WasmComponentSdkTest/testapps/OciWit/wit
*.binlog
.DS_Store
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
</PropertyGroup>
<ItemGroup>
<!-- find latest versions at https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-experimental by name of package -->
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24412.1" />
<PackageVersion Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24412.1" />
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24429.1" />
<PackageVersion Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24429.1" />

<!-- Tests -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
Expand Down
3 changes: 3 additions & 0 deletions samples/calculator/Adder/Adder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>

<!-- Need kebab case -->
<TargetName>adder</TargetName>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
<PropertyGroup>
<EntrypointComponent>../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/calculatorhost.wasm</EntrypointComponent>
<EntrypointComponent>../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/CalculatorHost.wasm</EntrypointComponent>
<DependencyComponent>../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/adder.wasm</DependencyComponent>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/WasmComponent.Sdk/ImportInDev.proj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" />
</ItemGroup>
</Project>
6 changes: 4 additions & 2 deletions src/WasmComponent.Sdk/WasmComponent.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" PrivateAssets="None" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" PrivateAssets="None" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" PrivateAssets="None" />
<ProjectReference Include="..\WitBindgen\WitBindgen.csproj" PrivateAssets="None" />
</ItemGroup>

Expand Down Expand Up @@ -67,7 +67,9 @@
<PrebuiltWasmToolsTarget Include="aarch64-macos" Rid="osx-arm64" Ext=".tar.gz" />
<PrebuiltWasmToolsTarget Include="x86_64-linux" Rid="linux-x64" Ext=".tar.gz" />
<PrebuiltWasmToolsTarget Include="x86_64-macos" Rid="osx-x64" Ext=".tar.gz" />
<PrebuiltWasmToolsTarget Include="x86_64-windows" Rid="win-x64" Ext=".zip" ExeExt=".exe" />
<!-- tar on non-Windows often cannot handle zip archives. Until we have a solution, we canonly publish the packages from the Windows build.
See https://github.com/bytecodealliance/componentize-dotnet/issues/41 -->
<PrebuiltWasmToolsTarget Include="x86_64-windows" Rid="win-x64" Ext=".zip" ExeExt=".exe" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
</ItemGroup>
<ItemGroup>
<PrebuiltWasmToolsOutputs Include="tools\%(PrebuiltWasmToolsTarget.Rid)\wasm-tools%(PrebuiltWasmToolsTarget.ExeExt)" />
Expand Down
4 changes: 3 additions & 1 deletion src/WitBindgen/WitBindgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<PrebuiltToolTarget Include="aarch64-macos" Rid="osx-arm64" Ext=".tar.gz" wkg="aarch64-apple-darwin"/>
<PrebuiltToolTarget Include="x86_64-linux" Rid="linux-x64" Ext=".tar.gz" wkg="x86_64-unknown-linux-gnu"/>
<PrebuiltToolTarget Include="x86_64-macos" Rid="osx-x64" Ext=".tar.gz" wkg="x86_64-apple-darwin"/>
<PrebuiltToolTarget Include="x86_64-windows" Rid="win-x64" Ext=".zip" ExeExt=".exe" wkg="x86_64-pc-windows-gnu" />
<!-- tar on non-Windows often cannot handle zip archives -->
<PrebuiltToolTarget Include="x86_64-windows" Rid="win-x64" Ext=".zip" ExeExt=".exe" wkg="x86_64-pc-windows-gnu" Condition="$([MSBuild]::IsOSPlatform('Windows'))"/>
</ItemGroup>
<ItemGroup>
<PrebuiltWitBindgenOutputs Include="tools\%(PrebuiltToolTarget.Rid)\wit-bindgen%(PrebuiltToolTarget.ExeExt)" />
Expand All @@ -79,6 +80,7 @@
<RemoveDir Directories="tools\temp" />

<DownloadFile SourceUrl="$(PrebuildWkgBaseUrl)-%(PrebuiltToolTarget.wkg)" DestinationFolder="tools\%(PrebuiltToolTarget.Rid)" DestinationFileName="wkg%(PrebuiltToolTarget.ExeExt)" />
<Exec Command="chmod +x &quot;tools/%(PrebuiltToolTarget.Rid)/wkg%(PrebuiltToolTarget.ExeExt)&quot;" Condition="$([MSBuild]::IsOSPlatform('Windows')) != 'true'" />
<WriteLinesToFile File="$(CurrentWkgVersion)" Lines="$(PrebuildWkgVersion)" Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>

Expand Down
2 changes: 1 addition & 1 deletion test/E2ETest/PackageTest/PackageTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<RemoveDir Directories="..\testapps\E2EProducer\obj" />
<RemoveDir Directories="..\testapps\E2EConsumer\obj" />
<Exec Command="dotnet restore --no-cache" WorkingDirectory="..\testapps\E2EConsumer" />
<Exec Command="dotnet build --no-restore" WorkingDirectory="..\testapps\E2EConsumer" />
<Exec Command="dotnet build --no-restore /bl" WorkingDirectory="..\testapps\E2EConsumer" />
</Target>

<Target Name="PackPackagesForE2ETest">
Expand Down
1 change: 1 addition & 0 deletions test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<UseAppHost>false</UseAppHost>
<PublishTrimmed>true</PublishTrimmed>
<TargetName>e2econsumer</TargetName>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions test/E2ETest/testapps/E2EProducer/E2EProducer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<PublishTrimmed>true</PublishTrimmed>
<TargetName>e2eproducer</TargetName>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/E2ETest/testapps/nuget.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dev" value="..\PackageTest\packages" />
<add key="dev" value="../PackageTest/packages" />
</packageSources>
<packageSourceMapping>
<packageSource key="dev">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ private static string FindModulePath(string searchDir, string filename)
}

var matches = Directory.GetFiles(resolvedSearchDir, filename, SearchOption.AllDirectories);
if (matches.Count() != 1)
{
throw new Exception($"Failed to get modules path, matched {matches.Count()} entries for directory {resolvedSearchDir} and filename {filename}.");
}

return Path.GetFullPath(matches.Single());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<TargetName>appwithwitfolder</TargetName>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions test/WasmComponentSdkTest/testapps/OciWit/OciWit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<TargetName>ociwit</TargetName>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<TargetName>simpleconsumer</TargetName>
</PropertyGroup>

<ItemGroup>
Expand All @@ -31,7 +32,7 @@
</PropertyGroup>

<MakeDir Directories="dist" />
<Exec Command="$(WasmToolsExe) compose -o dist/composed.wasm $(NativeOutputPath)$(TargetName.ToLower()).wasm -d $(DependencyComponent)" />
<Exec Command="$(WasmToolsExe) compose -o dist/composed.wasm $(NativeOutputPath)$(TargetName).wasm -d $(DependencyComponent)" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<!-- Kebab case probably better -->
<TargetName>simpleproducer</TargetName>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/WasmtimeCliFetcher/FetchWasmtime.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- This is a marker file that lets the build scripts identity if the files need to be modified when updating versions -->
<CurrentWasmtimeVersion>$(MSBuildThisFileDirectory)tools\version-$(WasmtimeVersion)</CurrentWasmtimeVersion>

<WasmtimeUrlExtension>.tar.gz</WasmtimeUrlExtension>
<WasmtimeUrlExtension>.tar.xz</WasmtimeUrlExtension>
<WasmtimeUrlExtension Condition="$([MSBuild]::IsOSPlatform('Windows'))">.zip</WasmtimeUrlExtension>
<WasmtimeUrl>https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-$(WasmtimeTarget)$(WasmtimeUrlExtension)</WasmtimeUrl>
</PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion test/WitBindgenTest/WitBindgenTest/CodeGenerationTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MyFuncsWorld;
using ProducerWorld;
using System;
using Xunit;

namespace WitBindgenTest;
Expand All @@ -14,7 +15,8 @@ public void GeneratesSimpleImport()
LibraryUsingWit.Code.CallSimpleDoSomething());

// Currently, it generates [DllImport("*", ...)] so validate that
Assert.StartsWith("Unable to load DLL", ex.Message);
var expectedErrorMessagePrefix = "Unable to load " + (OperatingSystem.IsWindows() ? "DLL" : "shared library");
Assert.StartsWith(expectedErrorMessagePrefix, ex.Message);
}

[Fact]
Expand Down

0 comments on commit 81d9da1

Please sign in to comment.