~rabbits/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH uxn] correctly parse arguments in build.sh

Details
Message ID
<20220106123109.82716-1-vlad@vladh.net>
DKIM signature
pass
Download raw message
Patch: +36 -4
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
---
Currently, build.sh only checks the first argument and ignores the rest. This
is confusing to the user, since if the user specifies e.g. --debug --format,
as is specified in the compudanzas tutorial, the build script will silently do
the wrong thing. This patch adds proper, albeit minimal, argument parsing.

 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
@@ -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
-- 
2.30.2

[uxn/patches/.build.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CGYLDO15LX6N.2QZJNALT4O02O@cirno>
In-Reply-To
<20220106123109.82716-1-vlad@vladh.net> (view parent)
DKIM signature
missing
Download raw message
uxn/patches/.build.yml: FAILED in 53s

[correctly parse arguments in build.sh][0] from [Vlad-Stefan Harbuz][1]

[0]: https://lists.sr.ht/~rabbits/public-inbox/patches/27993
[1]: vlad@vladh.net

✗ #665194 FAILED uxn/patches/.build.yml https://builds.sr.ht/~rabbits/job/665194
Details
Message ID
<CAKis=aFVmUvq1_j4JLn9Bsk2s0_xLfdD=KmnZiweVK8mLyDnAw@mail.gmail.com>
In-Reply-To
<20220106123109.82716-1-vlad@vladh.net> (view parent)
DKIM signature
pass
Download raw message
Excellent :) thanks, merged.

On 1/6/22, Vlad-Stefan Harbuz <vlad@vladh.net> wrote:
> Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
> ---
> Currently, build.sh only checks the first argument and ignores the rest.
> This
> is confusing to the user, since if the user specifies e.g. --debug
> --format,
> as is specified in the compudanzas tutorial, the build script will silently
> do
> the wrong thing. This patch adds proper, albeit minimal, argument parsing.
>
>  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
> --
> 2.30.2
>
>
Reply to thread Export thread (mbox)