Makefile 2.78 KB
Newer Older
1
TESTS=basic simple nested ref
Anders Blomdell's avatar
Anders Blomdell committed
2
LABCOMM_JAR=../compiler/labcomm2014_compiler.jar
3
LABCOMM=java -jar $(LABCOMM_JAR)
4
5
MONO_PATH=$(shell pwd)/../lib/csharp
PYTHONPATH=$(shell pwd)/../lib/python
6

7
include ../lib/c/os_compat.mk
8

9
all:
Anders Blomdell's avatar
Anders Blomdell committed
10

11
test: $(TESTS:%=test_%) compiler_errors
12
13
14
#	PYTHONPATH=../lib/python \
#		./test_encoder_decoder.py --labcomm="$(LABCOMM)" basic.lc

Anders Blomdell's avatar
Anders Blomdell committed
15
16
.PHONY: clean distclean
clean distclean:
17
18
	rm -rf gen

19
.PHONY: test_% 
Anders Blomdell's avatar
Anders Blomdell committed
20
21
test_%: gen/%/signatures.py \
	gen/%/c_relay \
22
	gen/%/cs_relay.exe \
Anders Blomdell's avatar
Anders Blomdell committed
23
	gen/%/java_relay.class \
24
	gen/%/java_code
25
26
	PYTHONPATH=$(PYTHONPATH) MONO_PATH=$(MONO_PATH) \
		./test_encoder_decoder.py \
27
		--signatures=gen/$*/signatures.py \
28
		--test tee gen/$*/testdata \
29
		--test gen/$*/c_relay /dev/stdin /dev/stdout \
Anders Blomdell's avatar
Anders Blomdell committed
30
		--test mono gen/$*/cs_relay.exe /dev/stdin /dev/stdout \
Anders Blomdell's avatar
Anders Blomdell committed
31
		--test java \\-cp gen/$*:../lib/java/labcomm2014.jar java_relay \
Anders Blomdell's avatar
Anders Blomdell committed
32
			    /dev/stdin /dev/stdout
33
34
35
36
37
38
39
40
41
42
43
44
45
46

# test cases for compiler error checking
.PHONY: compiler_errors testErrorsOK testErrorsNOK

compiler_errors: testErrorsOK testErrorsNOK

# tests that should succeed
testErrorsOK: $(wildcard errors/correct/*.lc)
	./test_errors.py --labcomm="$(LABCOMM)" --testOK $^

# tests that should fail
testErrorsNOK: $(wildcard errors/incorrect/*.lc)
	./test_errors.py --labcomm="$(LABCOMM)" --testNOK $^

Anders Blomdell's avatar
Anders Blomdell committed
47
48
49
50
.PRECIOUS: gen/%/.dir
gen/%/.dir:
	mkdir -p gen/$*
	touch $@
51
52

.PRECIOUS: gen/%/typeinfo
Anders Blomdell's avatar
Anders Blomdell committed
53
gen/%/typeinfo:	%.lc Makefile | gen/%/.dir
54
55
56
	$(LABCOMM) --typeinfo=$@ $<

.PRECIOUS: gen/%/signatures.py
Anders Blomdell's avatar
Anders Blomdell committed
57
gen/%/signatures.py: %.lc Makefile | gen/%/.dir
58
59
60
61
	$(LABCOMM) --python=$@ $<

# C relay test rules
.PRECIOUS: gen/%/c_code.h gen/%/c_code.c
Anders Blomdell's avatar
Anders Blomdell committed
62
gen/%/c_code.h gen/%/c_code.c: %.lc Makefile | gen/%/.dir
63
64
65
66
67
68
69
70
	$(LABCOMM) --c=gen/$*/c_code.c --h=gen/$*/c_code.h $<

.PRECIOUS: gen/%/c_relay.c
gen/%/c_relay.c: gen/%/typeinfo relay_gen_c.py Makefile
	./relay_gen_c.py $< > $@

.PRECIOUS: gen/%/c_relay
gen/%/c_relay: gen/%/c_relay.c gen/%/c_code.c Makefile
Anders Blomdell's avatar
Anders Blomdell committed
71
72
	$(CC) $(CFLAGS) -o $@ $< -I../lib/c/2014 -I. -L../lib/c \
		gen/$*/c_code.c -llabcomm2014
73
74
75

# C# relay test rules
.PRECIOUS: gen/%/cs_code.cs
Anders Blomdell's avatar
Anders Blomdell committed
76
gen/%/cs_code.cs: %.lc Makefile | gen/%/.dir
77
78
79
80
81
82
83
	$(LABCOMM) --cs=$@ $<

.PRECIOUS: gen/%/cs_relay.cs
gen/%/cs_relay.cs:  gen/%/typeinfo relay_gen_cs.py Makefile
	./relay_gen_cs.py $< > $@

.PRECIOUS: gen/%/cs_relay.exe
84
gen/%/cs_relay.exe: gen/%/cs_relay.cs gen/%/cs_code.cs Makefile
Anders Blomdell's avatar
Anders Blomdell committed
85
	mcs -out:$@ $(filter %.cs, $^) -lib:../lib/csharp/ -r:labcomm2014
86
87
88

# Java relay test rules
.PRECIOUS: gen/%/java_code
Anders Blomdell's avatar
Anders Blomdell committed
89
gen/%/java_code: %.lc | gen/%/.dir
90
91
92
	mkdir -p $@
	$(LABCOMM) --java=$@ $<

Anders Blomdell's avatar
Anders Blomdell committed
93
94
95
96
97
98
.PRECIOUS: gen/%/java_relay.java
gen/%/java_relay.java: gen/%/typeinfo relay_gen_java.py Makefile
	./relay_gen_java.py $< > $@

.PRECIOUS: gen/%/java_relay.class
gen/%/java_relay.class: gen/%/java_relay.java gen/%/java_code Makefile
Anders Blomdell's avatar
Anders Blomdell committed
99
	javac -d gen/$*  -cp ../lib/java/labcomm2014.jar:gen/$*/java_code $<