diff --git a/.github/workflows/build-wasm_of_ocaml.yml b/.github/workflows/build-wasm_of_ocaml.yml index e4ffefcff5..b120f13032 100644 --- a/.github/workflows/build-wasm_of_ocaml.yml +++ b/.github/workflows/build-wasm_of_ocaml.yml @@ -11,6 +11,7 @@ jobs: env: OPAMJOBS: 2 OPAMYES: true + WASM_OF_OCAML: true strategy: fail-fast: false @@ -19,15 +20,15 @@ jobs: - ubuntu-latest ocaml-compiler: - 4.14.x - - 5.00.x - - 5.01.x - - 5.02.x + - 5.0.x + - 5.1.x + - 5.2.x - ocaml-compiler.5.3.0~beta2 separate_compilation: - true include: - os: macos-latest - ocaml-compiler: 5.02.x + ocaml-compiler: 5.2.x separate_compilation: true - os: ubuntu-latest ocaml-compiler: 4.14.x @@ -92,12 +93,12 @@ jobs: - name: Run tests if: ${{ matrix.separate_compilation }} working-directory: ./wasm_of_ocaml - run: opam exec -- dune build @all @runtest --profile wasm + run: opam exec -- dune build @runtest-wasm - name: Run tests with CPS effects if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation }} working-directory: ./wasm_of_ocaml - run: opam exec -- dune build @all @runtest --profile wasm-effects + run: opam exec -- dune build @runtest-wasm --profile with-effects - name: Run Base tests if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32cf3f341a..9f198ae307 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,7 +146,7 @@ jobs: - run: opam exec -- make tests if: ${{ !matrix.skip-test }} - - run: opam exec -- dune build @all @runtest --profile using-effects + - run: opam exec -- dune build @all @runtest @runtest-js --profile with-effects if: ${{ !matrix.skip-effects }} - run: opam exec -- git diff --exit-code diff --git a/Makefile b/Makefile index 151061fb33..666196bbed 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,10 @@ all: dune build @all tests: - dune runtest + dune build @runtest @runtest-js + +tests-wasm: + WASM_OF_OCAML=true dune build @runtest-wasm test runtest runtests: tests @@ -31,4 +34,4 @@ installdoc: git worktree add _wikidoc origin/wikidoc rsync -av doc-dev/ _wikidoc/doc/dev/ -.PHONY: all tests test runtest runtests doc clean installdoc +.PHONY: all tests tests-wasm test runtest runtests doc clean installdoc diff --git a/compiler/tests-compiler/dune.inc b/compiler/tests-compiler/dune.inc index 4a4f76bf43..27e0cd65fb 100644 --- a/compiler/tests-compiler/dune.inc +++ b/compiler/tests-compiler/dune.inc @@ -2,7 +2,7 @@ (library ;; compiler/tests-compiler/array_access.ml (name array_access_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules array_access) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -17,7 +17,7 @@ (library ;; compiler/tests-compiler/build_path_prefix_map.ml (name build_path_prefix_map_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules build_path_prefix_map) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -32,7 +32,7 @@ (library ;; compiler/tests-compiler/call_gen.ml (name call_gen_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules call_gen) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -47,7 +47,7 @@ (library ;; compiler/tests-compiler/compact.ml (name compact_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules compact) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -62,7 +62,7 @@ (library ;; compiler/tests-compiler/cond.ml (name cond_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules cond) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -77,7 +77,7 @@ (library ;; compiler/tests-compiler/direct_calls.ml (name direct_calls_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules direct_calls) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -92,7 +92,7 @@ (library ;; compiler/tests-compiler/effects.ml (name effects_15) - (enabled_if (and (>= %{ocaml_version} 5) %{env:js-enabled=})) + (enabled_if (>= %{ocaml_version} 5)) (modules effects) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -107,7 +107,7 @@ (library ;; compiler/tests-compiler/effects_continuations.ml (name effects_continuations_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules effects_continuations) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -122,7 +122,7 @@ (library ;; compiler/tests-compiler/effects_exceptions.ml (name effects_exceptions_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules effects_exceptions) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -137,7 +137,7 @@ (library ;; compiler/tests-compiler/effects_toplevel.ml (name effects_toplevel_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules effects_toplevel) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -152,7 +152,7 @@ (library ;; compiler/tests-compiler/eliminate_exception_handler.ml (name eliminate_exception_handler_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules eliminate_exception_handler) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -167,7 +167,7 @@ (library ;; compiler/tests-compiler/empty_cma.ml (name empty_cma_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules empty_cma) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -182,7 +182,7 @@ (library ;; compiler/tests-compiler/end_to_end.ml (name end_to_end_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules end_to_end) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -197,7 +197,7 @@ (library ;; compiler/tests-compiler/error.ml (name error_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules error) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -212,7 +212,7 @@ (library ;; compiler/tests-compiler/es6.ml (name es6_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules es6) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -227,7 +227,7 @@ (library ;; compiler/tests-compiler/exceptions.ml (name exceptions_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules exceptions) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -242,7 +242,7 @@ (library ;; compiler/tests-compiler/exports.ml (name exports_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules exports) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -257,7 +257,7 @@ (library ;; compiler/tests-compiler/getenv.ml (name getenv_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules getenv) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -272,7 +272,7 @@ (library ;; compiler/tests-compiler/gh1007.ml (name gh1007_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1007) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -287,7 +287,7 @@ (library ;; compiler/tests-compiler/gh1051.ml (name gh1051_15) - (enabled_if (and %{arch_sixtyfour} %{env:js-enabled=})) + (enabled_if %{arch_sixtyfour}) (modules gh1051) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -302,7 +302,7 @@ (library ;; compiler/tests-compiler/gh1320.ml (name gh1320_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1320) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -317,7 +317,7 @@ (library ;; compiler/tests-compiler/gh1349.ml (name gh1349_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1349) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -332,7 +332,7 @@ (library ;; compiler/tests-compiler/gh1354.ml (name gh1354_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1354) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -347,7 +347,7 @@ (library ;; compiler/tests-compiler/gh1390.ml (name gh1390_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1390) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -362,7 +362,7 @@ (library ;; compiler/tests-compiler/gh1481.ml (name gh1481_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1481) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -377,7 +377,7 @@ (library ;; compiler/tests-compiler/gh1494.ml (name gh1494_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1494) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -392,7 +392,7 @@ (library ;; compiler/tests-compiler/gh1559.ml (name gh1559_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1559) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -407,7 +407,7 @@ (library ;; compiler/tests-compiler/gh1599.ml (name gh1599_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1599) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -422,7 +422,7 @@ (library ;; compiler/tests-compiler/gh1659.ml (name gh1659_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh1659) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -437,7 +437,7 @@ (library ;; compiler/tests-compiler/gh747.ml (name gh747_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gh747) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -452,7 +452,7 @@ (library ;; compiler/tests-compiler/gl507.ml (name gl507_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules gl507) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -467,7 +467,7 @@ (library ;; compiler/tests-compiler/global_deadcode.ml (name global_deadcode_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules global_deadcode) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -482,7 +482,7 @@ (library ;; compiler/tests-compiler/inlining.ml (name inlining_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules inlining) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -497,7 +497,7 @@ (library ;; compiler/tests-compiler/js_parser_printer.ml (name js_parser_printer_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules js_parser_printer) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -512,7 +512,7 @@ (library ;; compiler/tests-compiler/jsopt.ml (name jsopt_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules jsopt) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -527,7 +527,7 @@ (library ;; compiler/tests-compiler/lambda_lifting.ml (name lambda_lifting_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules lambda_lifting) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -542,7 +542,7 @@ (library ;; compiler/tests-compiler/lazy.ml (name lazy_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules lazy) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -557,7 +557,7 @@ (library ;; compiler/tests-compiler/loops.ml (name loops_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules loops) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -572,7 +572,7 @@ (library ;; compiler/tests-compiler/macro.ml (name macro_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules macro) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -587,7 +587,7 @@ (library ;; compiler/tests-compiler/match_with_exn.ml (name match_with_exn_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules match_with_exn) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -602,7 +602,7 @@ (library ;; compiler/tests-compiler/minify.ml (name minify_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules minify) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -617,7 +617,7 @@ (library ;; compiler/tests-compiler/mutable_closure.ml (name mutable_closure_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules mutable_closure) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -632,7 +632,7 @@ (library ;; compiler/tests-compiler/obj.ml (name obj_15) - (enabled_if (and (>= %{ocaml_version} 5) %{env:js-enabled=})) + (enabled_if (>= %{ocaml_version} 5)) (modules obj) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -647,7 +647,7 @@ (library ;; compiler/tests-compiler/obj_dup.ml (name obj_dup_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules obj_dup) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -662,7 +662,7 @@ (library ;; compiler/tests-compiler/rec.ml (name rec_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules rec) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -677,7 +677,7 @@ (library ;; compiler/tests-compiler/rec52.ml (name rec52_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules rec52) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -692,7 +692,7 @@ (library ;; compiler/tests-compiler/scopes.ml (name scopes_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules scopes) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -707,7 +707,7 @@ (library ;; compiler/tests-compiler/side_effect.ml (name side_effect_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules side_effect) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -722,7 +722,7 @@ (library ;; compiler/tests-compiler/sourcemap.ml (name sourcemap_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules sourcemap) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -737,7 +737,7 @@ (library ;; compiler/tests-compiler/static_eval.ml (name static_eval_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules static_eval) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -752,7 +752,7 @@ (library ;; compiler/tests-compiler/sys_command.ml (name sys_command_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules sys_command) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -767,7 +767,7 @@ (library ;; compiler/tests-compiler/sys_fs.ml (name sys_fs_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules sys_fs) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -782,7 +782,7 @@ (library ;; compiler/tests-compiler/tailcall.ml (name tailcall_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules tailcall) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -797,7 +797,7 @@ (library ;; compiler/tests-compiler/target_env.ml (name target_env_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules target_env) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -812,7 +812,7 @@ (library ;; compiler/tests-compiler/test_string.ml (name test_string_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules test_string) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -827,7 +827,7 @@ (library ;; compiler/tests-compiler/unix_fs.ml (name unix_fs_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules unix_fs) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests @@ -842,7 +842,7 @@ (library ;; compiler/tests-compiler/variable_declaration_output.ml (name variable_declaration_output_15) - (enabled_if %{env:js-enabled=}) + (enabled_if true) (modules variable_declaration_output) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests diff --git a/compiler/tests-compiler/gen-rules/gen.ml b/compiler/tests-compiler/gen-rules/gen.ml index 4781edde62..2595d3adac 100644 --- a/compiler/tests-compiler/gen-rules/gen.ml +++ b/compiler/tests-compiler/gen-rules/gen.ml @@ -72,10 +72,6 @@ let enabled_if = function | LT52 -> "(< %{ocaml_version} 5.2)" | B64 -> "%{arch_sixtyfour}" -let js_enabled = function - | "true" -> "%{env:js-enabled=}" - | x -> Printf.sprintf "(and %s %%{env:js-enabled=})" x - let () = Array.to_list (Sys.readdir ".") |> List.filter ~f:is_implem @@ -103,6 +99,6 @@ let () = basename basename (Hashtbl.hash prefix mod 100) - (js_enabled (enabled_if (lib_enabled_if basename))) + (enabled_if (lib_enabled_if basename)) basename (enabled_if (test_enabled_if basename))) diff --git a/compiler/tests-compiler/rec52.ml b/compiler/tests-compiler/rec52.ml index 18d766eeaf..87e13f1e32 100644 --- a/compiler/tests-compiler/rec52.ml +++ b/compiler/tests-compiler/rec52.ml @@ -44,6 +44,11 @@ let%expect_test "let rec" = in let p = compile_and_parse p in print_program p; + let s = [%expect.output] in + let s = + Str.global_replace (Str.regexp "runtime.caml_make_vect") "runtime.caml_array_make" s + in + print_endline s; [%expect {| (function(globalThis){ @@ -61,7 +66,7 @@ let%expect_test "let rec" = Stdlib_Hashtbl = global_data.Stdlib__Hashtbl, letrec_function_context = [], c = [], - d = runtime.caml_make_vect(5, 0), + d = runtime.caml_array_make(5, 0), default$0 = 42; function a(x){return b(x);} function b(x){ diff --git a/compiler/tests-dynlink-js/dune b/compiler/tests-dynlink-js/dune index 52df5f5de0..23e6869ba2 100644 --- a/compiler/tests-dynlink-js/dune +++ b/compiler/tests-dynlink-js/dune @@ -1,6 +1,5 @@ (executable (name main) - (enabled_if %{env:js-enabled=}) (modules main) (libraries js_of_ocaml) (link_flags @@ -35,7 +34,6 @@ (rule (target main.js) - (enabled_if %{env:js-enabled=}) (action (run %{bin:js_of_ocaml} @@ -79,7 +77,6 @@ (rule (target main.out) - (enabled_if %{env:js-enabled=}) (deps plugin.js plugin2.js) (action (with-outputs-to @@ -88,7 +85,6 @@ (rule (target main.out2) - (enabled_if %{env:js-enabled=}) (deps plugin.js plugin2.js) (action (with-outputs-to @@ -96,13 +92,11 @@ (run %{bin:node} %{dep:./main.bc.js})))) (rule - (alias runtest) - (enabled_if %{env:js-enabled=}) + (alias runtest-js) (action (diff main.out.expected main.out))) (rule - (alias runtest) - (enabled_if %{env:js-enabled=}) + (alias runtest-js) (action (diff main.out.expected main.out2))) diff --git a/compiler/tests-dynlink-js/effects_flags.ml b/compiler/tests-dynlink-js/effects_flags.ml index c0fce23c94..ef0fe616ba 100644 --- a/compiler/tests-dynlink-js/effects_flags.ml +++ b/compiler/tests-dynlink-js/effects_flags.ml @@ -6,7 +6,7 @@ let () = let major = String.split_on_char '.' Sys.ocaml_version |> List.hd |> int_of_string in let has_effect l = match l with - | [ "using-effects" ] -> major >= 5 + | [ "with-effects" ] -> major >= 5 | _ -> false in let aux l = enable (has_effect l) "effects" in diff --git a/compiler/tests-dynlink/dune b/compiler/tests-dynlink/dune index 37de0cb1cc..cd9b8a03fb 100644 --- a/compiler/tests-dynlink/dune +++ b/compiler/tests-dynlink/dune @@ -1,13 +1,11 @@ (executable (name main) - (enabled_if %{env:js-enabled=}) (modules main) (libraries dynlink js_of_ocaml-compiler.dynlink) (modes byte)) (rule (target main.js) - (enabled_if %{env:js-enabled=}) (deps plugin.cmo export) (action (run @@ -27,7 +25,6 @@ (rule (target main.out) - (enabled_if %{env:js-enabled=}) (deps plugin.cmo) (action (with-outputs-to @@ -35,7 +32,6 @@ (run %{bin:node} %{dep:./main.js})))) (rule - (alias runtest) - (enabled_if %{env:js-enabled=}) + (alias runtest-js) (action (diff main.out.expected main.out))) diff --git a/compiler/tests-io/cat.expected b/compiler/tests-io/cat.expected new file mode 100644 index 0000000000..6376bc646b --- /dev/null +++ b/compiler/tests-io/cat.expected @@ -0,0 +1 @@ +echo ☠ \ No newline at end of file diff --git a/compiler/tests-io/cat_nat.expected b/compiler/tests-io/cat_nat.expected new file mode 100644 index 0000000000..6376bc646b --- /dev/null +++ b/compiler/tests-io/cat_nat.expected @@ -0,0 +1 @@ +echo ☠ \ No newline at end of file diff --git a/compiler/tests-io/dune b/compiler/tests-io/dune index 184846813e..7133304edd 100644 --- a/compiler/tests-io/dune +++ b/compiler/tests-io/dune @@ -1,84 +1,72 @@ -(executables - (names cat md5) - (modes - js - wasm - (best exe))) - -(rule - (target cat-native.stdout) +(tests + (names cat) + (modes js wasm) (action - (with-stdout-to - %{target} - (pipe-stdout - (run printf "echo ☠") - (run %{dep:./cat.exe}))))) + (pipe-stdout + (run printf "echo ☠") + (run node %{test})))) -(rule - (target cat-js.stdout) +(tests + (names cat_nat) + (modes + (best exe)) (action - (with-stdout-to - %{target} - (pipe-stdout - (run printf "echo ☠") - (run node %{dep:./cat.bc.js}))))) + (pipe-stdout + (run printf "echo ☠") + (run %{test})))) (rule - (alias runtest) + (copy cat.ml cat_nat.ml)) + +(tests + (names md5) + (modes js wasm) (action - (diff cat-js.stdout cat-native.stdout))) + (progn + (run node %{test} %{dep:some-random-file}) + (run node %{test} %{dep:some-random-file} %{dep:some-random-file}) + (run node %{test} -offset 2000 -length 4000 %{dep:some-random-file}) + (pipe-stdout + (echo "tests") + (run node %{test})) + (pipe-stdout + (echo "teststeststests") + (run node %{test} -offset 5 -length 5)) + (pipe-stdout + (echo "teststeststests") + (run node %{test} -offset 2 -length 5))))) -(rule +(tests + (names md5_nat) + (modes + (best exe)) (action - (copy cat.bc.wasm.js cat.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) + (progn + (run %{test} %{dep:some-random-file}) + (run %{test} %{dep:some-random-file} %{dep:some-random-file}) + (run %{test} -offset 2000 -length 4000 %{dep:some-random-file}) + (pipe-stdout + (echo "tests") + (run %{test})) + (pipe-stdout + (echo "teststeststests") + (run %{test} -offset 5 -length 5)) + (pipe-stdout + (echo "teststeststests") + (run %{test} -offset 2 -length 5))))) (rule - (target md5-native.stdout) - (action - (with-stdout-to - %{target} - (progn - (run %{dep:md5.exe} %{dep:md5.bc.js}) - (run %{dep:md5.exe} %{dep:md5.bc.js} %{dep:md5.bc.js}) - (run %{dep:md5.exe} -offset 2000 -length 4000 %{dep:md5.bc.js}) - (pipe-stdout - (echo "tests") - (run %{dep:md5.exe})) - (pipe-stdout - (echo "teststeststests") - (run %{dep:md5.exe} -offset 5 -length 5)) - (pipe-stdout - (echo "teststeststests") - (run %{dep:md5.exe} -offset 2 -length 5)))))) + (copy md5.ml md5_nat.ml)) (rule - (target md5-js.stdout) - (action - (with-stdout-to - %{target} - (progn - (run node %{dep:md5.bc.js} %{dep:md5.bc.js}) - (run node %{dep:md5.bc.js} %{dep:md5.bc.js} %{dep:md5.bc.js}) - (run node %{dep:md5.bc.js} -offset 2000 -length 4000 %{dep:md5.bc.js}) - (pipe-stdout - (echo "tests") - (run node %{dep:md5.bc.js})) - (pipe-stdout - (echo "teststeststests") - (run node %{dep:md5.bc.js} -offset 5 -length 5)) - (pipe-stdout - (echo "teststeststests") - (run node %{dep:md5.bc.js} -offset 2 -length 5)))))) + (copy ../../manual/files/performances/time.png some-random-file)) (rule (alias runtest) (action - (diff md5-js.stdout md5-native.stdout))) + (diff md5.expected md5_nat.expected))) (rule + (alias runtest) (action - (copy md5.bc.wasm.js md5.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) + (diff cat.expected cat_nat.expected))) diff --git a/compiler/tests-io/md5.expected b/compiler/tests-io/md5.expected new file mode 100644 index 0000000000..1d196c833b --- /dev/null +++ b/compiler/tests-io/md5.expected @@ -0,0 +1,7 @@ +98a6d248b8d781e302522d18943d632b some-random-file +98a6d248b8d781e302522d18943d632b some-random-file +98a6d248b8d781e302522d18943d632b some-random-file +fcdf6d9d92ef3fd857ae75ee36b30e48 some-random-file +b61a6d542f9036550ba9c401c80f00ef - +b61a6d542f9036550ba9c401c80f00ef - +cf30c4ad3850e515e283b3f4e9e3fa3f - diff --git a/compiler/tests-io/md5_nat.expected b/compiler/tests-io/md5_nat.expected new file mode 100644 index 0000000000..1d196c833b --- /dev/null +++ b/compiler/tests-io/md5_nat.expected @@ -0,0 +1,7 @@ +98a6d248b8d781e302522d18943d632b some-random-file +98a6d248b8d781e302522d18943d632b some-random-file +98a6d248b8d781e302522d18943d632b some-random-file +fcdf6d9d92ef3fd857ae75ee36b30e48 some-random-file +b61a6d542f9036550ba9c401c80f00ef - +b61a6d542f9036550ba9c401c80f00ef - +cf30c4ad3850e515e283b3f4e9e3fa3f - diff --git a/compiler/tests-jsoo/bin/dune b/compiler/tests-jsoo/bin/dune index ed7615c013..a74de7ba77 100644 --- a/compiler/tests-jsoo/bin/dune +++ b/compiler/tests-jsoo/bin/dune @@ -1,119 +1,21 @@ -(executables +(tests (names error1 error2) - (modes exe js wasm) + (modes js wasm) (foreign_stubs (language c) (names named_value_stubs)) (js_of_ocaml (javascript_files runtime.js)) - (libraries)) - -(rule - (target error1.js.actual) - (deps error1.html) - (alias runtest) - (action - (with-accepted-exit-codes - 2 - (with-outputs-to - %{target} - (run node %{dep:error1.bc.js}))))) - -(rule - (target error1.exe.actual) - (alias runtest) - (action - (with-accepted-exit-codes - 2 - (with-outputs-to - %{target} - (run %{dep:error1.exe}))))) - -(rule - (alias runtest) - (action - (diff %{dep:error1.expected} %{dep:error1.js.actual}))) - -(rule - (alias runtest) - (action - (diff %{dep:error1.expected} %{dep:error1.exe.actual}))) - -(rule - (target error1-unregister.js.actual) - (deps error1-unregister.html) - (alias runtest) - (action - (with-accepted-exit-codes - 2 - (with-outputs-to - %{target} - (run node %{dep:error1.bc.js} unregister))))) - -(rule - (alias runtest) - (action - (diff %{dep:error1-unregister.expected} %{dep:error1-unregister.js.actual}))) - -(rule - (action - (copy error1.bc.wasm.js error1.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - -(rule - (target error2.js.actual) - (deps error2.html) - (alias runtest) - (action - (with-accepted-exit-codes - 2 - (with-outputs-to - %{target} - (run node %{dep:error2.bc.js}))))) - -(rule - (target error2.exe.actual) - (alias runtest) - (action - (with-accepted-exit-codes - 2 - (with-outputs-to - %{target} - (run %{dep:error2.exe}))))) - -(rule - (alias runtest) (enabled_if (= %{profile} dev)) (action - (diff %{dep:error2.expected} %{dep:error2.js.actual}))) - -(rule - (alias runtest) - (enabled_if - (= %{profile} dev)) - (action - (diff %{dep:error2.expected} %{dep:error2.exe.actual}))) - -(rule - (target error2-unregister.js.actual) - (deps error2-unregister.html) - (alias runtest) - (action - (with-accepted-exit-codes - 2 - (with-outputs-to - %{target} - (run node %{dep:error2.bc.js} unregister))))) - -(rule - (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 - (not %{env:js-enabled=}))) + (pipe-outputs + (progn + (with-accepted-exit-codes + 2 + (run node %{test})) + (with-accepted-exit-codes + 2 + (run node %{test} unregister))) + (run cat))) + (libraries)) diff --git a/compiler/tests-jsoo/bin/error1-unregister.expected b/compiler/tests-jsoo/bin/error1-unregister.expected deleted file mode 100644 index fa6fc3697b..0000000000 --- a/compiler/tests-jsoo/bin/error1-unregister.expected +++ /dev/null @@ -1 +0,0 @@ -Fatal error: exception Dune__exe__Error1.D(2, "test", _) diff --git a/compiler/tests-jsoo/bin/error1.expected b/compiler/tests-jsoo/bin/error1.expected index f020be1805..0cd209728b 100644 --- a/compiler/tests-jsoo/bin/error1.expected +++ b/compiler/tests-jsoo/bin/error1.expected @@ -1 +1,2 @@ Fatal error: exception custom printer +Fatal error: exception Dune__exe__Error1.D(2, "test", _) diff --git a/compiler/tests-jsoo/bin/error2-unregister.expected b/compiler/tests-jsoo/bin/error2-unregister.expected deleted file mode 100644 index f622dbe18b..0000000000 --- a/compiler/tests-jsoo/bin/error2-unregister.expected +++ /dev/null @@ -1 +0,0 @@ -Fatal error: exception Match_failure("compiler/tests-jsoo/bin/error2.ml", 13, 2) diff --git a/compiler/tests-jsoo/bin/error2.expected b/compiler/tests-jsoo/bin/error2.expected index 09937afc5a..ad8fdb68be 100644 --- a/compiler/tests-jsoo/bin/error2.expected +++ b/compiler/tests-jsoo/bin/error2.expected @@ -1 +1,2 @@ Fatal error: exception File "compiler/tests-jsoo/bin/error2.ml", line 13, characters 2-7: Pattern matching failed +Fatal error: exception Match_failure("compiler/tests-jsoo/bin/error2.ml", 13, 2) diff --git a/compiler/tests-jsoo/lib-effects/dune b/compiler/tests-jsoo/lib-effects/dune index 1e61456db8..ef92e93dbb 100644 --- a/compiler/tests-jsoo/lib-effects/dune +++ b/compiler/tests-jsoo/lib-effects/dune @@ -1,7 +1,4 @@ (env - (using-effects) - (wasm) - (wasm-effects) (_ (js_of_ocaml (flags diff --git a/compiler/tests-num/dune b/compiler/tests-num/dune index 5b48d2af79..38ac98ecbf 100644 --- a/compiler/tests-num/dune +++ b/compiler/tests-num/dune @@ -2,7 +2,6 @@ (name main) (modules main test_nats test test_big_ints test_ratios test_nums test_io) (libraries num) - (enabled_if %{env:js-enabled=}) (modes js (best exe)) diff --git a/compiler/tests-ocaml/lib-effects/dune b/compiler/tests-ocaml/lib-effects/dune index 1025666336..b025306dc4 100644 --- a/compiler/tests-ocaml/lib-effects/dune +++ b/compiler/tests-ocaml/lib-effects/dune @@ -1,13 +1,4 @@ (env - (using-effects - (flags - (:standard -w -38))) - (wasm - (flags - (:standard -w -38))) - (wasm-effects - (flags - (:standard -w -38))) (_ (flags (:standard -w -38)) diff --git a/compiler/tests-ocaml/lib-hashtbl/dune b/compiler/tests-ocaml/lib-hashtbl/dune index 9ef71618dc..f46f7976d4 100644 --- a/compiler/tests-ocaml/lib-hashtbl/dune +++ b/compiler/tests-ocaml/lib-hashtbl/dune @@ -3,7 +3,17 @@ (deps ../../../LICENSE) (modules hfun) (libraries) - (modes js wasm)) + (modes js)) + +(tests + (names hfun_wasm) + (deps ../../../LICENSE) + (modules hfun_wasm) + (libraries) + (modes wasm)) + +(rule + (copy hfun.ml hfun_wasm.ml)) (tests (names htbl) @@ -13,14 +23,3 @@ (>= %{ocaml_version} 5)) (libraries) (modes js wasm)) - -(rule - (action - (copy hfun.expected-js hfun.expected)) - (enabled_if %{env:js-enabled=})) - -(rule - (action - (copy hfun.expected-wasm hfun.expected)) - (enabled_if - (not %{env:js-enabled=}))) diff --git a/compiler/tests-ocaml/lib-hashtbl/hfun.expected-js b/compiler/tests-ocaml/lib-hashtbl/hfun.expected similarity index 100% rename from compiler/tests-ocaml/lib-hashtbl/hfun.expected-js rename to compiler/tests-ocaml/lib-hashtbl/hfun.expected diff --git a/compiler/tests-ocaml/lib-hashtbl/hfun.expected-wasm b/compiler/tests-ocaml/lib-hashtbl/hfun_wasm.expected similarity index 100% rename from compiler/tests-ocaml/lib-hashtbl/hfun.expected-wasm rename to compiler/tests-ocaml/lib-hashtbl/hfun_wasm.expected diff --git a/compiler/tests-sourcemap/dune b/compiler/tests-sourcemap/dune index 2582f218bc..1ffaaa9a63 100644 --- a/compiler/tests-sourcemap/dune +++ b/compiler/tests-sourcemap/dune @@ -7,7 +7,7 @@ (name test) (modules test) (enabled_if - (<> %{profile} using-effects)) + (<> %{profile} with-effects)) (modes js) (js_of_ocaml (link_flags diff --git a/compiler/tests-toplevel/dune b/compiler/tests-toplevel/dune index 650ac90c16..f3eb01f5fb 100644 --- a/compiler/tests-toplevel/dune +++ b/compiler/tests-toplevel/dune @@ -1,6 +1,5 @@ (executables (names test_toplevel) - (enabled_if %{env:js-enabled=}) (libraries js_of_ocaml-compiler.dynlink compiler-libs.toplevel) (flags (:standard -linkall)) @@ -10,16 +9,13 @@ (rule (targets test_toplevel.js) - (enabled_if %{env:js-enabled=}) (action (run %{bin:js_of_ocaml} --toplevel %{dep:test_toplevel.bc} -o %{targets}))) (rule (target test_toplevel.bc.js.actual) (enabled_if - (and - (>= %{ocaml_version} 5.2) - %{env:js-enabled=})) + (>= %{ocaml_version} 5.2)) (action (with-stdout-to %{target} @@ -28,20 +24,16 @@ (rule (target test_toplevel.js.actual) (enabled_if - (and - (>= %{ocaml_version} 5.2) - %{env:js-enabled=})) + (>= %{ocaml_version} 5.2)) (action (with-stdout-to %{target} (run node %{dep:test_toplevel.js})))) (rule - (alias runtest) + (alias runtest-js) (enabled_if - (and - (>= %{ocaml_version} 5.2) - %{env:js-enabled=})) + (>= %{ocaml_version} 5.2)) (action (progn (diff test_toplevel.expected test_toplevel.bc.js.actual) diff --git a/dune b/dune index 1bd709e8a8..72e1b1d00f 100644 --- a/dune +++ b/dune @@ -1,42 +1,20 @@ (env (dev - (wasm_of_ocaml - (enabled_if false)) (flags (:standard -w +a-4-40-41-42-44-48-58-66-70)) - (env-vars - (js-enabled true))) - (using-effects - (wasm_of_ocaml - (enabled_if false)) + (binaries + (tools/node_wrapper.exe as node) + (tools/node_wrapper.exe as node.exe))) + (with-effects (js_of_ocaml (compilation_mode separate) (flags (:standard --enable effects)) (build_runtime_flags (:standard --enable effects))) - (env-vars - (js-enabled true))) - (wasm - (binaries - (tools/node_wrapper.sh as node)) - (js_of_ocaml - (enabled_if false)) - (wasm_of_ocaml - (compilation_mode separate)) - (env-vars - (js-enabled false))) - (wasm-effects (binaries - (tools/node_wrapper.sh as node)) - (js_of_ocaml - (enabled_if false)) - (wasm_of_ocaml - (compilation_mode separate) - (flags - (:standard --enable effects))) - (env-vars - (js-enabled false))) + (tools/node_wrapper.exe as node) + (tools/node_wrapper.exe as node.exe))) (bench_no_debug (flags (:standard \ -g)) @@ -44,11 +22,13 @@ (:standard \ -g)) (link_flags (:standard \ -g)) - (env-vars - (js-enabled true))) + (binaries + (tools/node_wrapper.exe as node) + (tools/node_wrapper.exe as node.exe))) (_ - (env-vars - (js-enabled true)))) + (binaries + (tools/node_wrapper.exe as node) + (tools/node_wrapper.exe as node.exe)))) (rule (targets version.ml.in) diff --git a/dune-workspace b/dune-workspace new file mode 100644 index 0000000000..c14dee8543 --- /dev/null +++ b/dune-workspace @@ -0,0 +1,9 @@ +(lang dune 3.17) + +(env + (_ + (wasm_of_ocaml + (enabled_if %{env:WASM_OF_OCAML=false}) + (runtest_alias runtest-wasm)) + (js_of_ocaml + (runtest_alias runtest-js)))) \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 842b7ba6b4..b3b69c6f3b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,9 +10,9 @@ Or a single one: $> dune build @examples//default ``` -Add the `--profile wasm` option to compile to Wasm: +Set the environment variable WASM_OF_OCAML=true to compile to Wasm: ``` -$> dune build @examples/boulderdash/default --profile wasm +$> WASM_OF_OCAML=true dune build @examples/boulderdash/default ``` Compilation artifacts can be found in `${REPO_ROOT}/_build/default/examples/`. @@ -23,4 +23,4 @@ to serve the files, for instance with the following command: ``` python -m http.server -d _build/default/examples/boulderdash/ ``` -and then open `http://localhost:8000` in a browser. +and then open `http://localhost:8000/index-wasm.html` in a browser. diff --git a/examples/boulderdash/dune b/examples/boulderdash/dune index 3f26cd2f5a..1ee863cc12 100644 --- a/examples/boulderdash/dune +++ b/examples/boulderdash/dune @@ -9,12 +9,6 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy boulderdash.bc.wasm.js boulderdash.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps @@ -23,3 +17,8 @@ maps.txt (glob_files maps/*.map) (glob_files sprites/*.{png,svg}))) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps boulderdash.bc.wasm.js index-wasm.html)) diff --git a/compiler/tests-jsoo/bin/error3-unregister.html b/examples/boulderdash/index-wasm.html similarity index 57% rename from compiler/tests-jsoo/bin/error3-unregister.html rename to examples/boulderdash/index-wasm.html index 183acb3ca6..156cc27e45 100644 --- a/compiler/tests-jsoo/bin/error3-unregister.html +++ b/examples/boulderdash/index-wasm.html @@ -3,11 +3,10 @@ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> - Error 1 + Boulder Dash - - + + + diff --git a/examples/cubes/dune b/examples/cubes/dune index f945ab2f69..f3e636e515 100644 --- a/examples/cubes/dune +++ b/examples/cubes/dune @@ -5,12 +5,11 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy cubes.bc.wasm.js cubes.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps cubes.bc.js index.html)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps cubes.bc.wasm.js index-wasm.html)) diff --git a/examples/cubes/index-wasm.html b/examples/cubes/index-wasm.html new file mode 100644 index 0000000000..0982ade76b --- /dev/null +++ b/examples/cubes/index-wasm.html @@ -0,0 +1,11 @@ + + + + + Cubes + + + + + diff --git a/examples/graph_viewer/dune b/examples/graph_viewer/dune index e67a55a769..cb2b13f823 100644 --- a/examples/graph_viewer/dune +++ b/examples/graph_viewer/dune @@ -20,12 +20,11 @@ (ocamllex dot_lexer) -(rule - (action - (copy viewer_js.bc.wasm.js viewer_js.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps viewer_js.bc.js scene.json index.html)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps viewer_js.bc.wasm.js index-wasm.html)) diff --git a/examples/graph_viewer/index-wasm.html b/examples/graph_viewer/index-wasm.html new file mode 100644 index 0000000000..fd159d55a7 --- /dev/null +++ b/examples/graph_viewer/index-wasm.html @@ -0,0 +1,11 @@ + + + + + Graph viewer + + + + + diff --git a/examples/graphics/dune b/examples/graphics/dune index da1fd0f113..a334f53883 100644 --- a/examples/graphics/dune +++ b/examples/graphics/dune @@ -5,12 +5,11 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy main.bc.wasm.js main.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps main.bc.js index.html)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps main.bc.wasm.js index-wasm.html)) diff --git a/examples/graphics/index-wasm.html b/examples/graphics/index-wasm.html new file mode 100644 index 0000000000..fb26bed754 --- /dev/null +++ b/examples/graphics/index-wasm.html @@ -0,0 +1,28 @@ + + + + + Graphics_js + + + + + + + + + diff --git a/examples/hyperbolic/dune b/examples/hyperbolic/dune index 7a6788b708..887651c79a 100644 --- a/examples/hyperbolic/dune +++ b/examples/hyperbolic/dune @@ -14,12 +14,6 @@ (preprocess (pps js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json))) -(rule - (action - (copy hypertree.bc.wasm.js hypertree.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps @@ -30,3 +24,8 @@ tree.json (glob_files icons/*.{png,jpg}) (glob_files thumbnails/*.{png,jpg}))) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps hypertree.bc.wasm.js index-wasm.html)) diff --git a/examples/hyperbolic/index-wasm.html b/examples/hyperbolic/index-wasm.html new file mode 100644 index 0000000000..212060b091 --- /dev/null +++ b/examples/hyperbolic/index-wasm.html @@ -0,0 +1,83 @@ + + + + + Hyperbolic tree + + + + + + + + + + + diff --git a/examples/minesweeper/dune b/examples/minesweeper/dune index 12a574195b..4de8ce9221 100644 --- a/examples/minesweeper/dune +++ b/examples/minesweeper/dune @@ -5,15 +5,14 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy main.bc.wasm.js main.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps main.bc.js index.html (glob_files sprites/*.{png,svg}))) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps main.bc.wasm.js index-wasm.html)) diff --git a/examples/minesweeper/index-wasm.html b/examples/minesweeper/index-wasm.html new file mode 100644 index 0000000000..23dd8d33b3 --- /dev/null +++ b/examples/minesweeper/index-wasm.html @@ -0,0 +1,13 @@ + + + + + Minesweeper + + + + +
+ + diff --git a/examples/namespace/dune b/examples/namespace/dune index f616007252..1425466219 100644 --- a/examples/namespace/dune +++ b/examples/namespace/dune @@ -58,7 +58,6 @@ (run node for-node.js)))) (rule - (alias runtest) - (enabled_if %{env:js-enabled=}) + (alias runtest-js) (action (diff %{dep:for-node.expected} %{dep:for-node.actual}))) diff --git a/examples/planet/dune b/examples/planet/dune index c1c9db4ec8..8e50318e57 100644 --- a/examples/planet/dune +++ b/examples/planet/dune @@ -5,12 +5,11 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy planet.bc.wasm.js planet.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps planet.bc.js index.html texture.jpg)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps planet.bc.wasm.js index-wasm.html)) diff --git a/examples/planet/index-wasm.html b/examples/planet/index-wasm.html new file mode 100644 index 0000000000..b6a74e335e --- /dev/null +++ b/examples/planet/index-wasm.html @@ -0,0 +1,20 @@ + + + + + Planet + + + + + + diff --git a/examples/separate_compilation/dune b/examples/separate_compilation/dune index 8f0cc22b6e..0874fa21fd 100644 --- a/examples/separate_compilation/dune +++ b/examples/separate_compilation/dune @@ -109,14 +109,12 @@ (run node ./bin.js)))) (rule - (alias runtest) - (enabled_if %{env:js-enabled=}) + (alias runtest-js) (action (diff bin.expected bin.actual))) (alias (name default) - (enabled_if %{env:js-enabled=}) (deps myruntime.js stdlib.cma.js diff --git a/examples/test_wheel/dune b/examples/test_wheel/dune index 09de8f259d..ba4be3c0a9 100644 --- a/examples/test_wheel/dune +++ b/examples/test_wheel/dune @@ -4,9 +4,3 @@ (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) - -(rule - (action - (copy test_wheel.bc.wasm.js test_wheel.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) diff --git a/examples/test_wheel/index-wasm.html b/examples/test_wheel/index-wasm.html new file mode 100644 index 0000000000..df73e71331 --- /dev/null +++ b/examples/test_wheel/index-wasm.html @@ -0,0 +1,12 @@ + + + + + test_wheel + + + + + + + diff --git a/examples/webgl/dune b/examples/webgl/dune index dd0cbcdd3e..c2766ae5d5 100644 --- a/examples/webgl/dune +++ b/examples/webgl/dune @@ -7,12 +7,11 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy webgldemo.bc.wasm.js webgldemo.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps webgldemo.bc.js monkey.model index.html)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps webgldemo.bc.wasm.js index-wasm.html)) diff --git a/examples/webgl/index-wasm.html b/examples/webgl/index-wasm.html new file mode 100644 index 0000000000..36e4fe6a94 --- /dev/null +++ b/examples/webgl/index-wasm.html @@ -0,0 +1,51 @@ + + + + + WebGL monkey + + + + + + + +
frames per second
+ + diff --git a/examples/wiki/dune b/examples/wiki/dune index ee357ad4a6..9cbefbfba2 100644 --- a/examples/wiki/dune +++ b/examples/wiki/dune @@ -7,12 +7,11 @@ (ocamllex wikicreole) -(rule - (action - (copy main.bc.wasm.js main.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps main.bc.js index.html)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps main.bc.wasm.js index-wasm.html)) diff --git a/examples/wiki/index-wasm.html b/examples/wiki/index-wasm.html new file mode 100644 index 0000000000..9f3d5c5dc2 --- /dev/null +++ b/examples/wiki/index-wasm.html @@ -0,0 +1,12 @@ + + + + + Realtime wiki syntax parsing + + + + + + diff --git a/examples/wysiwyg/dune b/examples/wysiwyg/dune index ef6b073cbe..fe2810c5aa 100644 --- a/examples/wysiwyg/dune +++ b/examples/wysiwyg/dune @@ -5,12 +5,11 @@ (preprocess (pps js_of_ocaml-ppx))) -(rule - (action - (copy main.bc.wasm.js main.bc.js)) - (enabled_if - (not %{env:js-enabled=}))) - (alias (name default) (deps main.bc.js index.html)) + +(alias + (name default) + (enabled_if %{env:WASM_OF_OCAML=false}) + (deps main.bc.wasm.js index-wasm.html)) diff --git a/examples/wysiwyg/index-wasm.html b/examples/wysiwyg/index-wasm.html new file mode 100644 index 0000000000..b6270a4ebc --- /dev/null +++ b/examples/wysiwyg/index-wasm.html @@ -0,0 +1,12 @@ + + + + + Kakadu's WYSIWYG wiki editor + + + + + + diff --git a/lib/tests/dune.inc b/lib/tests/dune.inc index b7f107eb24..85b9beb929 100644 --- a/lib/tests/dune.inc +++ b/lib/tests/dune.inc @@ -32,7 +32,7 @@ (library ;; lib/tests/test_fun_call.ml (name test_fun_call_75) - (enabled_if (<> %{profile} using-effects)) + (enabled_if (<> %{profile} with-effects)) (modules test_fun_call) (libraries js_of_ocaml unix) (inline_tests (modes js)) diff --git a/lib/tests/gen-rules/gen.ml b/lib/tests/gen-rules/gen.ml index 56eb329f6f..980e2f0cc8 100644 --- a/lib/tests/gen-rules/gen.ml +++ b/lib/tests/gen-rules/gen.ml @@ -83,7 +83,7 @@ let () = (match enabled_if basename with | Any | Not_wasm -> "true" | GE5 -> "(>= %{ocaml_version} 5)" - | No_effects_not_wasm -> "(<> %{profile} using-effects)") + | No_effects_not_wasm -> "(<> %{profile} with-effects)") basename (match enabled_if basename with | Any -> " wasm" diff --git a/ppx/ppx_deriving_json/tests/dune b/ppx/ppx_deriving_json/tests/dune index 2e9ac54928..5e2a598458 100644 --- a/ppx/ppx_deriving_json/tests/dune +++ b/ppx/ppx_deriving_json/tests/dune @@ -27,9 +27,7 @@ (rule (alias runtest) (enabled_if - (and - (>= %{ocaml_version} 5.1) - %{env:js-enabled=})) + (>= %{ocaml_version} 5.1)) ;; (package js_of_ocaml-ppx) (action (diff ppx.mlt ppx.mlt.corrected))) @@ -37,9 +35,7 @@ (rule (alias runtest) (enabled_if - (and - (>= %{ocaml_version} 5.1) - %{env:js-enabled=})) + (>= %{ocaml_version} 5.2)) ;; (package js_of_ocaml-ppx) (action (diff gen.mlt gen.mlt.corrected))) diff --git a/tools/dune b/tools/dune new file mode 100644 index 0000000000..7532203a08 --- /dev/null +++ b/tools/dune @@ -0,0 +1,3 @@ +(executable + (name node_wrapper) + (libraries unix)) diff --git a/tools/node_wrapper.ml b/tools/node_wrapper.ml new file mode 100644 index 0000000000..6cb569e4bc --- /dev/null +++ b/tools/node_wrapper.ml @@ -0,0 +1,46 @@ +let extra_args_for_wasoo = + [ "--experimental-wasm-imported-strings" + ; "--experimental-wasm-stack-switching" + ; "--stack-size=10000" + ] + +let env = Unix.environment () + +let env = + Array.map + (fun e -> + if String.starts_with ~prefix:"PATH=" e + then + let path_sep = if Sys.win32 then ';' else ':' in + let path = String.sub e 5 (String.length e - 5) in + match String.split_on_char path_sep path with + | _drop :: paths -> + let paths = String.concat (String.make 1 path_sep) paths in + "PATH=" ^ paths + | _ -> e + else e) + env + +let args = + match Array.to_list Sys.argv with + | exe :: argv -> + let argv = + match argv with + | file :: _ when Filename.check_suffix file ".wasm.js" -> + extra_args_for_wasoo @ argv + | _ -> argv + in + Array.of_list (exe :: argv) + | [] -> assert false + +let () = + if Sys.win32 + then + let pid = + Unix.create_process_env "node.exe" args env Unix.stdin Unix.stdout Unix.stderr + in + match Unix.waitpid [] pid with + | _, WEXITED n -> exit n + | _, WSIGNALED _ -> exit 9 + | _, WSTOPPED _ -> exit 9 + else Unix.execvpe "node" args env diff --git a/tools/node_wrapper.sh b/tools/node_wrapper.sh deleted file mode 100755 index 9912795db0..0000000000 --- a/tools/node_wrapper.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -export PATH=$(echo $PATH | cut -d : -f 2-) # Do not call oneself recursively -exec node --experimental-wasm-imported-strings --experimental-wasm-stack-switching --stack-size=10000 "$@" diff --git a/toplevel/examples/eval/dune b/toplevel/examples/eval/dune index 76fc91026c..a9f4c6827d 100644 --- a/toplevel/examples/eval/dune +++ b/toplevel/examples/eval/dune @@ -1,6 +1,5 @@ (executables (names eval) - (enabled_if %{env:js-enabled=}) (libraries js_of_ocaml-compiler js_of_ocaml-toplevel) (link_flags (:standard -linkall)) @@ -10,14 +9,12 @@ (rule (targets export.txt) - (enabled_if %{env:js-enabled=}) (deps eval.bc) (action (run jsoo_listunits -o %{targets} stdlib))) (rule (targets eval.js) - (enabled_if %{env:js-enabled=}) (action (run %{bin:js_of_ocaml} @@ -31,5 +28,4 @@ (alias (name default) - (enabled_if %{env:js-enabled=}) (deps eval.js index.html)) diff --git a/toplevel/examples/lwt_toplevel/dune b/toplevel/examples/lwt_toplevel/dune index 13a6048862..65a80eba6e 100644 --- a/toplevel/examples/lwt_toplevel/dune +++ b/toplevel/examples/lwt_toplevel/dune @@ -1,6 +1,5 @@ (executables (names toplevel) - (enabled_if %{env:js-enabled=}) (libraries js_of_ocaml-compiler js_of_ocaml-tyxml @@ -157,7 +156,6 @@ (rule (targets toplevel.js) - (enabled_if %{env:js-enabled=}) (action (run %{bin:js_of_ocaml} @@ -186,5 +184,4 @@ (alias (name default) - (enabled_if %{env:js-enabled=}) (deps toplevel.js toplevel.bc.js index.html)) diff --git a/toplevel/test/dune b/toplevel/test/dune index b56071400e..2f5f8f18fa 100644 --- a/toplevel/test/dune +++ b/toplevel/test/dune @@ -35,7 +35,6 @@ (run node ./test_toplevel.js)))) (rule - (alias runtest) - (enabled_if %{env:js-enabled=}) + (alias runtest-js) (action (diff test_toplevel.expected test_toplevel.actual)))