Skip to content

Commit abbcf91

Browse files
committed
single dune file, proper opam support, switch parts of the Makefile to
dune, update GitHub actions
1 parent 1e5bd99 commit abbcf91

File tree

18 files changed

+131
-340
lines changed

18 files changed

+131
-340
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: ocaml/setup-ocaml@v2
1919
with:
2020
ocaml-compiler: 4.12.x
21-
- run: opam install --yes ocamlbuild.0.14.0
21+
- run: opam install --yes dune
2222
- run: cd interpreter && opam exec make all
2323

2424
build-js-api-spec:
@@ -51,7 +51,7 @@ jobs:
5151
submodules: "recursive"
5252
- run: pip install bikeshed && bikeshed update
5353
- run: pip install six
54-
- run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
54+
- run: sudo apt update -y && sudo apt install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
5555
- run: pip install sphinx==4.0.0
5656
- run: cd document/core && make all
5757
- uses: actions/upload-artifact@v2

interpreter/Makefile

Lines changed: 22 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -9,100 +9,24 @@
99

1010
# Configuration
1111

12-
NAME = wasm
13-
UNOPT = $(NAME).debug
14-
OPT = $(NAME)
15-
LIB = $(NAME)
16-
ZIP = $(NAME).zip
12+
UNOPT = _build/default/main/main.bc
13+
OPT = _build/default/main/main.exe
1714
JSLIB = wast.js
18-
WINMAKE = winmake.bat
19-
2015
DIRS = util syntax binary text valid runtime exec script host main tests
21-
LIBS = bigarray
22-
FLAGS = -lexflags -ml -cflags '-w +a-4-27-42-44-45 -warn-error +a-3'
23-
OCBA = ocamlbuild $(FLAGS) $(DIRS:%=-I %)
24-
OCB = $(OCBA) $(LIBS:%=-libs %)
2516
JS = # set to JS shell command to run JS tests
2617

27-
2818
# Main targets
2919

30-
.PHONY: default opt unopt libopt libunopt jslib all land zip smallint
20+
.PHONY: default opt unopt jslib all land zip
3121

