diff --git a/scripts/mk b/scripts/mk new file mode 100755 index 0000000..1eff358 --- /dev/null +++ b/scripts/mk @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +$([ -x "$(command -v bear)" ] && echo 'bear -- ') make $@ + diff --git a/scripts/test b/scripts/test new file mode 100755 index 0000000..2e00268 --- /dev/null +++ b/scripts/test @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +USAGE='test program [[run]-[valgrind]] ...' +if [[ "$1" =~ help ]]; then + echo "$USAGE" + exit 0 +fi + +# === ARGPARSE +MODE= +REBUILD=true +VALGRIND=false +TARGET=debug +PROGRAM="$1" +MODE_ARG="$2" + +if [[ "$MODE_ARG" =~ run.* ]]; then + MODE="$MODE_ARG" + REBUILD=false +fi +if [[ "$MODE_ARG" =~ .*valgrind ]]; then + MODE="$MODE_ARG" + VALGRIND=true + PROXY='valgrind -s --log-file=logs/valgrind.log --leak-check=full --show-leak-kinds=all' + TARGET=debug +fi + + +if [[ -n "$MODE" ]]; then + shift +fi + +# === MAIN +if [[ "$REBUILD" == true ]]; then + make clean $TARGET +fi + +if [[ ! -x "$PROGRAM" ]]; then + echo "[!] Invalid program: \"$PROGRAM\"" + echo "$USAGE" + exit 1 +fi + +mkdir -p logs +LD_LIBRARY_PATH=./lib $PROXY "$PROGRAM" $@ + +# If ncurses doesn't close gracefully, termios attributes +# will require reinitialisation (not a reset! don't clear the screen!) +tput init