-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
37 lines (30 loc) · 1.2 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.DEFAULT_GOAL := qcc
#Build
qcc: src/*
gcc src/*.c -o qcc
# Test all
test: clean $(addprefix test_, $(basename $(notdir $(wildcard tests/*.c))))
cd tools; ./test_summary.sh
clean:
rm -rf tests/build
rm -rf tests/results
# Compiler test
tests/build/%.asm: tests/%.c qcc
mkdir -p tests/build
rm -f tests/build/$(notdir $(basename $<)).asm
rm -f tests/build/$(notdir $(basename $<)).log
cd tests; ../qcc $(notdir $<) -o build/$(notdir $(basename $<)).asm >> build/$(notdir $(basename $<)).log || rm -f build/$(notdir $(basename $<)).asm || true
cat tests/build/$(notdir $(basename $<)).log
# Assemble test
tests/build/%.bin: tests/build/%.asm
rm -f tests/build/$(notdir $(basename $<)).bin
customasm $< tools/architecture.asm -f binary -o tests/build/$(notdir $(basename $<)).bin || true
# Run test
test_%: tests/build/%.bin
mkdir -p tests/results
rm -f tests/results/$(notdir $(basename $<)).pass
touch tests/results/$(notdir $(basename $<)).fail
./tools/emulator tests/build/$(notdir $(basename $<)).bin -n && rm -f tests/results/$(notdir $(basename $<)).fail && touch tests/results/$(notdir $(basename $<)).pass || true
# Print compiler log
log_%: tests/%.c
cat tests/build/$(notdir $(basename $<)).log