1 $TARGET = "$($Env:ARCH)-windows-gnu"
2 $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.12.0-dev.2073+402fe565a"
4 $PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
5 $ZIG = "$PREFIX_PATH\bin\zig.exe"
6 $ZIG_LIB_DIR = "$(Get-Location)\lib"
8 function CheckLastExitCode
{
15 # Make the `zig version` number consistent.
16 # This will affect the `zig build` command below which uses `git describe`.
19 if ((git rev-parse
--is-shallow-repository
) -eq
"true") {
20 git fetch
--unshallow
# `git describe` won't work on a shallow repo
23 Write-Output "Building from source..."
24 Remove-Item -Path
'build-release' -Recurse
-Force
-ErrorAction Ignore
25 New-Item -Path
'build-release' -ItemType Directory
26 Set-Location -Path
'build-release'
28 # CMake gives a syntax error when file paths with backward slashes are used.
29 # Here, we use forward slashes only to work around this.
32 -DCMAKE_INSTALL_PREFIX
="stage3-release" `
33 -DCMAKE_PREFIX_PATH
="$($PREFIX_PATH -Replace "\\", "/")" `
34 -DCMAKE_BUILD_TYPE
=Release `
35 -DCMAKE_C_COMPILER
="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
36 -DCMAKE_CXX_COMPILER
="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
37 -DCMAKE_AR
="$($ZIG -Replace "\\", "/")" `
38 -DZIG_AR_WORKAROUND
=ON `
39 -DZIG_TARGET_TRIPLE
="$TARGET" `
40 -DZIG_TARGET_MCPU
="$MCPU" `
48 Write-Output "Main test suite..."
49 & "stage3-release\bin\zig.exe" build test docs `
50 --zig-lib-dir
"$ZIG_LIB_DIR" `
51 --search-prefix
"$PREFIX_PATH" `
54 -Denable-symlinks-windows
57 Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
58 & "stage3-release\bin\zig.exe" test `
59 ..\test\behavior
.zig `
60 --zig-lib-dir
"$ZIG_LIB_DIR" `
62 -femit-bin
="test-x86_64-windows-msvc.c" `
64 -target x86_64-windows-msvc `
68 & "stage3-release\bin\zig.exe" build-obj `
69 --zig-lib-dir
"$ZIG_LIB_DIR" `
73 -femit-bin
="compiler_rt-x86_64-windows-msvc.c" `
75 -target x86_64-windows-msvc `
76 --mod root
..\lib\compiler_rt
.zig `
77 --mod build_options config
.zig
80 Import-Module
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
83 Enter-VsDevShell
-VsInstallPath
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" `
84 -DevCmdArguments
'-arch=x64 -no_logo' `
85 -StartInPath $(Get-Location)
88 Write-Output "Build and run behavior tests with msvc..."
89 & cl
.exe
-I
..\lib test-x86_64-windows-msvc
.c compiler_rt-x86_64-windows-msvc
.c
/W3
/Z7
-link
-nologo
-debug
-subsystem
:console kernel32
.lib ntdll
.lib libcmt
.lib
92 & .\test-x86_64-windows-msvc
.exe