Cubyz/scripts/install_compiler_linux.sh
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

65 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
fail () {
exit 1
}
echo "Detecting Zig compiler..."
BASE_VERSION=$(< .zig-version)
case "$(uname -s)" in
"Darwin")
OS=macos;;
*)
OS=linux;;
esac
if [ -n $ARCH ]
then
case "$(uname -m)" in
"arm64" | "aarch64")
ARCH=aarch64;;
"arm*")
ARCH=armv7a;;
"amd64" | "x86_64")
ARCH=x86_64;;
"x86*")
ARCH=x86;;
*)
echo "Machine architecture could not be recognized ($(uname -m)). Report this bug with the result of \`uname -m\` and your preferred Zig release name."
echo "Defaulting architecture to x86_64."
ARCH=x86_64;;
esac
fi
VERSION=zig-$ARCH-$OS-$BASE_VERSION
mkdir -p compiler/zig
touch compiler/version.txt
CURRENT_VERSION=$(< compiler/version.txt)
if [[ "$CURRENT_VERSION" != "$VERSION" ]]; then
echo "Your Zig is the wrong version."
echo "Deleting current Zig installation..."
rm -r compiler/zig
mkdir compiler/zig
echo "Downloading $VERSION..."
wget -O compiler/archive.tar.xz https://github.com/PixelGuys/Cubyz-zig-versions/releases/download/$BASE_VERSION/"$VERSION".tar.xz
if [ $? != 0 ]
then
echo "Failed to download the Zig compiler."
fail
fi
echo "Extracting tar file..."
tar --xz -xf compiler/archive.tar.xz --directory compiler/zig --strip-components 1
rm compiler/archive.tar.xz
echo "Patching lib/std/zig/render.zig..."
wget -O compiler/zig/lib/std/zig/render.zig https://github.com/PixelGuys/Cubyz-std-lib/releases/download/$BASE_VERSION/render.zig
echo "$VERSION" > compiler/version.txt
echo "Done updating Zig."
else
echo "Zig compiler is valid."
fi