2022-11-14 21:41:36 +00:00
|
|
|
$TARGET = "$($Env:ARCH)-windows-gnu"
|
2024-09-18 22:07:02 +00:00
|
|
|
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
2022-12-07 05:45:03 +00:00
|
|
|
$MCPU = "baseline"
|
2024-04-29 22:01:40 +00:00
|
|
|
$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
2024-04-29 22:44:35 +00:00
|
|
|
$PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
|
2022-12-07 05:45:03 +00:00
|
|
|
$ZIG = "$PREFIX_PATH\bin\zig.exe"
|
2022-12-07 10:47:54 +00:00
|
|
|
$ZIG_LIB_DIR = "$(Get-Location)\lib"
|
2022-11-14 21:41:36 +00:00
|
|
|
|
2024-04-29 23:08:50 +00:00
|
|
|
if (!(Test-Path "$PREFIX_PATH.zip")) {
|
2024-04-29 22:01:40 +00:00
|
|
|
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
|
2024-04-29 23:08:50 +00:00
|
|
|
Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$PREFIX_PATH.zip"
|
2024-04-29 22:01:40 +00:00
|
|
|
|
|
|
|
Write-Output "Extracting..."
|
|
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem ;
|
2024-04-29 23:08:50 +00:00
|
|
|
[System.IO.Compression.ZipFile]::ExtractToDirectory("$PREFIX_PATH.zip", "$PREFIX_PATH\..")
|
2024-04-29 22:01:40 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 21:41:36 +00:00
|
|
|
function CheckLastExitCode {
|
|
|
|
if (!$?) {
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make the `zig version` number consistent.
|
|
|
|
# This will affect the `zig build` command below which uses `git describe`.
|
|
|
|
git fetch --tags
|
|
|
|
|
|
|
|
if ((git rev-parse --is-shallow-repository) -eq "true") {
|
|
|
|
git fetch --unshallow # `git describe` won't work on a shallow repo
|
|
|
|
}
|
|
|
|
|
2022-12-07 05:45:03 +00:00
|
|
|
Write-Output "Building from source..."
|
2023-01-17 03:33:24 +00:00
|
|
|
Remove-Item -Path 'build-debug' -Recurse -Force -ErrorAction Ignore
|
|
|
|
New-Item -Path 'build-debug' -ItemType Directory
|
|
|
|
Set-Location -Path 'build-debug'
|
2022-11-14 21:41:36 +00:00
|
|
|
|
2024-04-29 22:01:40 +00:00
|
|
|
# Override the cache directories because they won't actually help other CI runs
|
|
|
|
# which will be testing alternate versions of zig, and ultimately would just
|
|
|
|
# fill up space on the hard drive for no reason.
|
|
|
|
$Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
|
|
|
|
$Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
|
|
|
|
|
2022-12-07 05:45:03 +00:00
|
|
|
# CMake gives a syntax error when file paths with backward slashes are used.
|
|
|
|
# Here, we use forward slashes only to work around this.
|
|
|
|
& cmake .. `
|
|
|
|
-GNinja `
|
2023-01-17 03:33:24 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX="stage3-debug" `
|
2022-12-07 05:45:03 +00:00
|
|
|
-DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
|
2023-01-17 03:33:24 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=Debug `
|
2022-12-07 05:45:03 +00:00
|
|
|
-DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
|
|
|
|
-DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
|
2024-04-14 03:12:52 +00:00
|
|
|
-DCMAKE_AR="$($ZIG -Replace "\\", "/")" `
|
|
|
|
-DZIG_AR_WORKAROUND=ON `
|
2022-12-07 05:45:03 +00:00
|
|
|
-DZIG_TARGET_TRIPLE="$TARGET" `
|
|
|
|
-DZIG_TARGET_MCPU="$MCPU" `
|
2023-07-22 03:29:42 +00:00
|
|
|
-DZIG_STATIC=ON `
|
2024-09-18 20:09:37 +00:00
|
|
|
-DZIG_NO_LIB=ON
|
2022-12-01 07:49:55 +00:00
|
|
|
CheckLastExitCode
|
2022-11-29 21:55:04 +00:00
|
|
|
|
2022-12-07 05:45:03 +00:00
|
|
|
ninja install
|
2022-12-01 07:49:55 +00:00
|
|
|
CheckLastExitCode
|
2022-11-29 21:55:04 +00:00
|
|
|
|
2022-12-07 05:45:03 +00:00
|
|
|
Write-Output "Main test suite..."
|
2023-01-17 03:33:24 +00:00
|
|
|
& "stage3-debug\bin\zig.exe" build test docs `
|
2022-12-07 10:47:54 +00:00
|
|
|
--zig-lib-dir "$ZIG_LIB_DIR" `
|
|
|
|
--search-prefix "$PREFIX_PATH" `
|
2022-12-07 05:45:03 +00:00
|
|
|
-Dstatic-llvm `
|
|
|
|
-Dskip-non-native `
|
2023-10-18 21:45:13 +00:00
|
|
|
-Dskip-release `
|
2024-08-18 13:20:55 +00:00
|
|
|
-Denable-symlinks-windows
|
2022-12-07 05:45:03 +00:00
|
|
|
CheckLastExitCode
|
2022-12-06 19:19:24 +00:00
|
|
|
|
2023-01-21 21:16:09 +00:00
|
|
|
Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
2023-01-21 21:32:37 +00:00
|
|
|
& "stage3-debug\bin\zig.exe" test `
|
2023-01-08 07:35:38 +00:00
|
|
|
..\test\behavior.zig `
|
|
|
|
--zig-lib-dir "$ZIG_LIB_DIR" `
|
|
|
|
-ofmt=c `
|
2023-01-21 21:16:09 +00:00
|
|
|
-femit-bin="test-x86_64-windows-msvc.c" `
|
2023-01-23 15:28:03 +00:00
|
|
|
--test-no-exec `
|
2023-01-26 05:45:40 +00:00
|
|
|
-target x86_64-windows-msvc `
|
|
|
|
-lc
|
2023-01-08 07:35:38 +00:00
|
|
|
CheckLastExitCode
|
|
|
|
|
2023-01-21 21:32:37 +00:00
|
|
|
& "stage3-debug\bin\zig.exe" build-obj `
|
2023-01-08 07:35:38 +00:00
|
|
|
--zig-lib-dir "$ZIG_LIB_DIR" `
|
|
|
|
-ofmt=c `
|
|
|
|
-OReleaseSmall `
|
|
|
|
--name compiler_rt `
|
2023-01-21 21:16:09 +00:00
|
|
|
-femit-bin="compiler_rt-x86_64-windows-msvc.c" `
|
2024-01-01 23:45:52 +00:00
|
|
|
--dep build_options `
|
|
|
|
-target x86_64-windows-msvc `
|
2024-07-23 00:54:30 +00:00
|
|
|
-Mroot="..\lib\compiler_rt.zig" `
|
|
|
|
-Mbuild_options="config.zig"
|
2023-01-08 07:35:38 +00:00
|
|
|
CheckLastExitCode
|
|
|
|
|
2024-04-14 03:12:52 +00:00
|
|
|
Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
2023-01-08 07:35:38 +00:00
|
|
|
CheckLastExitCode
|
|
|
|
|
2024-04-14 03:12:52 +00:00
|
|
|
Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" `
|
2023-01-08 07:35:38 +00:00
|
|
|
-DevCmdArguments '-arch=x64 -no_logo' `
|
|
|
|
-StartInPath $(Get-Location)
|
|
|
|
CheckLastExitCode
|
|
|
|
|
2023-01-17 03:33:24 +00:00
|
|
|
Write-Output "Build and run behavior tests with msvc..."
|
2024-01-02 12:57:36 +00:00
|
|
|
& 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
|
|
|
|
CheckLastExitCode
|
|
|
|
|
|
|
|
& .\test-x86_64-windows-msvc.exe
|
|
|
|
CheckLastExitCode
|