zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

aarch64-windows.ps1 (3174B) - Raw


      1 $TARGET = "$($Env:ARCH)-windows-gnu"
      2 $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.15.0-dev.233+7c85dc460"
      3 $MCPU = "baseline"
      4 $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 $ZIG_LIB_DIR = "$(Get-Location)\lib"
      8 
      9 if (!(Test-Path "..\$ZIG_LLVM_CLANG_LLD_NAME.zip")) {
     10     Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
     11     Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "..\$ZIG_LLVM_CLANG_LLD_NAME.zip"
     12 
     13     Write-Output "Extracting..."
     14     Add-Type -AssemblyName System.IO.Compression.FileSystem ;
     15     [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD\..\$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD\..")
     16 }
     17 
     18 function CheckLastExitCode {
     19     if (!$?) {
     20         exit 1
     21     }
     22     return 0
     23 }
     24 
     25 # Make the `zig version` number consistent.
     26 # This will affect the `zig build` command below which uses `git describe`.
     27 git fetch --tags
     28 
     29 if ((git rev-parse --is-shallow-repository) -eq "true") {
     30     git fetch --unshallow # `git describe` won't work on a shallow repo
     31 }
     32 
     33 # Override the cache directories because they won't actually help other CI runs
     34 # which will be testing alternate versions of zig, and ultimately would just
     35 # fill up space on the hard drive for no reason.
     36 $Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
     37 $Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
     38 
     39 Write-Output "Building from source..."
     40 New-Item -Path 'build-release' -ItemType Directory
     41 Set-Location -Path 'build-release'
     42 
     43 # CMake gives a syntax error when file paths with backward slashes are used.
     44 # Here, we use forward slashes only to work around this.
     45 & cmake .. `
     46   -GNinja `
     47   -DCMAKE_INSTALL_PREFIX="stage3-release" `
     48   -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
     49   -DCMAKE_BUILD_TYPE=Release `
     50   -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
     51   -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
     52   -DCMAKE_AR="$ZIG" `
     53   -DZIG_AR_WORKAROUND=ON `
     54   -DZIG_TARGET_TRIPLE="$TARGET" `
     55   -DZIG_TARGET_MCPU="$MCPU" `
     56   -DZIG_STATIC=ON `
     57   -DZIG_NO_LIB=ON
     58 CheckLastExitCode
     59 
     60 ninja install
     61 CheckLastExitCode
     62 
     63 Write-Output "Main test suite..."
     64 & "stage3-release\bin\zig.exe" build test docs `
     65   --zig-lib-dir "$ZIG_LIB_DIR" `
     66   --search-prefix "$PREFIX_PATH" `
     67   -Dstatic-llvm `
     68   -Dskip-non-native `
     69   -Denable-symlinks-windows
     70 CheckLastExitCode
     71 
     72 # Ensure that stage3 and stage4 are byte-for-byte identical.
     73 Write-Output "Build and compare stage4..."
     74 & "stage3-release\bin\zig.exe" build `
     75   --prefix stage4-release `
     76   -Denable-llvm `
     77   -Dno-lib `
     78   -Doptimize=ReleaseFast `
     79   -Dstrip `
     80   -Dtarget="$TARGET" `
     81   -Duse-zig-libcxx `
     82   -Dversion-string="$(stage3-release\bin\zig version)"
     83 CheckLastExitCode
     84 
     85 # Compare-Object returns an error code if the files differ.
     86 Write-Output "If the following command fails, it means nondeterminism has been"
     87 Write-Output "introduced, making stage3 and stage4 no longer byte-for-byte identical."
     88 Compare-Object (Get-Content stage3-release\bin\zig.exe) (Get-Content stage4-release\bin\zig.exe)
     89 CheckLastExitCode