commit 1048fd39d56027d7931cb24f80a5d57636eb9b01 parent 4e4a093f8fb0ae5ca88b2f93dfaa4a1272d099d3 Author: Brian Swetland <swetland@frotz.net> Date: Thu, 12 Oct 2023 13:23:36 -0700 tools: make tools/compile more useful standalone Diffstat:
M | tools/compile | | | 11 | +++++++++-- |
M | tools/runtest | | | 2 | +- |
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/tools/compile b/tools/compile @@ -1,4 +1,11 @@ #!/bin/bash -e -bin/compiler0 -o $2 $1 -gcc -Wall -I. -Iinc -Iout -o $2.bin $2.impl.c +src="$1" +base="${src%.src}" +out="out/${base}" + +if [ ! -e "${src}" ] ; then echo error: cannot find "${src}" ; exit 1 ; fi + +mkdir -p $(dirname ${out}) +bin/compiler0 -o ${out} ${src} +gcc -Wall -I. -Iinc -Iout -o ${out}.bin ${out}.impl.c diff --git a/tools/runtest b/tools/runtest @@ -13,7 +13,7 @@ msg="${txt%.txt}.msg" gold="${src%.src}.log" echo "RUNTEST: $src: compiling..." -if tools/compile "$src" "$base" 2> "$msg"; then +if tools/compile "$src" 2> "$msg"; then # success! if [[ "$txt" == *"-err"* ]]; then # but this was an error test, so...