From 8aaa9f585cb907b12c7d2d1fbbbf36daa7668bbe Mon Sep 17 00:00:00 2001 From: Samuel Meenzen Date: Tue, 24 Oct 2023 15:43:17 +0200 Subject: [PATCH] Add run_release script (#152) * Add run_release script * Update README to use the run_release scripts --- .zig-version | 1 + README.md | 3 +-- run.bat | 3 ++- run.sh | 17 ++++++++++------- run_release.bat | 3 +++ run_release.sh | 3 +++ 6 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .zig-version create mode 100644 run_release.bat create mode 100755 run_release.sh diff --git a/.zig-version b/.zig-version new file mode 100644 index 00000000..57f5993e --- /dev/null +++ b/.zig-version @@ -0,0 +1 @@ +0.12.0-dev.983+78f2ae7f2 \ No newline at end of file diff --git a/README.md b/README.md index 64c7dda4..0448dbb4 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,7 @@ Otherwise you can ### Compile Cubyz from source 1. Install git 2. Clone this repository `git clone https://github.com/pixelguys/Cubyz` -3. Run `run.sh` (Linux) or `run.bat` (Windows) -4. If the game is too slow, run it in release: `run.sh -Doptimize=ReleaseFast` (Linux) or `run.bar -Doptimize=ReleaseFast` (Windows) +3. Run `run_release.sh` (Linux) or `run_release.bat` (Windows) #### Note for Linux Users: I also had to install a few `-dev` packages for the compilation to work: ``` diff --git a/run.bat b/run.bat index 30d4ed51..2f9ee9a1 100644 --- a/run.bat +++ b/run.bat @@ -1,6 +1,7 @@ @echo off -set version=zig-windows-x86_64-0.12.0-dev.983+78f2ae7f2 +set /p baseVersion=<".zig-version" +set version=zig-windows-x86_64-%baseVersion% if not exist compiler mkdir compiler if not exist compiler\version.txt copy NUL compiler\version.txt >NUL diff --git a/run.sh b/run.sh index 29f1a302..66ef703a 100755 --- a/run.sh +++ b/run.sh @@ -1,21 +1,24 @@ #!/bin/bash -version=zig-linux-x86_64-0.12.0-dev.983+78f2ae7f2 +BASE_VERSION=$(< .zig-version) +VERSION=zig-linux-x86_64-$BASE_VERSION mkdir -p compiler/zig touch compiler/version.txt -if [[ $(< compiler/version.txt) != "$version" ]]; then + +CURRENT_VERSION=$(< compiler/version.txt) + +if [[ "$CURRENT_VERSION" != "$VERSION" ]]; then echo "Deleting old 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 + echo "Downloading $VERSION..." + wget -O compiler/archive.tar.xz https://ziglang.org/builds/"$VERSION".tar.xz echo "Extracting tar file..." tar --xz -xf compiler/archive.tar.xz --directory compiler/zig --strip-components 1 echo "Done." rm compiler/archive.tar.xz - rm compiler/version.txt - printf "$version" >> compiler/version.txt + echo "$VERSION" > compiler/version.txt fi -./compiler/zig/zig build run $@ \ No newline at end of file +./compiler/zig/zig build run "$@" \ No newline at end of file diff --git a/run_release.bat b/run_release.bat new file mode 100644 index 00000000..32e4aa6b --- /dev/null +++ b/run_release.bat @@ -0,0 +1,3 @@ +@echo off + +.\run.bat -Doptimize=ReleaseFast %* \ No newline at end of file diff --git a/run_release.sh b/run_release.sh new file mode 100755 index 00000000..d4184ae8 --- /dev/null +++ b/run_release.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./run.sh -Doptimize=ReleaseFast "$@" \ No newline at end of file