-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathwasi-provisioning.targets
35 lines (30 loc) · 2.2 KB
/
wasi-provisioning.targets
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
<Project>
<PropertyGroup>
<_WasmtimeVersionFile>$(WasiProjectRoot)wasmtime-version.txt</_WasmtimeVersionFile>
<_WasmtimeStampPath>$(WasmtimeDir)\.stamp-wasmtime-version.txt</_WasmtimeStampPath>
<InstallWasmtimeForTests Condition="'$(InstallWasmtimeForTests)' == '' and !Exists($(WasmtimeDir))">true</InstallWasmtimeForTests>
</PropertyGroup>
<!-- FIXMEWASI: prevent multiple downloads -->
<Target Name="ProvisionWasmtime"
AfterTargets="Build"
Condition="'$(InstallWasmtimeForTests)' == 'true' and !Exists($(WasmtimeDir))"
Inputs="$(_WasmtimeVersionFile)"
Outputs="$(_WasmtimeStampPath)">
<ReadLinesFromFile File="$(_WasmtimeVersionFile)">
<Output TaskParameter="Lines" ItemName="_VersionLines" />
</ReadLinesFromFile>
<PropertyGroup>
<WasmtimeVersion>%(_VersionLines.Identity)</WasmtimeVersion>
<WasmtimeURL>https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-linux.tar.xz</WasmtimeURL>
<WasmtimeURL Condition="'$(HostOS)' == 'osx'" >https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-macos.tar.xz</WasmtimeURL>
<WasmtimeURL Condition="'$(HostOS)' == 'windows'" >https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-windows.zip</WasmtimeURL>
</PropertyGroup>
<DownloadFile SourceUrl="$(WasmtimeURL)" DestinationFolder="$(ArtifactsObjDir)" SkipUnchangedFiles="true">
<Output TaskParameter="DownloadedFile" PropertyName="_DownloadedFile" />
</DownloadFile>
<MakeDir Directories="$(WasmtimeDir)" />
<Exec Command="powershell -command "Expand-Archive $(_DownloadedFile) . ; Move-Item wasmtime-v$(WasmtimeVersion)-x86_64-windows/*.* . "" WorkingDirectory="$(WasmtimeDir)" Condition="'$(HostOS)' == 'windows'"/>
<Exec Command="tar -Jx --strip-components=1 -f $(_DownloadedFile)" WorkingDirectory="$(WasmtimeDir)" Condition="'$(HostOS)' != 'windows'"/>
<Copy SourceFiles="$(WasiProjectRoot)wasmtime-version.txt" DestinationFiles="$(_WasmtimeStampPath)" SkipUnchangedFiles="true" />
</Target>
</Project>