2022-11-14 21:41:36 +00:00
|
|
|
$TARGET = "$($Env:ARCH)-windows-gnu"
|
2023-09-23 00:20:11 +01:00
|
|
|
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.12.0-dev.888+130227492"
|
2022-12-07 05:45:03 +00:00
|
|
|
$MCPU = "baseline"
|
2022-11-14 21:41:36 +00:00
|
|
|
$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
2022-12-07 05:45:03 +00:00
|
|
|
$PREFIX_PATH = "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME"
|
|
|
|
$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
|
|
|
|
2023-09-21 20:01:18 +01:00
|
|
|
choco install ninja
|
2022-11-14 21:41:36 +00:00
|
|
|
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
|
|
|
|
Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
|
|
|
|
|
|
|
Write-Output "Extracting..."
|
2022-12-01 07:49:55 +00:00
|
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem ;
|
2022-11-14 21:41:36 +00:00
|
|
|
[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD")
|
|
|
|
|
|
|
|
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..."
|
|
|
|
Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore
|
|
|
|
New-Item -Path 'build-release' -ItemType Directory
|
|
|
|
Set-Location -Path 'build-release'
|
2022-11-14 21:41:36 +00:00
|
|
|
|
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 `
|
|
|
|
-DCMAKE_INSTALL_PREFIX="stage3-release" `
|
|
|
|
-DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
|
|
|
|
-DCMAKE_BUILD_TYPE=Release `
|
|
|
|
-DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
|
|
|
|
-DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
|
|
|
|
-DZIG_TARGET_TRIPLE="$TARGET" `
|
|
|
|
-DZIG_TARGET_MCPU="$MCPU" `
|
2023-07-22 04:29:42 +01:00
|
|
|
-DZIG_STATIC=ON `
|
|
|
|
-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..."
|
|
|
|
& "stage3-release\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 `
|
|
|
|
-Denable-symlinks-windows
|
|
|
|
CheckLastExitCode
|
2022-12-06 19:19:24 +00:00
|
|
|
|
2023-01-21 21:14:52 +00:00
|
|
|
Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
2023-01-08 07:35:38 +00:00
|
|
|
& "stage3-release\bin\zig.exe" test `
|
|
|
|
..\test\behavior.zig `
|
|
|
|
--zig-lib-dir "$ZIG_LIB_DIR" `
|
|
|
|
-I..\test `
|
|
|
|
-I..\lib `
|
|
|
|
-ofmt=c `
|
2023-01-21 21:14:52 +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
|
|
|
|
|
|
|
|
& "stage3-release\bin\zig.exe" build-obj `
|
|
|
|
--zig-lib-dir "$ZIG_LIB_DIR" `
|
|
|
|
-ofmt=c `
|
|
|
|
-OReleaseSmall `
|
|
|
|
--name compiler_rt `
|
2023-01-21 21:14:52 +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 `
|
|
|
|
--mod root ..\lib\compiler_rt.zig `
|
|
|
|
--mod build_options config.zig
|
2023-01-08 07:35:38 +00:00
|
|
|
CheckLastExitCode
|
|
|
|
|
|
|
|
Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
|
|
|
CheckLastExitCode
|
|
|
|
|
|
|
|
Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" `
|
|
|
|
-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
|