1 $TARGET = "$($Env:ARCH)-windows-gnu"
2 $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.12.0-dev.2087+e9a18010b"
4 $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
5 $PREFIX_PATH = "$(Get-Location)\..\$ZIG_LLVM_CLANG_LLD_NAME"
6 $ZIG = "$PREFIX_PATH\bin\zig.exe"
7 $ZIG_LIB_DIR = "$(Get-Location)\lib"
9 if (!(Test-Path "..\$ZIG_LLVM_CLANG_LLD_NAME.zip")) {
10 Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
11 Invoke-WebRequest
-Uri
"$ZIG_LLVM_CLANG_LLD_URL" -OutFile
"..\$ZIG_LLVM_CLANG_LLD_NAME.zip"
13 Write-Output "Extracting..."
14 Add-Type
-AssemblyName System
.IO
.Compression
.FileSystem
;
15 [System
.IO
.Compression
.ZipFile
]::ExtractToDirectory
("$PWD\..\$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD\..")
18 function CheckLastExitCode
{
25 # Make the `zig version` number consistent.
26 # This will affect the `zig build` command below which uses `git describe`.
29 if ((git rev-parse
--is-shallow-repository
) -eq
"true") {
30 git fetch
--unshallow
# `git describe` won't work on a shallow repo
33 Write-Output "Building from source..."
34 Remove-Item -Path
'build-release' -Recurse
-Force
-ErrorAction Ignore
35 New-Item -Path
'build-release' -ItemType Directory
36 Set-Location -Path
'build-release'
38 # Override the cache directories because they won't actually help other CI runs
39 # which will be testing alternate versions of zig, and ultimately would just
40 # fill up space on the hard drive for no reason.
41 $Env:ZIG_GLOBAL_CACHE_DIR
="$(Get-Location)\zig-global-cache"
42 $Env:ZIG_LOCAL_CACHE_DIR
="$(Get-Location)\zig-local-cache"
44 # CMake gives a syntax error when file paths with backward slashes are used.
45 # Here, we use forward slashes only to work around this.
48 -DCMAKE_INSTALL_PREFIX
="stage3-release" `
49 -DCMAKE_PREFIX_PATH
="$($PREFIX_PATH -Replace "\\", "/")" `
50 -DCMAKE_BUILD_TYPE
=Release `
51 -DCMAKE_C_COMPILER
="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
52 -DCMAKE_CXX_COMPILER
="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
54 -DZIG_AR_WORKAROUND
=ON `
55 -DZIG_TARGET_TRIPLE
="$TARGET" `
56 -DZIG_TARGET_MCPU
="$MCPU" `
64 Write-Output "Main test suite..."
65 & "stage3-release\bin\zig.exe" build test docs `
66 --zig-lib-dir
"$ZIG_LIB_DIR" `
67 --search-prefix
"$PREFIX_PATH" `
70 -Denable-symlinks-windows