-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (46 loc) · 1.43 KB
/
Makefile
File metadata and controls
64 lines (46 loc) · 1.43 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
TIG_BIN := ./tc
# Important parser files.
TIG_PARSE := $(addprefix tiger/, *.grm.sml *.lex.sml)
# Source files.
SRC := $(wildcard tiger/*.sml) $(addprefix tiger/, tiger.grm tiger.lex) \
$(wildcard target/*.sml) \
$(wildcard ir/*.sml) \
$(wildcard util/*.sml) \
tc.sml
# Test cases.
TIG_TEST_DIR := tests/
TIG_CUSTOM_TEST := tests/custom.tig
TIG_TESTS := $(filter-out ${TIG_CUSTOM_TEST}, $(wildcard tests/*))
TIG_TEST_SCRIPT := ./tig_test.sh
TIG_TEST_OUT := tig_test.out
# Files to be cleaned.
CLEAN := $(addprefix tiger/, *.grm.sml *.lex.sml *.grm.desc *.grm.sig) ${TIG_BIN} ${TIG_TEST_OUT} \
$(shell find -type d -name .cm)
.PHONY: all clean tests test
all: ${TIG_BIN}
log:
@echo ${SRC}
${TIG_BIN}: ${SRC} ${TIG_PARSE}
mlton -output $@ tc.mlb
%.lex.sml: %.lex
mllex $<
%.grm.sml: %.grm
mlyacc $<
run: ${TIG_BIN}
@${TIG_BIN}
test: ${TIG_BIN}
@${TIG_BIN} --pp ${TIG_CUSTOM_TEST}
tests: ${TIG_BIN} ${TIG_TESTS}
@echo "Check ${TIG_TEST_OUT} for the outputs or error logs."
%.tig: ${TIG_BIN} | setup_out
@echo - $(notdir $@) >> ${TIG_TEST_OUT}
@${TIG_BIN} --fmt $@ >> ${TIG_TEST_OUT} 2>&1||:
@-${TIG_BIN} --fmt $@ 2>/dev/null | ${TIG_BIN} > /dev/null 2>&1 \
&& (echo "$(notdir $@) .... \033[0;32mOK\033[0m"; exit 0) \
|| (echo "$(notdir $@) .... \033[0;31mFAIL\033[0m"; exit 0)
@echo "" >> ${TIG_TEST_OUT}
setup_out:
@rm -f ${TIG_TEST_OUT}
@echo "Test Directory - ${TIG_TEST_DIR}\n" >> ${TIG_TEST_OUT}
clean:
rm -rf ${CLEAN}