zig

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

x86_64-windows-debug.ps1 (3716B) - 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 = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
      6 $ZIG = "$PREFIX_PATH\bin\zig.exe"
      7 $ZIG_LIB_DIR = "$(Get-Location)\lib"
      8 
      9 if (!(Test-Path "$PREFIX_PATH.zip")) {
     10     Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
     11     Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$PREFIX_PATH.zip"
     12 
     13     Write-Output "Extracting..."
     14     Add-Type -AssemblyName System.IO.Compression.FileSystem ;
     15     [System.IO.Compression.ZipFile]::ExtractToDirectory("$PREFIX_PATH.zip", "$PREFIX_PATH\..")
     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-debug' -ItemType Directory
     41 Set-Location -Path 'build-debug'
     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-debug" `
     48   -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
     49   -DCMAKE_BUILD_TYPE=Debug `
     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 -Replace "\\", "/")" `
     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-debug\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   -Dskip-release `
     70   -Denable-symlinks-windows
     71 CheckLastExitCode
     72 
     73 Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
     74 & "stage3-debug\bin\zig.exe" test `
     75   ..\test\behavior.zig `
     76   --zig-lib-dir "$ZIG_LIB_DIR" `
     77   -ofmt=c `
     78   -femit-bin="test-x86_64-windows-msvc.c" `
     79   --test-no-exec `
     80   -target x86_64-windows-msvc `
     81   -lc
     82 CheckLastExitCode
     83 
     84 & "stage3-debug\bin\zig.exe" build-obj `
     85   --zig-lib-dir "$ZIG_LIB_DIR" `
     86   -ofmt=c `
     87   -OReleaseSmall `
     88   --name compiler_rt `
     89   -femit-bin="compiler_rt-x86_64-windows-msvc.c" `
     90   --dep build_options `
     91   -target x86_64-windows-msvc `
     92   -Mroot="..\lib\compiler_rt.zig" `
     93   -Mbuild_options="config.zig"
     94 CheckLastExitCode
     95 
     96 Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
     97 CheckLastExitCode
     98 
     99 Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" `
    100   -DevCmdArguments '-arch=x64 -no_logo' `
    101   -StartInPath $(Get-Location)
    102 CheckLastExitCode
    103 
    104 Write-Output "Build and run behavior tests with msvc..."
    105 & 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
    106 CheckLastExitCode
    107 
    108 & .\test-x86_64-windows-msvc.exe
    109 CheckLastExitCode