Skip to content

Instantly share code, notes, and snippets.

@matu3ba
Created December 22, 2022 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matu3ba/b3443a0a88b093e77d8eb9b78d0fc84e to your computer and use it in GitHub Desktop.
Save matu3ba/b3443a0a88b093e77d8eb9b78d0fc84e to your computer and use it in GitHub Desktop.
Build Zig with previous Zig version by parsing devkit.
# powershell script to parse devkit version and install Zig
# assume: 1. devkit in dir devkit, zig in dir zig in same dir
# 2. powershell scripts executable (execution in shell):
# Get-Content bZig.ps1 | PowerShell.exe -noprofile -
# parse pip install
$draftpathninja = pip show ninja
$pathninja = $draftpathninja[7].Split(" ")[1]
$joinpath = -join($pathninja, "\ninja\data\bin")
$env:Path += $joinpath
$joinpath
$env:Path
function CheckLastExitCode {
if (!$?) {
exit 1
}
return 0
}
# replace with other dir, if needed
$COMMON_DIR = -join('C:\Users\', $env:UserName, '\Desktop')
Set-Location -Path $COMMON_DIR
$line = Get-ChildItem -Path .\zig\ci\x86_64-windows.ps1 -Recurse | Select-String -Pattern 'ZIG_LLVM_CLANG_LLD_NAME ='
$splitted = $line -split "-"
$version_raw = -join($splitted[3], "-", $splitted[4])
$VERSION = $version_raw.Substring(0,$version_raw.Length-1)
$TARGET = "x86_64-windows-gnu"
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-$VERSION"
$MCPU = "baseline"
$DEVKIT = "$(Get-Location)\devkit\$ZIG_LLVM_CLANG_LLD_NAME"
$ZIG = "$PREFIX_PATH\bin\zig.exe"
$ZIG_LIB_DIR = "$(Get-Location)\zig\lib"
Set-Location -Path 'zig'
& $DEVKIT\bin\zig.exe build -p stage3 --search-prefix $DEVKIT --zig-lib-dir lib -Dstatic-llvm -Duse-zig-libcxx -Dtarget=x86_64-windows-gnu
CheckLastExitCode
@matu3ba
Copy link
Author

matu3ba commented Dec 22, 2022

TODO: fixup overly long default zig paths for devkit to prevent too long lines.
Could be thats the reason why compilation doesnt work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment