Cubyz/scripts/install_compiler_windows.bat
IntegratedQuantum aae66ea77f
Update Zig to use the new Writergate version (#1664)
For reference: https://github.com/ziglang/zig/pull/24329

some commits have been extracted from #1583, but the x86_64 backend has
been disabled due to its horrible performance.

Remaining work:
- [x] Wait for official builds on ziglang.org and upload them to our
repository
- [x] Add workaround for https://github.com/ziglang/zig/pull/24466
- [x] Fix TODO comment about ANSI support in stdout
- [x] Check for compile-time performance changes → it went from 13.1 to
11.9 seconds 🎉
2025-07-15 23:00:29 +02:00

46 lines
1.7 KiB
Batchfile

@echo off
echo Detecting Zig compiler...
set /p baseVersion=<".zig-version"
IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set arch=x86_64)
IF "%PROCESSOR_ARCHITECTURE%"=="IA64" (set arch=x86_64)
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (set arch=x86)
IF "%PROCESSOR_ARCHITECTURE%"=="ARM64" (set arch=aarch64)
IF "%arch%"=="" (
echo Machine architecture could not be recognized: %arch%. Please file a bug report.
echo Defaulting architecture to x86_64.
set arch=x86_64
)
set version=zig-%arch%-windows-%baseVersion%
if not exist compiler mkdir compiler
if not exist compiler\version.txt copy NUL compiler\version.txt >NUL
set currVersion=
set /p currVersion=<"compiler\version.txt"
if not "%version%" == "%currVersion%" (
echo Your Zig is the wrong version.
echo Deleting current Zig installation...
if exist compiler\zig rmdir /s /q compiler\zig
echo Downloading %version%...
powershell -Command $ProgressPreference = 'SilentlyContinue'; "Invoke-WebRequest -uri https://github.com/PixelGuys/Cubyz-zig-versions/releases/download/%baseVersion%/%version%.zip -OutFile compiler\archive.zip"
if errorlevel 1 (
echo Failed to download the Zig compiler.
exit /b 1
)
echo Extracting zip file...
C:\Windows\System32\tar.exe -xf compiler\archive.zip --directory compiler
ren compiler\%version% zig
del compiler\archive.zip
echo Patching lib/std/zig/render.zig...
powershell -Command $ProgressPreference = 'SilentlyContinue'; "Invoke-WebRequest -uri https://github.com/PixelGuys/Cubyz-std-lib/releases/download/%baseVersion%/render.zig -OutFile compiler\zig\lib\std\zig\render.zig"
echo %version%> compiler\version.txt
echo Done updating Zig.
) ELSE (
echo Zig compiler is valid.
)