Cubyz/debug_linux.sh
archbirdplus fd332139d7
Progress on making compile errors easier to debug for new users: #241, #251, #252 (#254)
* Rename run_release scripts to run_OS (#241)

* Update README with new script names (#241)

* Fix run_windows infinite loop

* Make debug_linux more verbose.

* Make windows script errors match linux

* Automatically set working directory (#252)

* Remote quotes from echo commands in run_windows

* Replace zig run with zig build run

* Replace spaces with tabs in run scripts.

* Make 'Building Cubyz' message more accurate

* Have run scripts check the machine architecture.

* Add failsafe for unrecognized architecture; erase scratch work in debug_windows

* Replace more spaces with tabs in debug_linux

* Linux run script: don't pause if debug build or NO_PAUSE

* Windows run script: do not pause in debug builds or if NO_PAUSE

* Escape a paren

* Fix x64 typo

* Delete logs about failing to build

* Use `call` to call the batch script on windows

Without `call` windows won't execute the lines after calling the batch script.

---------

Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com>
2024-01-23 19:02:51 +01:00

79 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
cd "$(dirname "$0")"
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-$OS-$ARCH-$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://ziglang.org/builds/"$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 "$VERSION" > compiler/version.txt
echo "Done updating Zig."
else
echo "Zig compiler is valid."
fi
echo "Building Zig Cubyz ($@) from source. This may take a few minutes..."
./compiler/zig/zig build "$@"
if [ $? != 0 ]
then
fail
fi
echo "Cubyz successfully built!"
echo "Launching Cubyz."
./compiler/zig/zig build run "$@"