spl

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 010c900acb10cabe9de78210c1b4619305cd7560
parent 41707427f8eebbd641f179f9510f194907da9cda
Author: Brian Swetland <swetland@frotz.net>
Date:   Sat, 14 Oct 2023 14:02:05 -0700

tidy things up

- move all bootstrap compiler source and helper files under bootstrap/...
- move build tooling from tools/... to build/...
- move compiler source into compiler/...
- remove bin directory (all build products go into out/... now)

Diffstat:
MMakefile | 20++++++++++----------
Rcompiler0.c -> bootstrap/compiler0.c | 0
Rinc/builtin.type.h -> bootstrap/inc/builtin.type.h | 0
Rinc/library.impl.c -> bootstrap/inc/library.impl.c | 0
Rinc/library.impl.h -> bootstrap/inc/library.impl.h | 0
Abuild/compile0 | 11+++++++++++
Rtools/compile1 -> build/compile1 | 0
Abuild/runtest0 | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rcompiler.spl -> compiler/compiler.spl | 0
Dtools/compile0 | 11-----------
Dtools/runtest0 | 54------------------------------------------------------
11 files changed, 75 insertions(+), 75 deletions(-)

diff --git a/Makefile b/Makefile @@ -2,16 +2,16 @@ .NOTINTERMEDIATE: %.c %.h -all: bin/compiler0 +all: out/compiler0 test: out/test/summary.txt -bin/compiler0: compiler0.c - @mkdir -p bin - gcc -Wall -O0 -g -o bin/compiler0 compiler0.c +out/compiler0: bootstrap/compiler0.c + @mkdir -p out + gcc -Wall -O0 -g -o out/compiler0 bootstrap/compiler0.c -out/compiler.bin: compiler.spl bin/compiler0 - ./tools/compile0 compiler.spl +out/compiler.bin: compiler.spl out/compiler0 + ./build/compile0 compiler.spl clean:: rm -rf bin out @@ -21,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/runtest0 tools/compile0 -TESTDEPS += $(wildcard inc/*.h) $(wildcard inc/*.c) +TESTDEPS := out/compiler0 build/runtest0 build/compile0 +TESTDEPS += $(wildcard bootstrap/inc/*.h) $(wildcard bootstrap/inc/*.c) out/test/%.txt: test/%.spl test/%.log $(TESTDEPS) @mkdir -p out/test @rm -f $@ - @tools/runtest0 $< $@ + @build/runtest0 $< $@ out/test/%.txt: test/%.spl $(TESTDEPS) @mkdir -p out/test @rm -f $@ - @tools/runtest0 $< $@ + @build/runtest0 $< $@ SRCTESTS := $(sort $(wildcard test/*.spl)) diff --git a/compiler0.c b/bootstrap/compiler0.c diff --git a/inc/builtin.type.h b/bootstrap/inc/builtin.type.h diff --git a/inc/library.impl.c b/bootstrap/inc/library.impl.c diff --git a/inc/library.impl.h b/bootstrap/inc/library.impl.h diff --git a/build/compile0 b/build/compile0 @@ -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 + +mkdir -p $(dirname ${out}) +out/compiler0 -o ${out} ${src} +gcc -g -O0 -Wall -I. -Ibootstrap/inc -Iout -o ${out}.bin ${out}.impl.c diff --git a/tools/compile1 b/build/compile1 diff --git a/build/runtest0 b/build/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 build/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 + diff --git a/compiler.spl b/compiler/compiler.spl diff --git a/tools/compile0 b/tools/compile0 @@ -1,11 +0,0 @@ -#!/bin/bash -e - -src="$1" -base="${src%.spl}" -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 -g -O0 -Wall -I. -Iinc -Iout -o ${out}.bin ${out}.impl.c diff --git a/tools/runtest0 b/tools/runtest0 @@ -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/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 -