With the new check function, this helper method doesn't make much sense to put in the standard library. To replicate the same result, we do need to expose the current line number; adding column number is a nice bonus. Also; made it a bit clearer when a check failes in it2. Also; the builtincheckfalse was not working. Also; separated out the test input file to have more data.
90 lines
2.6 KiB
Makefile
90 lines
2.6 KiB
Makefile
.SUFFIXES:
|
|
.PHONY: all clean
|
|
.PRECIOUS: build/%.it0.py build/%.it0.c
|
|
.DELETE_ON_ERROR:
|
|
|
|
PYVERSION=3.10
|
|
PYPREFIX=/usr
|
|
CYTHON=cython3
|
|
CC=gcc
|
|
|
|
# builtincheckfalse is separate since it's supposed to crash. It's a test for the test 'framework', if you will.
|
|
TESTLIST=$(shell ls *.lang0 | grep -v 'builtincheckfalse' | sed 's/.lang0//')
|
|
|
|
all: check
|
|
|
|
check: all-it0.results all-it1.results all-it2.results
|
|
! grep -v 'Success' $^
|
|
|
|
all-it0.results: $(addprefix build/,$(addsuffix .it0, $(TESTLIST))) build/builtincheckfalse.it0
|
|
-rm -f $@
|
|
cat test-input.txt | build/builtincheckfalse.it0 2> /dev/null 2>&1 | grep 'Success'
|
|
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it0 >> $@ ; echo "" >> $@ ;)
|
|
|
|
all-it1.results: $(addprefix build/,$(addsuffix .it1, $(TESTLIST))) build/builtincheckfalse.it1
|
|
-rm -f $@
|
|
cat test-input.txt | build/builtincheckfalse.it1 2> /dev/null 2>&1 | grep 'Success'
|
|
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it1 >> $@ ; echo "" >> $@ ;)
|
|
|
|
all-it2.results: $(addprefix build/,$(addsuffix .it2, $(TESTLIST))) build/builtincheckfalse.it2
|
|
-rm -f $@
|
|
cat test-input.txt | build/builtincheckfalse.it2 2> /dev/null 2>&1 | grep 'Success'
|
|
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it2 >> $@ ; echo "" >> $@ ;)
|
|
|
|
clean:
|
|
-rm -f *.results build/*.it0* build/*.it1* build/*.it2*
|
|
|
|
###
|
|
# it0
|
|
|
|
../0-lang0py/lang0py.exe: ../0-lang0py/lang0py.py
|
|
$(MAKE) -C ../0-lang0py
|
|
|
|
build/%.it0.py: %.lang0 ../0-lang0py/lang0py.exe
|
|
cat $< | ../0-lang0py/lang0py.exe > $@.tmp
|
|
mv $@.tmp $@
|
|
|
|
build/%.it0.c: build/%.it0.py
|
|
$(CYTHON) -3 --embed -o $@ $^
|
|
|
|
build/%.it0.o: build/%.it0.c
|
|
$(CC) -o $@ -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
|
|
|
|
build/%.it0: build/%.it0.o
|
|
$(CC) -o $@ $^ -lpython$(PYVERSION)
|
|
|
|
###
|
|
# it1
|
|
|
|
../1-lang0py/lang0py.exe: ../0-lang0py/lang0py.exe ../1-lang0py/lang0py.lang0
|
|
$(MAKE) -C ../1-lang0py
|
|
|
|
build/%.it1.py: %.lang0 ../1-lang0py/lang0py.exe
|
|
cat $< | ../1-lang0py/lang0py.exe > $@.tmp
|
|
mv $@.tmp $@
|
|
|
|
build/%.it1.c: build/%.it1.py
|
|
$(CYTHON) -3 --embed -o $@ $^
|
|
|
|
build/%.it1.o: build/%.it1.c
|
|
$(CC) -o $@ -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
|
|
|
|
build/%.it1: build/%.it1.o
|
|
$(CC) -o $@ $^ -lpython$(PYVERSION)
|
|
|
|
###
|
|
# it2
|
|
|
|
../2-lang0c/lang0c.exe: ../0-lang0py/lang0py.exe ../1-lang0py/lang0py.exe ../2-lang0c/lang0c.lang0
|
|
$(MAKE) -C ../2-lang0c
|
|
|
|
build/%.it2.c: %.lang0 ../2-lang0c/lang0c.exe
|
|
cat $< | ../2-lang0c/lang0c.exe > $@.tmp
|
|
mv $@.tmp $@
|
|
|
|
build/%.it2.o: build/%.it2.c
|
|
$(CC) -o $@ -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
|
|
|
|
build/%.it2: build/%.it2.o
|
|
$(CC) -o $@ $^ -lpython$(PYVERSION)
|