-
Notifications
You must be signed in to change notification settings - Fork 478
use dune in the Makefile and remove ocamlbuild #1665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
af54a42
remove winmake.bat
zapashcanon 6e7cccc
switch the Makefile to dune
zapashcanon b12aaee
bring back $NAME in the Makefile
zapashcanon 38e26c2
add wast.js rule
zapashcanon 1fe1fff
add instructions on how to install dune
zapashcanon 63adaf4
update .gitignore
zapashcanon 8e82fbe
bring back the wasm executable at the root of the interpreter directory
zapashcanon 71715d2
basic opam support
zapashcanon ecf6af7
makefile tweaks
zapashcanon 0737b9b
Makefile fix
zapashcanon 0200871
rename wasm.ml to main.ml
zapashcanon a6855a7
use $(NAME) everywhere
zapashcanon 069c4e3
add a distclean target
zapashcanon b37da56
update .gitignore
zapashcanon f4265a2
fix distclean target
zapashcanon 030a5ce
update dune-project
zapashcanon 0d5943e
remove meta
zapashcanon c02251b
fix jslib
zapashcanon 665f1c2
opam-release
zapashcanon 4078ca6
remove phony
zapashcanon b35a792
opam release
zapashcanon 5dca9fb
Update interpreter/Makefile
zapashcanon df5be7c
makefile style
zapashcanon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
*.cmo | ||
*.cmx | ||
*.native | ||
*.byte | ||
*.opt | ||
*.unopt | ||
*.js | ||
*.zip | ||
*.mlpack | ||
_build | ||
wasm | ||
wasm.debug | ||
|
||
*.install | ||
*.js | ||
*.zip | ||
opam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# This Makefile uses ocamlbuild but does not rely on ocamlfind or the Opam | ||
# 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 check/install/uninstall targets. | ||
# | ||
|
@@ -9,131 +9,45 @@ | |
|
||
# Configuration | ||
|
||
NAME = wasm | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
UNOPT = $(NAME).debug | ||
OPT = $(NAME) | ||
LIB = $(NAME) | ||
NAME = wasm | ||
OPT = $(NAME).exe | ||
ZIP = $(NAME).zip | ||
JSLIB = wast | ||
WINMAKE = winmake.bat | ||
|
||
DIRS = util syntax binary text valid runtime exec script host main tests | ||
LIBS = | ||
FLAGS = -lexflags -ml -cflags '-w +a-4-27-42-44-45-70 -warn-error +a-3' | ||
OCBA = ocamlbuild $(FLAGS) $(DIRS:%=-I %) | ||
OCB = $(OCBA) $(LIBS:%=-libs %) | ||
JSO = js_of_ocaml -q --opt 3 | ||
JS = # set to JS shell command to run JS tests, empty to skip | ||
JSLIB = wast.js | ||
|
||
BUILDDIR = _build/default | ||
|
||
# Main targets | ||
JS = # set to JS shell command to run JS tests, empty to skip | ||
|
||
.PHONY: default opt unopt libopt libunopt jslib all land zip smallint dunebuild | ||
|
||
default: opt | ||
debug: unopt | ||
opt: $(OPT) | ||
unopt: $(UNOPT) | ||
libopt: _build/$(LIB).cmx _build/$(LIB).cmxa | ||
libunopt: _build/$(LIB).cmo _build/$(LIB).cma | ||
jslib: $(JSLIB).js | ||
all: unopt opt libunopt libopt test | ||
land: $(WINMAKE) all | ||
zip: $(ZIP) | ||
smallint: smallint.native | ||
ci: land jslib dunebuild | ||
# Main targets | ||
|
||
dunebuild: | ||
dune build | ||
.PHONY: default opt jslib all zip smallint | ||
|
||
default: $(OPT) | ||
jslib: $(JSLIB) | ||
all: $(OPT) test | ||
zip: $(ZIP) | ||
smallint: smallint.exe | ||
ci: all jslib | ||
|
||
# Building executable | ||
.PHONY: $(NAME).exe | ||
$(NAME).exe: | ||
rm -f $(NAME) | ||
dune build $@ | ||
cp $(BUILDDIR)/$(OPT) $(NAME) | ||
|
||
empty = | ||
space = $(empty) $(empty) | ||
comma = , | ||
|
||
.INTERMEDIATE: _tags | ||
_tags: | ||
echo >$@ "true: bin_annot" | ||
echo >>$@ "true: debug" | ||
echo >>$@ "<{$(subst $(space),$(comma),$(DIRS))}/*.cmx>: for-pack($(PACK))" | ||
|
||
$(UNOPT): main.byte | ||
mv $< $@ | ||
|
||
$(OPT): main.native | ||
mv $< $@ | ||
|
||
.PHONY: main.byte main.native | ||
main.byte: _tags | ||
$(OCB) -quiet $@ | ||
|
||
main.native: _tags | ||
$(OCB) -quiet $@ | ||
|
||
.PHONY: smallint.byte smallint.native | ||
smallint.byte: _tags | ||
$(OCB) -quiet $@ | ||
smallint.native: _tags | ||
$(OCB) -quiet $@ | ||
|
||
|
||
# Building library | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
FILES = $(shell ls $(DIRS:%=%/*) | grep '[.]ml[^.]*$$') | ||
PACK = $(shell echo `echo $(LIB) | sed 's/^\(.\).*$$/\\1/g' | tr [:lower:] [:upper:]``echo $(LIB) | sed 's/^.\(.*\)$$/\\1/g'`) | ||
|
||
.INTERMEDIATE: $(LIB).mlpack | ||
$(LIB).mlpack: $(DIRS) | ||
ls $(FILES) \ | ||
| sed 's:\(.*/\)\{0,1\}\(.*\)\.[^\.]*:\2:' \ | ||
| grep -v main \ | ||
| sort | uniq \ | ||
>$@ | ||
|
||
.INTERMEDIATE: $(LIB).mllib | ||
$(LIB).mllib: | ||
echo Wasm >$@ | ||
|
||
_build/$(LIB).cmo: $(FILES) $(LIB).mlpack _tags Makefile | ||
$(OCB) -quiet $(LIB).cmo | ||
|
||
_build/$(LIB).cmx: $(FILES) $(LIB).mlpack _tags Makefile | ||
$(OCB) -quiet $(LIB).cmx | ||
|
||
_build/$(LIB).cma: $(FILES) $(LIB).mllib _tags Makefile | ||
$(OCBA) -quiet $(LIB).cma | ||
|
||
_build/$(LIB).cmxa: $(FILES) $(LIB).mllib _tags Makefile | ||
$(OCBA) -quiet $(LIB).cmxa | ||
|
||
.PHONY: smallint.exe | ||
smallint.exe: | ||
dune build $@ | ||
|
||
# Building JavaScript library | ||
|
||
JSLIB_DIR = meta/jslib | ||
JSLIB_FLAGS = -I $(JSLIB_DIR) -use-ocamlfind -pkg js_of_ocaml -pkg js_of_ocaml-ppx | ||
|
||
.INTERMEDIATE: $(JSLIB).byte | ||
$(JSLIB).byte: $(JSLIB_DIR)/$(JSLIB).ml | ||
$(OCBA) $(JSLIB_FLAGS) $@ | ||
|
||
$(JSLIB).js: $(JSLIB).byte | ||
$(JSO) $< | ||
|
||
# Building Windows build file | ||
|
||
$(WINMAKE): clean | ||
echo rem Auto-generated from Makefile! >$@ | ||
echo set NAME=$(NAME) >>$@ | ||
echo if \'%1\' neq \'\' set NAME=%1 >>$@ | ||
$(OCB) main.byte \ | ||
| grep -v ocamldep \ | ||
| grep -v mkdir \ | ||
| sed s:`which ocaml`:ocaml:g \ | ||
| sed s:main/main.d.byte:%NAME%.exe: \ | ||
>>$@ | ||
$(JSLIB): $(BUILDDIR)/$(JSLIB) | ||
cp $< $@ | ||
|
||
$(BUILDDIR)/$(JSLIB): | ||
dune build $(JSLIB) | ||
|
||
# Executing test suite | ||
|
||
|
@@ -142,78 +56,62 @@ TESTDIR = ../test/core | |
TESTFILES = $(shell cd $(TESTDIR); ls *.wast; ls [a-z]*/*.wast) | ||
TESTS = $(TESTFILES:%.wast=%) | ||
|
||
.PHONY: test debugtest partest dune-test | ||
.PHONY: test partest dune-test | ||
|
||
test: $(OPT) smallint | ||
$(TESTDIR)/run.py --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',) | ||
./smallint.native | ||
debugtest: $(UNOPT) smallint | ||
$(TESTDIR)/run.py --wasm `pwd`/$(UNOPT) $(if $(JS),--js '$(JS)',) | ||
./smallint.native | ||
$(TESTDIR)/run.py --wasm `pwd`/$(BUILDDIR)/$(OPT) $(if $(JS),--js '$(JS)',) | ||
dune exec ./smallint.exe | ||
|
||
test/%: $(OPT) | ||
$(TESTDIR)/run.py --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast | ||
debugtest/%: $(UNOPT) | ||
$(TESTDIR)/run.py --wasm `pwd`/$(UNOPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast | ||
$(TESTDIR)/run.py --wasm `pwd`/$(BUILDDIR)/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast | ||
|
||
run/%: $(OPT) | ||
./$(OPT) $(TESTDIR)/$*.wast | ||
debug/%: $(UNOPT) | ||
./$(UNOPT) $(TESTDIR)/$*.wast | ||
|
||
partest: $(TESTS:%=quiettest/%) | ||
partest: $(TESTS:%=quiettest/%) | ||
@echo All tests passed. | ||
|
||
quiettest/%: $(OPT) | ||
@ ( \ | ||
$(TESTDIR)/run.py 2>$(@F).out --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast && \ | ||
$(TESTDIR)/run.py 2>$(@F).out --wasm `pwd`/$(BUILDDIR)/$(OPT) $(if $(JS),--js '$(JS)',) $(TESTDIR)/$*.wast && \ | ||
rm $(@F).out \ | ||
) || \ | ||
cat $(@F).out || rm $(@F).out || exit 1 | ||
|
||
smallinttest: smallint | ||
@./smallint.native | ||
dune exec ./smallint.exe | ||
|
||
dunetest: | ||
dune test | ||
|
||
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 | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo ' src: "https://github.com/WebAssembly/spec/archive/[email protected]"' >> opam | ||
echo ' checksum: "md5=@MD5"' >> opam | ||
echo '}' >> opam | ||
sed -i ".tmp" s/@VERSION/$*/g opam | ||
sed -i ".tmp" s/@MD5/`md5 -q opam-$*.zip`/g opam | ||
rm opam.tmp opam-$*.zip | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@echo Created file ./opam, submit to github opam-repository/packages/wasm/wasm.$*/opam | ||
|
||
# Miscellaneous targets | ||
|
||
.PHONY: clean | ||
|
||
$(ZIP): $(WINMAKE) | ||
git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD | ||
$(ZIP): | ||
git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD | ||
|
||
clean: | ||
rm -rf _build/jslib $(LIB).mlpack _tags $(JSLIB).js | ||
$(OCB) -clean | ||
|
||
|
||
# Opam support | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.PHONY: check install uninstall | ||
dune clean | ||
|
||
check: | ||
# Check that we can find all relevant libraries | ||
# when using ocamlfind | ||
ocamlfind query $(LIBS) | ||
|
||
install: _build/$(LIB).cmx _build/$(LIB).cmo | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ocamlfind install $(LIB) meta/findlib/META _build/$(LIB).o \ | ||
$(wildcard _build/$(LIB).cm*) \ | ||
$(wildcard $(DIRS:%=%/*.mli)) | ||
|
||
uninstall: | ||
ocamlfind remove $(LIB) | ||
|
||
opam-release/%: | ||
git tag opam-$* | ||
git push --tags | ||
rm -f opam-$*.zip | ||
wget https://github.com/WebAssembly/spec/archive/opam-$*.zip | ||
cp meta/opam/opam . | ||
sed -i ".tmp" s/@VERSION/$*/g opam | ||
sed -i ".tmp" s/@MD5/`md5 -q opam-$*.zip`/g opam | ||
rm opam.tmp opam-$*.zip | ||
@echo Created file ./opam, submit to github opam-repository/packages/wasm/wasm.$*/opam | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
distclean: clean | ||
rm -f $(NAME) $(JSLIB) | ||
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
zapashcanon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.