Makefile 2.75 KB
Newer Older
1
TESTS=basic simple nested
2
LABCOMM_JAR=../compiler/labComm.jar
3
LABCOMM=java -jar $(LABCOMM_JAR)
4

5
CFLAGS=-O3 -g -Wall -Werror
6

7
all:
Anders Blomdell's avatar
Anders Blomdell committed
8
9

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

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

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

# 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
44
45
46
47
.PRECIOUS: gen/%/.dir
gen/%/.dir:
	mkdir -p gen/$*
	touch $@
48
49

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

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

# C relay test rules
.PRECIOUS: gen/%/c_code.h gen/%/c_code.c
Anders Blomdell's avatar
Anders Blomdell committed
59
gen/%/c_code.h gen/%/c_code.c: %.lc Makefile | gen/%/.dir
60
61
62
63
64
65
66
67
	$(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
68
	$(CC) $(CFLAGS) -o $@ $< -I../lib/c -I. -L..//lib/c \
69
		gen/$*/c_code.c -llabcomm
70
71
72

# C# relay test rules
.PRECIOUS: gen/%/cs_code.cs
Anders Blomdell's avatar
Anders Blomdell committed
73
gen/%/cs_code.cs: %.lc Makefile | gen/%/.dir
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
	$(LABCOMM) --cs=$@ $<

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

.PRECIOUS: gen/%/labcomm.dll
gen/%/labcomm.dll:
	ln -s ../../../lib/csharp/labcomm.dll $@

.PRECIOUS: gen/%/cs_relay.exe
gen/%/cs_relay.exe: gen/%/cs_relay.cs gen/%/cs_code.cs \
		    gen/%/labcomm.dll Makefile
	mcs -out:$@ $(filter %.cs, $^) -lib:../lib/csharp/ -r:labcomm

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

Anders Blomdell's avatar
Anders Blomdell committed
95
96
97
98
99
100
101
.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
	javac -d gen/$*  -cp ../lib/java/labcomm.jar:gen/$*/java_code $<