Skip to content

Commit

Permalink
Merge pull request #126 from ocaml-wasm/wasm-dune
Browse files Browse the repository at this point in the history
Revised dune support
  • Loading branch information
vouillon authored Nov 6, 2024
2 parents bd01184 + ee35863 commit d7bf42c
Show file tree
Hide file tree
Showing 53 changed files with 138 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-wasm_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:

- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml-wasm/dune.git#wasm_of_ocaml-incremental
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- name: Pin wasm_of_ocaml
working-directory: ./wasm_of_ocaml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:

- name: Pin dune
run: |
opam pin add dune.3.17 https://github.com/ocaml-wasm/dune.git#wasm_of_ocaml
opam pin add dune.3.17 https://github.com/ocaml/dune.git
- run: opam install conf-pkg-config
if: runner.os == 'Windows'
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
dune-cache: true
- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml-wasm/dune.git#wasm_of_ocaml
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- uses: ocaml/setup-ocaml/lint-opam@v3

lint-fmt:
Expand All @@ -193,7 +193,7 @@ jobs:
dune-cache: true
- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml-wasm/dune.git#wasm_of_ocaml
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- uses: ocaml/setup-ocaml/lint-fmt@v3

lint-runtime:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ The following commands will perform a minimal installation:
```
git clone https://github.com/ocaml-wasm/wasm_of_ocaml
cd wasm_of_ocaml
opam pin add -n --with-version 3.17 https://github.com/ocaml-wasm/dune.git#wasm_of_ocaml
opam pin add -n --with-version 5.3.0-wasm .
opam pin add -n --with-version 3.17 https://github.com/ocaml/dune.git
opam pin add -n --with-version 5.8.2-wasm .
opam install wasm_of_ocaml-compiler
```
You may want to install additional packages. For instance:
Expand Down
6 changes: 1 addition & 5 deletions compiler/tests-env/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
(test
(modes js)
(build_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(modes js) ; No env support in wasm_of_ocaml yet
(js_of_ocaml
(javascript_files setup.js)
(flags :standard --setenv JSOO_C=from-jsoo-args))
Expand Down
17 changes: 17 additions & 0 deletions compiler/tests-io/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(names cat md5)
(modes
js
wasm
(best exe)))

(rule
Expand All @@ -27,6 +28,14 @@
(action
(diff cat-js.stdout cat-native.stdout)))

(rule
(action
(copy cat.bc.wasm.js cat.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))

(rule
(target md5-native.stdout)
(action
Expand Down Expand Up @@ -69,3 +78,11 @@
(alias runtest)
(action
(diff md5-js.stdout md5-native.stdout)))

(rule
(action
(copy md5.bc.wasm.js md5.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
18 changes: 17 additions & 1 deletion compiler/tests-jsoo/bin/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(executables
(names error1 error2)
(modes exe js)
(modes exe js wasm)
(foreign_stubs
(language c)
(names named_value_stubs))
Expand Down Expand Up @@ -55,6 +55,14 @@
(action
(diff %{dep:error1-unregister.expected} %{dep:error1-unregister.js.actual})))

(rule
(action
(copy error1.bc.wasm.js error1.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))

(rule
(target error2.js.actual)
(deps error2.html)
Expand Down Expand Up @@ -105,3 +113,11 @@
(alias runtest)
(action
(diff %{dep:error2-unregister.expected} %{dep:error2-unregister.js.actual})))

(rule
(action
(copy error2.bc.wasm.js error2.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
8 changes: 4 additions & 4 deletions compiler/tests-jsoo/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(enabled_if
(>= %{ocaml_version} 4.14))
(inline_tests
(modes js best))
(modes js wasm best))
(preprocess
(pps ppx_expect)))

Expand All @@ -16,7 +16,7 @@
(enabled_if
(>= %{ocaml_version} 5.1.1))
(inline_tests
(modes js best))
(modes js wasm best))
(preprocess
(pps ppx_expect)))

Expand All @@ -27,7 +27,7 @@
(enabled_if
(>= %{ocaml_version} 5.1.1))
(inline_tests
(modes js best))
(modes js wasm best))
(preprocess
(pps ppx_expect)))

Expand All @@ -41,7 +41,7 @@
(language c)
(names bigarray_stubs))
(inline_tests
(modes js best))
(modes js wasm best))
(preprocess
(pps ppx_expect)))

Expand Down
2 changes: 1 addition & 1 deletion compiler/tests-jsoo/lib-effects/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
(inline_tests
;; This requires the unreleased dune 3.7 to work
(enabled_if true)
(modes js best))
(modes js wasm best))
(preprocess
(pps ppx_expect)))
4 changes: 3 additions & 1 deletion compiler/tests-linkall/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
(env
(_
(js_of_ocaml
(compilation_mode separate))
(wasm_of_ocaml
(compilation_mode separate))))

