From b94c52cbbf18ff93c79533f943446f182a14c93a Mon Sep 17 00:00:00 2001 From: Vlad-Stefan Harbuz Date: Thu, 6 Jan 2022 13:31:09 +0100 Subject: [PATCH] correctly parse arguments in build.sh Signed-off-by: Vlad-Stefan Harbuz --- build.sh | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 84214c1..9f16aac 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,37 @@ #!/bin/sh -e +format=0 +console=0 +debug=0 +norun=0 + +while [ $# -gt 0 ]; do + case $1 in + --format) + format=1 + shift + ;; + + --console) + console=1 + shift + ;; + + --debug) + debug=1 + shift + ;; + + --no-run) + norun=1 + shift + ;; + + *) + shift + esac +done + echo "Cleaning.." rm -f ./bin/uxnasm rm -f ./bin/uxnemu @@ -10,7 +42,7 @@ rm -f ./bin/asma.rom # When clang-format is present -if [ "${1}" = '--format' ]; +if [ $format = 1 ]; then echo "Formatting.." clang-format -i src/uxn.h @@ -37,7 +69,7 @@ CC="${CC:-cc}" CFLAGS="${CFLAGS:--std=c89 -Wall -Wno-unknown-pragmas}" case "$(uname -s 2>/dev/null)" in MSYS_NT*|MINGW*) # MSYS2 on Windows - if [ "${1}" = '--console' ]; + if [ $console = 1 ]; then UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs | sed -e 's/ -mwindows//g')" else @@ -53,7 +85,7 @@ Linux|*) ;; esac -if [ "${1}" = '--debug' ]; +if [ $debug = 1 ]; then echo "[debug]" CFLAGS="${CFLAGS} -DDEBUG -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined" @@ -80,7 +112,7 @@ echo "Assembling(boot+hypervisor).." echo "Assembling(asma).." ./bin/uxnasm projects/software/asma.tal bin/asma.rom -if [ "${1}" = '--no-run' ]; then exit; fi +if [ $norun = 1 ]; then exit; fi echo "Assembling(piano).." bin/uxncli bin/asma.rom projects/examples/demos/piano.tal bin/piano.rom 2> bin/piano.log