From 8b13f72acc6a65d64d42d35b2b58ad9a002d8978 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sat, 8 Jun 2024 14:26:48 +0200 Subject: [PATCH] tools: Add zlibutil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Third time's the charm... Editing this commit again to resolve merge conflicts. - Bodge Splitting one of Joca’s commits by topic - Bodge Add zlibutil.cpp and zlib to the project's dependencies. - Joca --- scripts/build.sh | 20 +++++++++++++++----- scripts/clean.sh | 1 + scripts/setup_project.sh | 12 +++++------- src/tools/zlibutil.cpp | 3 ++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 3e90458..36d7f79 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -35,10 +35,20 @@ fi # dynamically linked libraries. echo ">>> Building libs..." create_directory bin/lib -for lib in $(find ./src/lib -name "*.cpp"); do - COMPILE_COMMAND="$CXX_WITH_FLAGS -I ./include -fPIC -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib" - echo $COMPILE_COMMAND - $COMPILE_COMMAND & +COMPILE_COMMANDS=( + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/net/client.so ./src/lib/net/client.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/net/server.so ./src/lib/net/server.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/cli.so ./src/lib/cli.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/file.so ./src/lib/file.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/game/block.so ./src/lib/game/block.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/game/entity.so ./src/lib/game/entity.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/nbt.so ./src/lib/nbt.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/region.so ./src/lib/region.cpp" + "$CXX_WITH_FLAGS -I ./include -fPIC -shared -l:libz.so -o ./bin/lib/zlibutil.so ./src/lib/zlibutil.cpp" +) +for command in ${!COMPILE_COMMANDS[@]}; do + echo "${COMPILE_COMMANDS[command]}" + ${COMPILE_COMMANDS[command]} & $WAIT_ANYWAY done @@ -62,7 +72,7 @@ COMPILE_COMMANDS=( "$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:cli.so -o bin/tools/dumpnbt" "$CXX_WITH_FLAGS src/tools/arraydump.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -o bin/tools/arraydump" "$CXX_WITH_FLAGS src/tools/baseconvert.cpp -I./include -Lbin/lib -l:cli.so -o bin/tools/baseconvert" - "$CXX_WITH_FLAGS src/tools/zlibutil.cpp -I./include -Lbin/lib -l:cli.so -l:libz.so -l:file.so -l:zlibutil.so -o bin/tools/zlibutil" + "$CXX_WITH_FLAGS src/tools/zlibutil.cpp -I./include -Lbin/lib -l:cli.so -l:file.so -l:zlibutil.so -l:libz.so -o bin/tools/zlibutil" "$CXX_WITH_FLAGS -pthread src/tools/hexnet.cpp -I./include -Lbin/lib -l:cli.so -l:libsockpp.so -o bin/tools/hexnet" "$CXX_WITH_FLAGS -DFOSSVG_DEBUG src/fossvg.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -lglfw -lvulkan -o bin/fossvg" "$CXX_WITH_FLAGS src/fossvgd.cpp -I./include -Lbin/lib -l:cli.so -o bin/fossvgd" diff --git a/scripts/clean.sh b/scripts/clean.sh index 09f86cd..d67aa2b 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -39,6 +39,7 @@ fi ln -vs ../dependencies/sockpp-0.8.1/include/sockpp/ ./include/ ln -vs ../dependencies/tiny-utf8-4.4.3/include/tinyutf8/ ./include/ +ln -vs ../dependencies/zlib-1.3.1/ ./include/zlib create_file ./bin/.placeholder create_file ./include/.placeholder diff --git a/scripts/setup_project.sh b/scripts/setup_project.sh index a204509..b079399 100755 --- a/scripts/setup_project.sh +++ b/scripts/setup_project.sh @@ -79,7 +79,7 @@ set -e # failures are not acceptable here create_directory dependencies/tmp download https://github.com/DuffsDevice/tiny-utf8/archive/refs/tags/v4.4.3.tar.gz dependencies/tmp/tiny-utf8.tar.gz 8e3f61651909c9f3105d3501932a96aa65733127fb6e7cf94cb1b0a2dff42c8f download https://github.com/fpagliughi/sockpp/archive/refs/tags/v0.8.1.tar.gz dependencies/tmp/sockpp.tar.gz a8aedff8bd8c1da530b91be650352008fddabc9f1df0d19701d76cbc359c8651 -download https://www.zlib.net/zlib-1.3.tar.gz dependencies/tmp/zlib-1.3.tar.gz ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e +download https://www.zlib.net/zlib-1.3.1.tar.xz dependencies/tmp/zlib.tar.xz 38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32 #TODO: figure out how to cache shaderc #also TODO: target a specific commit @@ -97,11 +97,8 @@ tar -xf dependencies/tmp/sockpp.tar -C dependencies echo "done" echo -n ">>> Extracting zlib... " -gzip -d dependencies/tmp/zlib-1.3.tar.gz -tar -xf dependencies/tmp/zlib-1.3.tar -C dependencies -cd include/ -ln -vs ../dependencies/zlib-1.3/ zlib -cd .. +xz -d dependencies/tmp/zlib.tar.xz +tar -xf dependencies/tmp/zlib.tar -C dependencies echo "done" echo ">>> Building sockpp..." @@ -148,9 +145,10 @@ cp -v "dependencies/tmp/shaderc/$SHADERC_BUILD/glslc/glslc" dependencies/shaderc echo ">>> done" echo ">>> Building zlib..." -cd dependencies/zlib-1.3/ +pushd dependencies/zlib-1.3.1/ ./configure make +popd echo "done" echo ">>> Cleaning up..." diff --git a/src/tools/zlibutil.cpp b/src/tools/zlibutil.cpp index 97cdfe0..4336a05 100644 --- a/src/tools/zlibutil.cpp +++ b/src/tools/zlibutil.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "../lib/cli.hpp" #include "../lib/file.hpp" @@ -32,7 +33,7 @@ #define EXIT_RUNTIME 1 #define EXIT_USAGE 2 - +#define CHUNK_SIZE 16384 // Chunk size /* Finnaly, the main file