forked from bytecodealliance/componentize-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWitBindgen.csproj
98 lines (80 loc) · 6.31 KB
/
WitBindgen.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
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="build\BytecodeAlliance.Componentize.DotNet.WitBindgen.props" />
<PropertyGroup>
<PackageId>BytecodeAlliance.Componentize.DotNet.WitBindgen</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>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<!-- Things you might want to edit -->
<!-- Set BuildWitBindgenLocally to true if you want to build modules/wit-bindgen locally and use its output -->
<BuildWitBindgenLocally>false</BuildWitBindgenLocally>
<PrebuiltWitBindgenVersion>0.30.0</PrebuiltWitBindgenVersion>
<PrebuiltWitBindgenBaseUrl>https://github.com/bytecodealliance/wit-bindgen/releases/download/v$(PrebuiltWitBindgenVersion)/wit-bindgen-$(PrebuiltWitBindgenVersion)</PrebuiltWitBindgenBaseUrl>
<WitBindgenModuleRoot>$(MSBuildThisFileDirectory)..\..\modules\wit-bindgen\</WitBindgenModuleRoot>
<!-- This is a marker file that lets the build scripts identity if the files need to be modified when updating versions -->
<CurrentWitBindgenVersion>$(MSBuildThisFileDirectory)tools\version-wit-bindgen-$(PrebuiltWitBindgenVersion)</CurrentWitBindgenVersion>
<PrebuildWkgVersion>0.5.1</PrebuildWkgVersion>
<PrebuildWkgBaseUrl>https://github.com/bytecodealliance/wasm-pkg-tools/releases/download/v$(PrebuildWkgVersion)/wkg</PrebuildWkgBaseUrl>
<CurrentWkgVersion>$(MSBuildThisFileDirectory)tools\version-wkg-$(PrebuildWkgVersion)</CurrentWkgVersion>
<!-- Don't pack any assemblies in lib/*/.dll.-->
<NoPackageAnalysis>true</NoPackageAnalysis>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup>
<None Include="../../Readme.md" Pack="true" PackagePath="\"/>
</ItemGroup>
<Target Name="BuildOrDownloadNativeTooling" BeforeTargets="BeforeBuild" DependsOnTargets="BuildNativeTooling; DownloadNativeTooling">
</Target>
<Target Name="BuildNativeTooling" Condition="'$(BuildWitBindgenLocally)' == 'true'">
<Exec Command="cargo build --release" WorkingDirectory="$(WitBindgenModuleRoot)" />
<PropertyGroup>
<WitBindgenExeName>wit-bindgen</WitBindgenExeName>
<WitBindgenExeName Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(WitBindgenExeName).exe</WitBindgenExeName>
</PropertyGroup>
<Copy SourceFiles="$(WitBindgenModuleRoot)target\release\$(WitBindgenExeName)" DestinationFolder="tools\$(WitBindgenToolTarget)\" />
</Target>
<Target Name="DownloadNativeTooling" DependsOnTargets="GetDownloadNativeToolingDependencies; DownloadNativeToolingCore" Condition="'$(BuildWitBindgenLocally)' != 'true'">
</Target>
<Target Name="GetDownloadNativeToolingDependencies">
<ItemGroup>
<PrebuiltToolTarget Include="aarch64-linux" Rid="linux-arm64" Ext=".tar.gz" wkg="aarch64-unknown-linux-gnu" />
<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"/>
<!-- 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)" />
<PrebuiltWkgOutputs Include="tools\%(PrebuiltToolTarget.Rid)\wkg%(PrebuiltToolTarget.ExeExt)" />
</ItemGroup>
</Target>
<Target Name="DownloadNativeToolingCore" Condition="!Exists('$(CurrentWitBindgenVersion)') Or !Exists('$(CurrentWkgVersion)')" Inputs="@(PrebuiltWitBindgenOutputs);$(CurrentWitBindgenVersion);$(CurrentWkgVersion)" Outputs="@(PrebuiltWitBindgenOutputs);$(CurrentWitBindgenVersion);$(CurrentWkgVersion)">
<RemoveDir Directories="$(MSBuildThisFileDirectory)tools" />
<MakeDir Directories="tools\%(PrebuiltToolTarget.Rid)" />
<DownloadFile SourceUrl="$(PrebuiltWitBindgenBaseUrl)-%(PrebuiltToolTarget.Identity)%(PrebuiltToolTarget.Ext)" DestinationFolder="tools\temp" DestinationFileName="%(PrebuiltToolTarget.Rid)%(PrebuiltToolTarget.Ext)" />
<WriteLinesToFile File="$(CurrentWitBindgenVersion)" Lines="$(PrebuiltWitBindgenVersion)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Exec Command="tar -xf "temp/%(PrebuiltToolTarget.Rid)%(PrebuiltToolTarget.Ext)" -C %(PrebuiltToolTarget.Rid) --strip-components=1" WorkingDirectory="tools" />
<RemoveDir Directories="tools\temp" />
<DownloadFile SourceUrl="$(PrebuildWkgBaseUrl)-%(PrebuiltToolTarget.wkg)" DestinationFolder="tools\%(PrebuiltToolTarget.Rid)" DestinationFileName="wkg%(PrebuiltToolTarget.ExeExt)" />
<Exec Command="chmod +x "tools/%(PrebuiltToolTarget.Rid)/wkg%(PrebuiltToolTarget.ExeExt)"" Condition="$([MSBuild]::IsOSPlatform('Windows')) != 'true'" />
<WriteLinesToFile File="$(CurrentWkgVersion)" Lines="$(PrebuildWkgVersion)" Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>
<ItemGroup>
<None Include="ImportInDev.proj" />
</ItemGroup>
<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
<ItemGroup>
<_PackageFiles Include="build\**" BuildAction="Content" PackagePath="build" />
<_PackageFiles Include="tools\**" BuildAction="Content" PackagePath="tools" />
</ItemGroup>
</Target>
</Project>