3222
default: opt
3323
debug: unopt
3424
opt: $(OPT)
3525
unopt: $(UNOPT)
36-
libopt: _build/$(LIB).cmx _build/$(LIB).cmxa
37-
libunopt: _build/$(LIB).cmo _build/$(LIB).cma
3826
jslib: $(JSLIB)
39-
all: unopt opt libunopt libopt test
40-
land: $(WINMAKE) all
41-
zip: $(ZIP)
42-
smallint: smallint.native
43-
44-
45-
# Building executable
46-
47-
empty =
48-
space = $(empty) $(empty)
49-
comma = ,
50-
51-
.INTERMEDIATE: _tags
52-
_tags:
53-
echo >$@ "true: bin_annot"
54-
echo >>$@ "true: debug"
55-
echo >>$@ "<{$(subst $(space),$(comma),$(DIRS))}/*.cmx>: for-pack($(PACK))"
56-
57-
$(UNOPT): main.byte
58-
mv $< $@
59-
60-
$(OPT): main.native
61-
mv $< $@
62-
63-
.PHONY: main.byte main.native
64-
main.byte: _tags
65-
$(OCB) -quiet $@
66-
67-
main.native: _tags
68-
$(OCB) -quiet $@
69-
70-
.PHONY: smallint.byte smallint.native
71-
smallint.byte: _tags
72-
$(OCB) -quiet $@
73-
smallint.native: _tags
74-
$(OCB) -quiet $@
75-
76-
77-
# Building library
78-
79-
FILES = $(shell ls $(DIRS:%=%/*) | grep '[.]ml[^.]*$$')
80-
PACK = $(shell echo `echo $(LIB) | sed 's/^\(.\).*$$/\\1/g' | tr [:lower:] [:upper:]``echo $(LIB) | sed 's/^.\(.*\)$$/\\1/g'`)
81-
82-
.INTERMEDIATE: $(LIB).mlpack
83-
$(LIB).mlpack: $(DIRS)
84-
ls $(FILES) \
85-
| sed 's:\(.*/\)\{0,1\}\(.*\)\.[^\.]*:\2:' \
86-
| grep -v main \
87-
| sort | uniq \
88-
>$@
89-
90-
.INTERMEDIATE: $(LIB).mllib
91-
$(LIB).mllib:
92-
echo Wasm >$@
93-
94-
_build/$(LIB).cmo: $(FILES) $(LIB).mlpack _tags Makefile
95-
$(OCB) -quiet $(LIB).cmo
96-
97-
_build/$(LIB).cmx: $(FILES) $(LIB).mlpack _tags Makefile
98-
$(OCB) -quiet $(LIB).cmx
99-
100-
_build/$(LIB).cma: $(FILES) $(LIB).mllib _tags Makefile
101-
$(OCBA) -quiet $(LIB).cma
102-
103-
_build/$(LIB).cmxa: $(FILES) $(LIB).mllib _tags Makefile
104-
$(OCBA) -quiet $(LIB).cmxa
105-
27+
all: unopt opt test
28+
land: all
29+
zip: wasm.zip
10630

10731
# Building JavaScript library
10832

@@ -114,21 +38,6 @@ $(JSLIB): $(UNOPT)
11438
rm _build/jslib/src/*.ml[^i]
11539
(cd _build/jslib; ./build.sh ../../$@)
11640

117-
118-
# Building Windows build file
119-
120-
$(WINMAKE): clean
121-
echo rem Auto-generated from Makefile! >$@
122-
echo set NAME=$(NAME) >>$@
123-
echo if \'%1\' neq \'\' set NAME=%1 >>$@
124-
$(OCB) main.byte \
125-
| grep -v ocamldep \
126-
| grep -v mkdir \
127-
| sed s:`which ocaml`:ocaml:g \
128-
| sed s:main/main.d.byte:%NAME%.exe: \
129-
>>$@
130-
131-
13241
# Executing test suite
13342

13443
TESTDIR = ../test/core
@@ -138,24 +47,24 @@ TESTS = $(TESTFILES:%.wast=%)
13847

13948
.PHONY: test debugtest partest
14049

141-
test: $(OPT) smallint
50+
test:
14251
$(TESTDIR)/run.py --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',)
143-
./smallint.native
52+
dune runtest
14453
debugtest: $(UNOPT) smallint
14554
$(TESTDIR)/run.py --wasm `pwd`/$(UNOPT) $(if $(JS),--js '$(JS)',)
146-
./smallint.native
55+
dune runtest
14756

14857
test/%: $(OPT)
14958
$(TESTDIR)/run.py --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast
15059
debugtest/%: $(UNOPT)
15160
$(TESTDIR)/run.py --wasm `pwd`/$(UNOPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast
15261

153-
run/%: $(OPT)
154-
./$(OPT) $(TESTDIR)/$*.wast
155-
debug/%: $(UNOPT)
156-
./$(UNOPT) $(TESTDIR)/$*.wast
62+
run/%:
63+
dune exec -- main/main.exe $(TESTDIR)/$*.wast
64+
debug/%:
65+
dune exec -- main/main.bc $(TESTDIR)/$*.wast
15766

158-
partest: $(TESTS:%=quiettest/%)
67+
partest: $(TESTS:%=quiettest/%)
15968
@echo All tests passed.
16069

16170
quiettest/%: $(OPT)
@@ -165,34 +74,21 @@ quiettest/%: $(OPT)
16574
) || \
16675
cat $(@F).out || rm $(@F).out || exit 1
16776

168-
smallinttest: smallint
169-
@./smallint.native
77+
smallinttest:
78+
dune runtest
17079

17180
# Miscellaneous targets
17281

173-
.PHONY: clean
174-
175-
$(ZIP): $(WINMAKE)
176-
git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD
82+
wasm.zip:
83+
git archive --format=zip --prefix=wasm/ -o $@ HEAD
17784

17885
clean:
179-
rm -rf _build/jslib $(LIB).mlpack _tags
180-
$(OCB) -clean
181-
86+
dune clean
18287

18388
# Opam support
18489

185-
.PHONY: check install uninstall
186-
187-
check:
188-
# Check that we can find all relevant libraries
189-
# when using ocamlfind
190-
ocamlfind query $(LIBS)
191-
192-
install: _build/$(LIB).cmx _build/$(LIB).cmo
193-
ocamlfind install $(LIB) meta/findlib/META _build/$(LIB).o \
194-
$(wildcard _build/$(LIB).cm*) \
195-
$(wildcard $(DIRS:%=%/*.mli))
90+
install:
91+
dune install
19692

19793
uninstall:
198-
ocamlfind remove $(LIB)
94+
dune uninstall

interpreter/binary/dune

Lines changed: 0 additions & 4 deletions
This file was deleted.

interpreter/dune

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
(copy_files#
2+
(files binary/*.ml*))
3+
4+
(copy_files#
5+
(files exec/*.ml*))
6+
7+
(copy_files#
8+
(files host/*.ml*))
9+
10+
(copy_files#
11+
(files main/flags.ml))
12+
13+
(copy_files#
14+
(files runtime/*.ml*))
15+
16+
(copy_files#
17+
(files script/*.ml*))
18+
19+
(copy_files#
20+
(files syntax/*.ml*))
21+
22+
(copy_files#
23+
(files text/*.ml*))
24+
25+
(copy_files#
26+
(files util/*.ml*))
27+
28+
(copy_files#
29+
(files valid/*.ml*))
30+
31+
(library
32+
(public_name wasm)
33+
(wrapped false))
34+
35+
; we don't use the `ocamllex` stanza directly as there's no way to pass the `-ml`
36+
; if we don't pass `-ml` we have a transition table overflow...
37+
38+
(rule
39+
(target lexer.ml)
40+
(deps lexer.mll)
41+
(action
42+
(chdir
43+
%{workspace_root}
44+
(run %{bin:ocamllex} -q -ml -o %{target} %{deps}))))
45+
46+
(ocamlyacc
47+
(modules parser))

interpreter/dune-project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
(lang dune 2.8)
22

33
(implicit_transitive_deps false)
4+
5+
(name wasm)
6+
7+
(license Apache-2.0)
8+
9+
(authors "TODO")
10+
11+
(maintainers "TODO")
12+
13+
(source
14+
(github WebAssembly/spec))
15+
16+
(generate_opam_files true)
17+
18+
(package
19+
(name wasm)
20+
(synopsis "WebAssembly library")
21+
(description "A library for writing/reading/running WebAssembly binaries.")
22+
(tags
23+
(wasm webassembly spec interpreter))
24+
(depends
25+
(ocaml
26+
(>= 4.05))))

interpreter/exec/dune

Lines changed: 0 additions & 25 deletions
This file was deleted.

interpreter/host/dune

Lines changed: 0 additions & 12 deletions
This file was deleted.

interpreter/main/dune

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
(library
2-
(name flags)
3-
(wrapped false)
4-
(modules flags))
5-
61
(executable
2+
(public_name wasm)
73
(name main)
84
(modules main)
9-
(libraries binary flags host script_run script syntax))
5+
(modes byte exe)
6+
(libraries wasm))

interpreter/meta/findlib/META

Lines changed: 0 additions & 4 deletions
This file was deleted.

interpreter/runtime/dune

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)