(test
(name test)
(modes byte js)
(modes byte js wasm)
(libraries dynlink)
;; It doesn't seem possible to create a pack-ed module with dune.
;; However, dynlink uses pack to embed a copy
Expand Down
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/basic-modules/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names recursive_module_init)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-atomic/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(test
(name test_atomic)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-bigarray/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names bigarrays change_layout fftba pr5115 weak_bigarray)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-bool/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-buffer/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
1 change: 1 addition & 0 deletions compiler/tests-ocaml/lib-bytes-utf/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
(:standard \ -strict-sequence))
(modes
js
wasm
(best exe)))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-bytes/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test_bytes binary)
(libraries)
(modes js))
(modes js wasm))
8 changes: 3 additions & 5 deletions compiler/tests-ocaml/lib-digest/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
(names md5)
(libraries)
(modules md5)
(modes js))
(modes js wasm))

(tests
(names digests)
(libraries)
(build_if
(and
(>= %{ocaml_version} 5.2)
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(>= %{ocaml_version} 5.2))
(modules digests)
; blake2b not supported by wasm_of_ocaml yet
(modes js))
4 changes: 2 additions & 2 deletions compiler/tests-ocaml/lib-effects/dune
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
test5 test6 test_lazy used_cont)
(modules
(:standard \ unhandled_unlinked))
(modes js))
(modes js wasm))

(tests
(build_if
Expand All @@ -41,4 +41,4 @@
2
(run node %{test}))
(run cat)))
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-filename/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names suffix extension)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-float/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-floatarray/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names floatarray)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-format/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
(libraries)
(flags
(:standard -no-strict-formats \ -strict-formats))
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-fun/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-gc/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(names test_gc)
(libraries)
(flags -w -69)
(modes js))
(modes js wasm))
4 changes: 2 additions & 2 deletions compiler/tests-ocaml/lib-hashtbl/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(deps ../../../LICENSE)
(modules hfun)
(libraries)
(modes js))
(modes js wasm))

(tests
(names htbl)
Expand All @@ -12,7 +12,7 @@
(build_if
(>= %{ocaml_version} 5))
(libraries)
(modes js))
(modes js wasm))

(rule
(action
Expand Down
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-int/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-int64/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test issue9460)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-list/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-option/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
1 change: 1 addition & 0 deletions compiler/tests-ocaml/lib-printf/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
(:standard -no-strict-formats \ -strict-formats))
(modes
js
wasm
(best exe)))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-queue/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
1 change: 1 addition & 0 deletions compiler/tests-ocaml/lib-random/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
(libraries)
(modes
js
wasm
(best exe)))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-result/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-seq/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-set/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names testmap testset)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-stack/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-str/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names t01)
(libraries str)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-string/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
(build_if
(>= %{ocaml_version} 5))
(libraries)
(modes js))
(modes js wasm))
2 changes: 1 addition & 1 deletion compiler/tests-ocaml/lib-uchar/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(tests
(names test)
(libraries)
(modes js))
(modes js wasm))
Loading

0 comments on commit d7bf42c

Please sign in to comment.