-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (77 loc) · 2.16 KB
/
Copy pathMakefile
File metadata and controls
113 lines (77 loc) · 2.16 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# This Makefile uses dune but does not rely on ocamlfind or the Opam
# package manager to build. However, Opam package management is available
# optionally through the install target.
#
# The $(JSLIB).js target requires Js_of_ocaml (using ocamlfind).
#
# See README.me for instructions.
# Configuration
NAME = wasm
LIB = $(NAME)
JSLIB = wast.js
ZIP = $(NAME).zip
BUILDDIR = _build/default
JS = # set to JS shell command to run JS tests, empty to skip
# Main targets
.PHONY: default all ci jslib zip
default: $(NAME)
all: default partest
ci: all jslib zip
jslib: $(JSLIB)
zip: $(ZIP)
# Building
.PHONY: $(NAME) $(JSLIB)
$(NAME):
rm -f $@
dune build $@.exe
ln $(BUILDDIR)/$@.exe $@
$(JSLIB):
rm -f $@
dune build $(@:%.js=%.bc.js)
ln $(BUILDDIR)/$(@:%.js=%.bc.js) $@
# Test suite
TESTDIR = ../test/core
TESTFILES = $(shell cd $(TESTDIR) > /dev/null; ls *.wast; ls [a-z]*/*.wast)
TESTS = $(TESTFILES:%.wast=%)
.PHONY: test partest quiettest
test: $(NAME)
$(TESTDIR)/run.py --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',)
test/%: $(NAME)
$(TESTDIR)/run.py --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast
run/%: $(NAME)
./$(NAME) $(TESTDIR)/$*.wast
partest: $(NAME)
make -j10 quiettest
quiettest: $(TESTS:%=quiettest/%)
@echo All tests passed.
quiettest/%: $(NAME)
@ ( \
$(TESTDIR)/run.py 2>$(@F).out --wasm `pwd`/$(NAME) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast && \
rm $(@F).out \
) || \
(cat $(@F).out && rm $(@F).out && exit 1)
# Packaging
.PHONY: install
install:
dune build -p $(NAME) @install
dune install
opam-release/%:
git tag opam-$*
git push --tags
rm -f opam-$*.zip
wget https://github.com/WebAssembly/spec/archive/opam-$*.zip
cp wasm.opam opam
echo "url {" >> opam
echo " src: \"https://github.com/WebAssembly/spec/archive/opam-$*.zip\"" >> opam
echo " checksum: \"md5=`md5 -q opam-$*.zip`\"" >> opam
echo "}" >> opam
rm opam-$*.zip
@echo Created file ./opam, submit to github opam-repository/packages/wasm/wasm.$*/opam
$(ZIP):
git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD
# Cleanup
.PHONY: clean distclean
clean:
dune clean
distclean: clean
rm -f $(NAME) $(JSLIB) $(ZIP)