commit 41707427f8eebbd641f179f9510f194907da9cda
parent b4049a8f6016661e0264a4f1015e678e95a5d5b5
Author: Brian Swetland <swetland@frotz.net>
Date: Sat, 14 Oct 2023 13:43:01 -0700
build: tooling for compiler0 vs compiler1
Diffstat:
5 files changed, 71 insertions(+), 57 deletions(-)
diff --git a/Makefile b/Makefile
@@ -10,6 +10,9 @@ bin/compiler0: compiler0.c
@mkdir -p bin
gcc -Wall -O0 -g -o bin/compiler0 compiler0.c
+out/compiler.bin: compiler.spl bin/compiler0
+ ./tools/compile0 compiler.spl
+
clean::
rm -rf bin out
@@ -18,18 +21,18 @@ clean::
# fail to be compiled by the rule that depends on spl+log *or*
# we fail to depend on the .log for tests with both...
-TESTDEPS := bin/compiler0 tools/runtest tools/compile
+TESTDEPS := bin/compiler0 tools/runtest0 tools/compile0
TESTDEPS += $(wildcard inc/*.h) $(wildcard inc/*.c)
out/test/%.txt: test/%.spl test/%.log $(TESTDEPS)
@mkdir -p out/test
@rm -f $@
- @tools/runtest $< $@
+ @tools/runtest0 $< $@
out/test/%.txt: test/%.spl $(TESTDEPS)
@mkdir -p out/test
@rm -f $@
- @tools/runtest $< $@
+ @tools/runtest0 $< $@
SRCTESTS := $(sort $(wildcard test/*.spl))
diff --git a/tools/compile b/tools/compile0
diff --git a/tools/compile1 b/tools/compile1
@@ -0,0 +1,11 @@
+#!/bin/bash -e
+
+src="$1"
+base="${src%.spl}"
+out="out/${base}"
+
+if [ ! -e "${src}" ] ; then echo error: cannot find "${src}" ; exit 1 ; fi
+
+make out/compiler.bin
+
+out/compiler.bin < ${src}
diff --git a/tools/runtest b/tools/runtest
@@ -1,54 +0,0 @@
-#!/bin/bash
-
-## Copyright 2020, Brian Swetland <swetland@frotz.net>
-## Licensed under the Apache License, Version 2.0.
-
-src="$1"
-txt="$2"
-base="${txt%.txt}"
-bin="${txt%.txt}.bin"
-lst="${txt%.txt}.lst"
-log="${txt%.txt}.log"
-msg="${txt%.txt}.msg"
-gold="${src%.spl}.log"
-
-echo "RUNTEST: $src: compiling..."
-if tools/compile "$src" 2> "$msg"; then
- # success!
- if [[ "$txt" == *"-err"* ]]; then
- # but this was an error test, so...
- echo "RUNTEST: $src: FAIL: compiler did not detect error"
- echo "FAIL: $src" > "$txt"
- else
- #echo "RUNTEST: $src: running..."
- if "$bin" > "$log"; then
- if diff "$log" "$gold" >/dev/null ; then
- echo "RUNTEST: $src: PASS"
- echo "PASS: $src" > "$txt"
- else
- echo "RUNTEST: $src: FAIL: output differs from expected"
- diff "$log" "$gold" | head
- echo "FAIL: %src" > "$txt"
- fi
- else
- echo "RUNTEST: $src: FAIL: emulator crashed"
- echo "FAIL: %src" > "$txt"
- fi
- fi
-else
- if [[ $? > 127 ]]; then
- echo "RUNTEST: $src: FAIL: compiler crashed"
- echo "FAIL: $src" > "$txt"
- cat "$msg"
- # failure
- elif [[ "$txt" == *"-err"* ]]; then
- # but this was an error test, so...
- echo "RUNTEST: $src: PASS"
- echo "PASS: $src" > "$txt"
- else
- echo "RUNTEST: $src: FAIL: compiler error"
- echo "FAIL: $src" > "$txt"
- cat "$msg"
- fi
-fi
-
diff --git a/tools/runtest0 b/tools/runtest0
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+## Copyright 2020, Brian Swetland <swetland@frotz.net>
+## Licensed under the Apache License, Version 2.0.
+
+src="$1"
+txt="$2"
+base="${txt%.txt}"
+bin="${txt%.txt}.bin"
+lst="${txt%.txt}.lst"
+log="${txt%.txt}.log"
+msg="${txt%.txt}.msg"
+gold="${src%.spl}.log"
+
+echo "RUNTEST: $src: compiling..."
+if tools/compile0 "$src" 2> "$msg"; then
+ # success!
+ if [[ "$txt" == *"-err"* ]]; then
+ # but this was an error test, so...
+ echo "RUNTEST: $src: FAIL: compiler did not detect error"
+ echo "FAIL: $src" > "$txt"
+ else
+ #echo "RUNTEST: $src: running..."
+ if "$bin" > "$log"; then
+ if diff "$log" "$gold" >/dev/null ; then
+ echo "RUNTEST: $src: PASS"
+ echo "PASS: $src" > "$txt"
+ else
+ echo "RUNTEST: $src: FAIL: output differs from expected"
+ diff "$log" "$gold" | head
+ echo "FAIL: %src" > "$txt"
+ fi
+ else
+ echo "RUNTEST: $src: FAIL: emulator crashed"
+ echo "FAIL: %src" > "$txt"
+ fi
+ fi
+else
+ if [[ $? > 127 ]]; then
+ echo "RUNTEST: $src: FAIL: compiler crashed"
+ echo "FAIL: $src" > "$txt"
+ cat "$msg"
+ # failure
+ elif [[ "$txt" == *"-err"* ]]; then
+ # but this was an error test, so...
+ echo "RUNTEST: $src: PASS"
+ echo "PASS: $src" > "$txt"
+ else
+ echo "RUNTEST: $src: FAIL: compiler error"
+ echo "FAIL: $src" > "$txt"
+ cat "$msg"
+ fi
+fi
+