forked from ballerina-platform/nballerina
-
Notifications
You must be signed in to change notification settings - Fork 0
/
balt-sub.mk
58 lines (46 loc) · 1.54 KB
/
balt-sub.mk
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
COMPILER_JAR=../../../build/compiler/bin/nballerina.jar
JAVA ?= $(shell ../../../test/findJava.sh)
TARGETS=all test testll compile
LLVM_SUFFIX ?=-12
CLANG ?= clang$(LLVM_SUFFIX)
LLVM_LINK ?= llvm-link$(LLVM_SUFFIX)
CFLAGS ?= -O2
RT=../../../runtime/balrt.a
RT_INLINE=../../../runtime/balrt_inline.bc
ll_files = $(wildcard ll/*-[vpo].ll)
diff_files = $(addsuffix .diff, $(addprefix result/, $(basename $(notdir $(ll_files)))))
exe_files = $(addsuffix .exe, $(addprefix result/, $(basename $(notdir $(ll_files)))))
expect_files = $(wildcard ./expect/*.txt)
balt_files = $(wildcard $(balt_dir)/*.balt)
test: all
$(MAKE) -f ../../balt-sub.mk tdir=$(tdir) testll
all:
if test $(COMPILER_JAR) -nt compile.stamp; then rm -f compile.stamp; fi
$(MAKE) -f ../../balt-sub.mk tdir=$(tdir) compile
compile: compile.stamp
compile.stamp: $(balt_files)
$(JAVA) -jar $(COMPILER_JAR) --outDir ll --expectOutDir expect $^
mkdir -p ll
mkdir -p expect
@touch $@
# This compiles, runs and checks the output of ll/*.ll
testll: fail.txt $(expect_files) $(exe_files)
fail.txt: $(diff_files)
@>$@
@for f in $^; do \
if test -s $$f; then \
echo $(tdir)$$f failed | sed -e 's;result/*[0-9]*L0*;.balt:;' -e 's;-[vpe]\.diff;;' >>$@; \
fi \
done
@cat $@
@test ! -s $@
result/%.diff: result/%.exe expect/%.txt
-../../runcheck.sh $^ >$@
result/%.bc: ll/%.ll $(RT_INLINE)
@mkdir -p result
$(LLVM_LINK) -o $@ $^
result/%.exe: result/%.bc result/%._init.bc $(RT)
$(CLANG) $(CFLAGS) -o $@ $^
clean:
-rm -rf actual compile.stamp expect fail.txt ll result
.PHONY: $(TARGETS)