Files
bun.sh/scripts/download-zig.ps1
dave caruso 369e3022e4 chore: upgrade zig to 0.12.0-dev.1828+225fe6ddb (#7671)
* chore: upgrade zig to 0.12.0-dev.1828+225fe6ddb

* open as iterable

* fix building identifier cache

* fix windows build

* fix linux build

* fix linux build
2023-12-16 00:14:15 -08:00

42 lines
1.1 KiB
PowerShell

$ErrorActionPreference = "Stop"
$ZigVersion="0.12.0-dev.1828+225fe6ddb"
$Target="windows"
$Arch="x86_64"
$Url = "https://ziglang.org/builds/zig-${Target}-${Arch}-${ZigVersion}.zip"
$CacheDir = (mkdir -Force (Join-Path $PSScriptRoot "../.cache"))
$TarPath = Join-Path $CacheDir "zig-${ZigVersion}.zip"
$OutDir = Join-Path $CacheDir "zig"
if (Test-Path $OutDir\.tag) {
$CurrentTag = Get-Content -Path (Join-Path $OutDir ".tag")
if ($CurrentTag -eq $ZigVersion) {
return
}
}
Remove-Item $OutDir -ErrorAction SilentlyContinue -Recurse
$null = mkdir -Force $OutDir
Push-Location $CacheDir
try {
if (!(Test-Path $TarPath)) {
try {
Write-Host "-- Downloading Zig"
Invoke-WebRequest $Url -OutFile $TarPath
} catch {
Write-Error "Failed to fetch Zig from: $Url"
throw $_
}
}
Remove-Item "$OutDir" -Recurse
Expand-Archive "$TarPath" "$OutDir\..\"
Move-Item "zig-$Target-$Arch-$ZigVersion" "zig"
Set-Content -Path (Join-Path $OutDir ".tag") -Value "$ZigVersion"
} catch {
Remove-Item -Force -ErrorAction SilentlyContinue $OutDir
throw $_
} finally {
Pop-Location
}