aboutsummaryrefslogtreecommitdiff
path: root/Makefile.test
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-09-08 17:27:48 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-09-08 17:27:48 +0200
commitcbc2686373a5fe81b6b28f845edc323d4cae56e5 (patch)
treef53d38cbb32f441450f8d33ff315566f1e98ce5f /Makefile.test
parent0a49a2c1496888f0014cf09feb425d9cc47a75ba (diff)
downloadAGH-engineering-thesis-cbc2686373a5fe81b6b28f845edc323d4cae56e5.tar.gz
AGH-engineering-thesis-cbc2686373a5fe81b6b28f845edc323d4cae56e5.zip
modernize the build (test) system
Diffstat (limited to 'Makefile.test')
-rw-r--r--Makefile.test73
1 files changed, 73 insertions, 0 deletions
diff --git a/Makefile.test b/Makefile.test
new file mode 100644
index 0000000..fac2c14
--- /dev/null
+++ b/Makefile.test
@@ -0,0 +1,73 @@
+# This Makefile is to be included by Makefile of each test
+
+ifndef PROJ_DIR
+PROJ_DIR := ../../
+endif
+
+IVFLAGS += -I$(PROJ_DIR)/include/ -DSIMULATION
+# The macroassembly header file is somewhat different thing, but I don't know
+# what place would be more suitable for it than include/ dir
+MACROASM_FLAGS += -I$(PROJ_DIR)/include/ -E
+
+include $(PROJ_DIR)/Makefile.config
+include $(PROJ_DIR)/Makefile.util
+
+ifdef DEBUG
+IVFLAGS += -DDEBUG
+DBG&SAVE = tee "$(1)"
+else
+DBG&SAVE = cat > "$(1)" # putting cat through pipe - what an animal cruelty!
+endif
+
+vpath %.v $(PROJ_DIR):$(PROJ_DIR)/design/:$(PROJ_DIR)/models/:.
+vpath %.vh $(PROJ_DIR)/include:.
+
+ifdef QUICK_TEST
+ifdef VGA_TEST
+SKIPPING = 1
+endif
+endif
+
+ifdef SKIPPING
+test :
+ @echo Skipping >&2
+else
+ifdef VGA_TEST
+test : VGAdump.ppm VGAdump_expected.ppm
+endif
+test : report.log
+ ! grep error $< >&2
+ifdef VGA_TEST
+ diff VGAdump.ppm VGAdump_expected.ppm
+endif
+endif
+
+$(PROJ_DIR)/% :
+ $(MAKE) -C $(PROJ_DIR) $*
+
+%.mem : %.memv
+ $(IV) $(MACROASM_FLAGS) $^ -o $@
+
+%.vvp : %.v $(DEPENDS)
+ $(IV) $(IVFLAGS) -s $(TOP) $(filter %.v,$^) -o $@
+
+
+ifdef VGA_TEST
+report.log VGAdump.mem : $(PROJ_DIR)/design/font.mem
+endif
+report.log VGAdump.mem : test.vvp
+ vvp $< | $(call DBG&SAVE,report.log)
+
+VGAdump.ppm : $(PROJ_DIR)/tools/VGAdump2ppm VGAdump.mem
+ grep -v // < VGAdump.mem | $< > $@
+
+GENERATED_MEM_FILES := $(shell find . -name "*.s.tcl")
+GENERATED_MEM_FILES := $(basename $(basename $(GENERATED_MEM_FILES)))
+GENERATED_MEM_FILES += $(basename $(shell find . -name "*.memv"))
+GENERATED_MEM_FILES := $(addsuffix .mem,$(GENERATED_MEM_FILES))
+
+clean :
+ rm $(GENERATED_MEM_FILES) *.vvp report.log VGAdump.mem VGAdump.ppm \
+ 2>/dev/null || true
+
+.PHONY : test clean