1$TARGET = "aarch64-windows-gnu"
2$MCPU = "baseline"
3$PREFIX_PATH = "$($Env:USERPROFILE)\deps\zig+llvm+lld+clang-$TARGET-0.18.0-dev.92+1e1964473"
4$ZIG = "$PREFIX_PATH\bin\zig.exe"
5$ZSF_MAX_RSS = if ($Env:ZSF_MAX_RSS) { $Env:ZSF_MAX_RSS } else { 0 }
6
7$Env:PATH = "$($Env:USERPROFILE)\local\bin;$Env:PATH"
8
9function CheckLastExitCode {
10 if (!$?) {
11 exit 1
12 }
13 return 0
14}
15
16# Override the cache directories because they won't actually help other CI runs
17# which will be testing alternate versions of zig, and ultimately would just
18# fill up space on the hard drive for no reason.
19$Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
20$Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
21
22Write-Output "Building from source..."
23New-Item -Force -Path 'build-debug' -ItemType Directory
24Set-Location -Path 'build-debug'
25
26# CMake gives a syntax error when file paths with backward slashes are used.
27# Here, we use forward slashes only to work around this.
28cmake .. `
29 -GNinja `
30 -DCMAKE_INSTALL_PREFIX="stage3-debug" `
31 -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
32 -DCMAKE_BUILD_TYPE=Debug `
33 -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
34 -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
35 -DCMAKE_AR="$($ZIG -Replace "\\", "/")" `
36 -DZIG_AR_WORKAROUND=ON `
37 -DZIG_TARGET_TRIPLE="$TARGET" `
38 -DZIG_TARGET_MCPU="$MCPU" `
39 -DZIG_STATIC=ON `
40 -DZIG_NO_LIB=ON
41CheckLastExitCode
42
43ninja install
44CheckLastExitCode
45
46# Must be done after zig cc is finished.
47$Env:ZIG_LIB_DIR="$(Get-Location)\..\lib"
48
49Write-Output "Main test suite..."
50stage3-debug\bin\zig.exe build install test docs `
51 --maxrss "$ZSF_MAX_RSS" `
52 --prefix stage4-debug `
53 --search-prefix "$PREFIX_PATH" `
54 --test-timeout 30m `
55 -Dversion-string="$(stage3-debug\bin\zig.exe version)" `
56 -Dtarget="$TARGET" `
57 -Dcpu="$MCPU" `
58 -Duse-zig-libcxx `
59 -Denable-llvm `
60 -Dno-lib `
61 -Denable-symlinks-windows `
62 -Dskip-non-native
63CheckLastExitCode
64
65stage4-debug\bin\zig.exe test ..\test\behavior.zig
66CheckLastExitCode