-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathWasmComponent.Sdk.csproj
110 lines (91 loc) · 5.96 KB
/
WasmComponent.Sdk.csproj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="build\BytecodeAlliance.Componentize.DotNet.Wasm.SDK.props" />
<PropertyGroup>
<PackageId>BytecodeAlliance.Componentize.DotNet.Wasm.SDK</PackageId>
<Authors>Bytecode Alliance Developers</Authors>
<Description>Tooling for creating WebAssembly components from C#</Description>
<RepositoryUrl>https://github.com/bytecodealliance/componentize-dotnet</RepositoryUrl>
<PackageLicenseExpression>Apache-2.0 WITH LLVM-exception</PackageLicenseExpression>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageTags>webassembly, .net, wasm</PackageTags>
<PackageReleaseNotes>https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion)</PackageReleaseNotes>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<!-- Things you might want to edit -->
<!-- Set BuildWasmToolsLocally to true if you want to build modules/wasm-tools locally and use its output -->
<BuildWasmToolsLocally>false</BuildWasmToolsLocally>
<WasmToolsModuleRoot>$(MSBuildThisFileDirectory)..\..\modules\wasm-tools\</WasmToolsModuleRoot>
<PrebuiltWasmToolsBaseUrl>https://github.com/bytecodealliance/wasm-tools/releases/download/v$(WasmToolsVersion)/wasm-tools-$(WasmToolsVersion)</PrebuiltWasmToolsBaseUrl>
<WacBaseUrl>https://github.com/bytecodealliance/wac/releases/download/$(WacVersion)/wac-cli</WacBaseUrl>
<!-- Don't pack any assemblies in lib/*/.dll.-->
<NoPackageAnalysis>true</NoPackageAnalysis>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\WitBindgen\WitBindgen.csproj" PrivateAssets="None" />
</ItemGroup>
<ItemGroup>
<None Include="../../Readme.md" Pack="true" PackagePath="\"/>
</ItemGroup>
<ItemGroup>
<None Include="ImportInDev.proj" />
</ItemGroup>
<Target Name="BuildOrDownloadNativeTooling" BeforeTargets="Build" DependsOnTargets="BuildNativeTooling; DownloadNativeTooling;">
</Target>
<Target Name="BuildNativeTooling" Condition="'$(BuildWasmToolsLocally)' == 'true'">
<Exec Command="cargo build --release" WorkingDirectory="$(WasmToolsModuleRoot)" />
<PropertyGroup>
<WasmToolsExeName>wasm-tools</WasmToolsExeName>
<WasmToolsExeName Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(WasmToolsExeName).exe</WasmToolsExeName>
</PropertyGroup>
<Copy SourceFiles="$(WasmToolsModuleRoot)target\release\$(WasmToolsExeName)" DestinationFolder="tools\$(WasmToolsTarget)\" />
</Target>
<Target Name="DownloadNativeTooling" Condition="'$(BuildWasmToolsLocally)' != 'true'" DependsOnTargets="GetWasmToolsDependencies; DownloadWasmTools; GetWacDependencies; DownloadWac">
</Target>
<Target Name="GetWasmToolsDependencies">
<ItemGroup>
<WasmToolsTarget Include="aarch64-linux" Rid="linux-arm64" Ext=".tar.gz" />
<WasmToolsTarget Include="aarch64-macos" Rid="osx-arm64" Ext=".tar.gz" />
<WasmToolsTarget Include="x86_64-linux" Rid="linux-x64" Ext=".tar.gz" />
<WasmToolsTarget Include="x86_64-macos" Rid="osx-x64" Ext=".tar.gz" />
<!-- 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 -->
<WasmToolsTarget Include="x86_64-windows" Rid="win-x64" Ext=".zip" ExeExt=".exe" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
</ItemGroup>
<ItemGroup>
<PrebuiltWasmToolsOutputs Include="tools\%(WasmToolsTarget.Rid)\wasm-tools%(WasmToolsTarget.ExeExt)" />
</ItemGroup>
</Target>
<Target Name="GetWacDependencies">
<ItemGroup>
<WacTarget Include="aarch64-unknown-linux-musl" Rid="linux-arm64"/>
<WacTarget Include="aarch64-apple-darwin" Rid="osx-arm64"/>
<WacTarget Include="x86_64-unknown-linux-musl" Rid="linux-x64"/>
<WacTarget Include="x86_64-apple-darwin" Rid="osx-x64"/>
<WacTarget Include="x86_64-pc-windows-gnu" Rid="win-x64" ExeExt=".exe"/>
</ItemGroup>
<ItemGroup>
<WacOutputs Include="tools\%(WacTarget.Rid)\wac%(WacTarget.ExeExt)" />
</ItemGroup>
</Target>
<Target Name="DownloadWac" Inputs="@(WacOutputs)" Outputs="@(WacOutputs)">
<MakeDir Directories="tools\%(WacOutputs.Rid)" />
<DownloadFile SourceUrl="$(WacBaseUrl)-%(WacTarget.Identity)" DestinationFolder="tools\%(WacTarget.Rid)" DestinationFileName="wac%(WacTarget.ExeExt)" />
<!-- this makes CI pass but doesn't really make it work from Linux since package is build on Windows-->
<Exec Command="chmod +x tools/%(WacTarget.Rid)/wac" Condition="$([MSBuild]::IsOSPlatform('Linux')) And '%(WacTarget.ExeExt)' == ''"/>
</Target>
<Target Name="DownloadWasmTools" Inputs="@(PrebuiltWasmToolsOutputs)" Outputs="@(PrebuiltWasmToolsOutputs)">
<DownloadFile SourceUrl="$(PrebuiltWasmToolsBaseUrl)-%(WasmToolsTarget.Identity)%(WasmToolsTarget.Ext)" DestinationFolder="tools\temp" DestinationFileName="%(WasmToolsTarget.Rid)%(WasmToolsTarget.Ext)" />
<MakeDir Directories="tools\%(WasmToolsTarget.Rid)" />
<Exec Command="tar -xf "temp/%(WasmToolsTarget.Rid)%(WasmToolsTarget.Ext)" -C %(WasmToolsTarget.Rid) --strip-components=1" WorkingDirectory="tools" />
<RemoveDir Directories="tools\temp" />
</Target>
<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
<ItemGroup>
<_PackageFiles Include="build\**" BuildAction="Content" PackagePath="build" />
<_PackageFiles Include="tools\**" BuildAction="Content" PackagePath="tools" />
</ItemGroup>
</Target>
</Project>