From e882a090998359987243de8ac5ae7f0580499be8 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sat, 13 Aug 2022 00:28:36 +0200 Subject: [PATCH] Build system: Improve output readability and prepare for script based unit tests --- scripts/build.sh | 4 ++-- scripts/clean.sh | 2 ++ scripts/clean_dependencies.sh | 5 +++-- scripts/setup_project.sh | 15 +++++++-------- scripts/test.sh | 10 ++++++++-- scripts/test/hexnet.sh | 8 ++++++++ 6 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 scripts/test/hexnet.sh diff --git a/scripts/build.sh b/scripts/build.sh index c6bde3a..e065a78 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -33,7 +33,7 @@ fi # `.cpp` files in src/lib will be automatically picked up and compiled into # dynamically linked libraries. -echo "Building libs..." +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" @@ -55,7 +55,7 @@ wait # How to run a tool: specify the library path to use for the dynamic linker # when running a program # Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt -echo "Building tools..." +echo ">>> Building tools..." create_directory bin/tools # add compile commands to this array COMPILE_COMMANDS=( diff --git a/scripts/clean.sh b/scripts/clean.sh index 88b386f..e4f54de 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -15,6 +15,8 @@ # version 3 along with this program. # If not, see https://www.gnu.org/licenses/agpl-3.0.en.html +echo ">>> Cleaning build files..." + source scripts/lib.sh remove ./bin diff --git a/scripts/clean_dependencies.sh b/scripts/clean_dependencies.sh index ccf9009..3832ae3 100755 --- a/scripts/clean_dependencies.sh +++ b/scripts/clean_dependencies.sh @@ -17,7 +17,7 @@ source scripts/lib.sh -echo "Checking download cache for unneeded or corrupted files..." +echo ">>> Checking download cache for unneeded or corrupted files..." for file in $(ls .download_cache); do #TODO: remove if unknown shasum if grep $file scripts/setup_project.sh >/dev/null 2>&1; then @@ -32,7 +32,8 @@ for file in $(ls .download_cache); do rm ".download_cache/$file" fi done -echo "" +echo " +>>> Cleaning dependencies..." remove ./dependencies create_directory ./dependencies diff --git a/scripts/setup_project.sh b/scripts/setup_project.sh index b3a87b7..39ce6e4 100755 --- a/scripts/setup_project.sh +++ b/scripts/setup_project.sh @@ -72,9 +72,7 @@ function download { fi } -echo "Cleaning build files..." scripts/clean.sh -echo "Cleaning dependencies..." scripts/clean_dependencies.sh set -e # failures are not acceptable here @@ -82,20 +80,21 @@ 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.7.1.tar.gz dependencies/tmp/sockpp.tar.gz 2e023528bebbd2ac083fc91fbe6d5c4158c3336bedbcff48f594f3b28f53b940 -echo -n "Extracting tiny-utf8... " +echo -n ">>> Extracting tiny-utf8... " gzip -d dependencies/tmp/tiny-utf8.tar.gz tar -xf dependencies/tmp/tiny-utf8.tar -C dependencies -echo "done." +echo "done" -echo -n "Extracting sockpp... " +echo -n ">>> Extracting sockpp... " gzip -d dependencies/tmp/sockpp.tar.gz tar -xf dependencies/tmp/sockpp.tar -C dependencies -echo "done." -echo -n "Building sockpp... " +echo "done" + +echo ">>> Building sockpp... " pushd dependencies/sockpp-0.7.1/ >/dev/null 2>&1 cmake -Bbuild . cmake --build build popd >/dev/null 2>&1 -echo "done." +echo ">>> Cleaning up..." remove dependencies/tmp diff --git a/scripts/test.sh b/scripts/test.sh index d66b92f..dd0e1ad 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -27,7 +27,7 @@ echo "$LD_LIBRARY_PATH" create_directory bin/test -echo "Building tests..." +echo ">>> Building tests..." # add compile commands to this array COMPILE_COMMANDS=( @@ -45,9 +45,15 @@ done wait -echo "Running tests..." +echo ">>> Running tests..." +# explicitly allow commands to fail at this stage set +e + for test in $(ls bin/test); do bin/test/$test done + +for test in $(ls scripts/test); do + scripts/test/$test +done diff --git a/scripts/test/hexnet.sh b/scripts/test/hexnet.sh new file mode 100644 index 0000000..8c59a2a --- /dev/null +++ b/scripts/test/hexnet.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +echo "################################################################################ +Testing hexnet +################################################################################" + +echo "Test not yet implemented." +#TODO: implement unit test after merging back with master