| ... | @@ -1,17 +1,20 @@ | ... | @@ -1,17 +1,20 @@ |
| 1 | $TARGET = "$($Env:ARCH)-windows-gnu" | 1 | $TARGET = "$($Env:ARCH)-windows-gnu" |
| 2 | $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.448+e6e459e9e" | 2 | $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.448+e6e459e9e" |
| 3 | $MCPU = "baseline" | | |
| 4 | $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip" | 3 | $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 | | 4 | |
| 8 | Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" | 5 | Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" |
| | 6 | |
| 9 | Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip" | 7 | Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip" |
| 10 | | 8 | |
| 11 | Write-Output "Extracting..." | 9 | Write-Output "Extracting..." |
| | 10 | |
| 12 | Add-Type -AssemblyName System.IO.Compression.FileSystem ; | 11 | Add-Type -AssemblyName System.IO.Compression.FileSystem ; |
| 13 | [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD") | 12 | [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD") |
| 14 | | 13 | |
| | 14 | Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib" |
| | 15 | Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release" |
| | 16 | Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME" |
| | 17 | |
| 15 | function CheckLastExitCode { | 18 | function CheckLastExitCode { |
| 16 | if (!$?) { | 19 | if (!$?) { |
| 17 | exit 1 | 20 | exit 1 |
| ... | @@ -28,41 +31,32 @@ if ((git rev-parse --is-shallow-repository) -eq "true") { | ... | @@ -28,41 +31,32 @@ if ((git rev-parse --is-shallow-repository) -eq "true") { |
| 28 | git fetch --unshallow # `git describe` won't work on a shallow repo | 31 | git fetch --unshallow # `git describe` won't work on a shallow repo |
| 29 | } | 32 | } |
| 30 | | 33 | |
| 31 | Write-Output "Building from source..." | 34 | Write-Output "Building Zig..." |
| 32 | Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore | | |
| 33 | New-Item -Path 'build-release' -ItemType Directory | | |
| 34 | Set-Location -Path 'build-release' | | |
| 35 | | 35 | |
| 36 | # CMake gives a syntax error when file paths with backward slashes are used. | 36 | & "$ZIGPREFIXPATH\bin\zig.exe" build ` |
| 37 | # Here, we use forward slashes only to work around this. | 37 | --prefix "$ZIGINSTALLDIR" ` |
| 38 | & cmake .. ` | 38 | --search-prefix "$ZIGPREFIXPATH" ` |
| 39 | -GNinja ` | 39 | --zig-lib-dir "$ZIGLIBDIR" ` |
| 40 | -DCMAKE_INSTALL_PREFIX="stage3-release" ` | 40 | -Dstatic-llvm ` |
| 41 | -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" ` | 41 | -Drelease ` |
| 42 | -DCMAKE_BUILD_TYPE=Release ` | 42 | -Duse-zig-libcxx ` |
| 43 | -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" ` | 43 | -Dtarget="$TARGET" |
| 44 | -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" ` | | |
| 45 | -DZIG_TARGET_TRIPLE="$TARGET" ` | | |
| 46 | -DZIG_TARGET_MCPU="$MCPU" ` | | |
| 47 | -DZIG_STATIC=ON | | |
| 48 | CheckLastExitCode | 44 | CheckLastExitCode |
| 49 | | 45 | |
| 50 | ninja install | 46 | Write-Output " zig build test docs..." |
| 51 | CheckLastExitCode | | |
| 52 | | 47 | |
| 53 | Write-Output "Main test suite..." | 48 | & "$ZIGINSTALLDIR\bin\zig.exe" build test docs ` |
| 54 | & "stage3-release\bin\zig.exe" build test docs ` | 49 | --search-prefix "$ZIGPREFIXPATH" ` |
| 55 | --zig-lib-dir "..\lib" ` | 50 | -Dstatic-llvm ` |
| 56 | --search-prefix "../$ZIG_LLVM_CLANG_LLD_NAME" ` | 51 | -Dskip-non-native ` |
| 57 | -Dstatic-llvm ` | 52 | -Denable-symlinks-windows |
| 58 | -Dskip-non-native ` | | |
| 59 | -Denable-symlinks-windows | | |
| 60 | CheckLastExitCode | 53 | CheckLastExitCode |
| 61 | | 54 | |
| 62 | Write-Output "Testing Autodocs..." | 55 | # Produce the experimental std lib documentation. |
| 63 | & "stage3-release\bin\zig.exe" test "..\lib\std\std.zig" ` | 56 | Write-Output "zig test std/std.zig..." |
| 64 | --zig-lib-dir "..\lib" ` | 57 | |
| | 58 | & "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" ` |
| | 59 | --zig-lib-dir "$ZIGLIBDIR" ` |
| 65 | -femit-docs ` | 60 | -femit-docs ` |
| 66 | -fno-emit-bin | 61 | -fno-emit-bin |
| 67 | CheckLastExitCode | 62 | CheckLastExitCode |
| 68 | | | |