This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,66 @@
|
|||
$ . ../../git-helpers.sh
|
||||
|
||||
Jsoo and build-info
|
||||
|
||||
$ echo "(lang dune 3.0)" > dune-project
|
||||
$ dune build
|
||||
Warning [missing-debug-event]: '--source-map' is enabled but the bytecode program was compiled with no debugging information.
|
||||
Consider passing '-g' option to ocamlc.
|
||||
$ node _build/default/src/main.bc.js
|
||||
unknown
|
||||
$ dune install --prefix _install --display short
|
||||
Installing _install/lib/main/META
|
||||
Installing _install/lib/main/dune-package
|
||||
Installing _install/lib/main/opam
|
||||
Installing _install/bin/main
|
||||
Installing _install/bin/main.bc.js
|
||||
$ node _install/bin/main.bc.js
|
||||
unknown
|
||||
$ git init -q
|
||||
$ touch README
|
||||
$ git add README
|
||||
$ git commit -m "initial" -q
|
||||
$ git tag v1 -am "V1"
|
||||
$ git commit -m "empty2" --allow-empty -q
|
||||
$ echo "HELLO" > README
|
||||
$ dune build
|
||||
Warning [missing-debug-event]: '--source-map' is enabled but the bytecode program was compiled with no debugging information.
|
||||
Consider passing '-g' option to ocamlc.
|
||||
$ node _build/default/src/main.bc.js
|
||||
unknown
|
||||
$ dune install --prefix _install --display short
|
||||
Deleting _install/lib/main/META
|
||||
Installing _install/lib/main/META
|
||||
Deleting _install/lib/main/dune-package
|
||||
Installing _install/lib/main/dune-package
|
||||
Deleting _install/lib/main/opam
|
||||
Installing _install/lib/main/opam
|
||||
Deleting _install/bin/main
|
||||
Installing _install/bin/main
|
||||
Deleting _install/bin/main.bc.js
|
||||
Installing _install/bin/main.bc.js
|
||||
Installing _install/doc/main/README
|
||||
$ node _install/bin/main.bc.js
|
||||
v1-1-xxxxx-dirty
|
||||
$ echo "(name main)" >> dune-project
|
||||
$ echo "(version 0.2.0)" >> dune-project
|
||||
$ dune build
|
||||
Warning [missing-debug-event]: '--source-map' is enabled but the bytecode program was compiled with no debugging information.
|
||||
Consider passing '-g' option to ocamlc.
|
||||
$ node _build/default/src/main.bc.js
|
||||
0.2.0
|
||||
$ dune install --prefix _install --display short
|
||||
Deleting _install/lib/main/META
|
||||
Installing _install/lib/main/META
|
||||
Deleting _install/lib/main/dune-package
|
||||
Installing _install/lib/main/dune-package
|
||||
Deleting _install/lib/main/opam
|
||||
Installing _install/lib/main/opam
|
||||
Deleting _install/bin/main
|
||||
Installing _install/bin/main
|
||||
Deleting _install/bin/main.bc.js
|
||||
Installing _install/bin/main.bc.js
|
||||
Deleting _install/doc/main/README
|
||||
Installing _install/doc/main/README
|
||||
$ node _build/default/src/main.bc.js
|
||||
0.2.0
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
(executable
|
||||
(name main)
|
||||
(public_name main)
|
||||
(modes js byte)
|
||||
(modules main)
|
||||
(package main)
|
||||
(libraries dune-build-info))
|
||||
|
||||
(install
|
||||
(section bin)
|
||||
(files main.bc.js))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
let version =
|
||||
match Build_info.V1.version () with
|
||||
| None -> "unknown"
|
||||
| Some v -> Build_info.V1.Version.to_string v
|
||||
|
||||
let () = match String.split_on_char '-' version with
|
||||
| [tag; plus; _commit; dirty] -> Printf.printf "%s-%s-%s-%s" tag plus "xxxxx" dirty
|
||||
| [ x ] -> print_endline x
|
||||
| _ -> print_endline "unexpected"
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
(cram
|
||||
(deps %{bin:node} %{bin:js_of_ocaml})
|
||||
(alias runtest-js))
|
||||
|
||||
(cram
|
||||
(applies_to inline-tests)
|
||||
(enabled_if
|
||||
(<> "macosx" %{ocaml-config:system}))
|
||||
(deps
|
||||
(package ppx_expect)))
|
||||
|
||||
(cram
|
||||
(applies_to build-info)
|
||||
(deps
|
||||
%{bin:git}
|
||||
../git-helpers.sh
|
||||
(package dune-build-info)))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.0)
|
||||
> EOF
|
||||
$ cat >dune <<EOF
|
||||
> (env (_ (js_of_ocaml (flags :standard "--no-inline"))))
|
||||
> (library (name test))
|
||||
> EOF
|
||||
$ dune printenv --field js_of_ocaml_flags --field js_of_ocaml_link_flags --field js_of_ocaml_build_runtime_flags 2>&1
|
||||
(js_of_ocaml_flags
|
||||
(--pretty --no-inline))
|
||||
(js_of_ocaml_build_runtime_flags (--pretty))
|
||||
(js_of_ocaml_link_flags ())
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(library
|
||||
(name foo))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Anonymous projects have explicit_js_mode enabled
|
||||
|
||||
$ echo '(lang dune 2.8)' > dune-project
|
||||
$ dune build --display short @all 2>&1 | grep -F .js
|
||||
[1]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
(executable
|
||||
(name a)
|
||||
(modules a))
|
||||
|
||||
(executable
|
||||
(name b)
|
||||
(modes js)
|
||||
(modules b))
|
||||
|
||||
(library
|
||||
(name foo)
|
||||
(modules c))
|
||||
|
||||
(test
|
||||
(name d)
|
||||
(modules d))
|
||||
|
||||
(executable
|
||||
(name e)
|
||||
(modules e)
|
||||
(modes js)
|
||||
(libraries foo))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(lang dune 1.11)
|
||||
(explicit_js_mode)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
Check that .bc.js rule is generated only if js mode is used.
|
||||
|
||||
$ dune build a.bc.js
|
||||
Error: Don't know how to build a.bc.js
|
||||
Hint: did you mean b.bc.js or e.bc.js?
|
||||
[1]
|
||||
|
||||
$ dune build b.bc.js
|
||||
|
||||
We also check that .cmo.js rules are not generated if not specified.
|
||||
|
||||
$ dune build _build/default/.a.eobjs/jsoo/a.cmo.js
|
||||
Error: Don't know how to build _build/default/.a.eobjs/jsoo/a.cmo.js
|
||||
[1]
|
||||
|
||||
JS compilation of libraries is always available to avoid having to annotate
|
||||
every dependency of an executable.
|
||||
|
||||
$ dune build _build/default/.foo.objs/jsoo/default/foo.cma.js
|
||||
|
||||
Check that js targets are attached to @all, but not for tests that do not
|
||||
specify js mode (#1940).
|
||||
|
||||
$ dune clean
|
||||
$ dune build --display short @@all 2>&1 | grep js_of_ocaml
|
||||
js_of_ocaml .b.eobjs/jsoo/b.bc.runtime.js
|
||||
js_of_ocaml .e.eobjs/jsoo/e.bc.runtime.js
|
||||
js_of_ocaml .js/default/stdlib/stdlib.cma.js
|
||||
js_of_ocaml .js/default/stdlib/std_exit.cmo.js
|
||||
js_of_ocaml .b.eobjs/jsoo/b.cmo.js
|
||||
js_of_ocaml b.bc.js
|
||||
js_of_ocaml .foo.objs/jsoo/default/foo.cma.js
|
||||
js_of_ocaml .e.eobjs/jsoo/e.cmo.js
|
||||
js_of_ocaml e.bc.js
|
||||
|
||||
Check that building a JS-enabled executable that depends on a library works.
|
||||
|
||||
$ dune clean
|
||||
$ dune build e.bc.js
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
This test demonstrates a bug in dune's separation compilation of jsoo.
|
||||
std_exit.cmo wasn't being linked in the end, which was causing at_exit hooks not
|
||||
being ran and channels not being flushed.
|
||||
|
||||
Setup fixtures:
|
||||
|
||||
$ echo "(lang dune 2.6)" > dune-project
|
||||
$ echo 'let () = print_string "bla"' > main.ml
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (name main)
|
||||
> (modes js))
|
||||
> EOF
|
||||
|
||||
Test without separate compilation:
|
||||
|
||||
$ dune build --profile=release ./main.bc.js
|
||||
$ node _build/default/main.bc.js
|
||||
bla
|
||||
|
||||
Test with separate compilation:
|
||||
|
||||
$ dune build --profile=dev ./main.bc.js
|
||||
$ node _build/default/main.bc.js
|
||||
bla
|
||||
|
||||
The result should be the same
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let _ = assert (Sys.backend_type = Bytecode)
|
||||
let _ = print_endline "inline tests (Byte)"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(name inline_tests_byte)
|
||||
(inline_tests (modes byte) (backend fake_backend)))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(library
|
||||
(name fake_backend)
|
||||
(modules ())
|
||||
(inline_tests.backend
|
||||
(generate_runner
|
||||
(progn
|
||||
(echo "[@@@warning \"-40\"]\n")
|
||||
(cat %{impl-files})))))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(library
|
||||
(name inline_tests_js_alias)
|
||||
(inline_tests (modes byte js) (backend fake_backend)))
|
||||
|
||||
(env
|
||||
(_
|
||||
(js_of_ocaml
|
||||
(runtest_alias runtest-js))))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
let _ =
|
||||
Printf.eprintf
|
||||
"inline tests (%s - alias)\n"
|
||||
(match Sys.backend_type with
|
||||
| Native -> "Native"
|
||||
| Bytecode -> "Byte"
|
||||
| Other _ -> "JS")
|
||||
;;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name inline_tests_js)
|
||||
(js_of_ocaml (javascript_files js.js))
|
||||
(inline_tests (modes js) (backend fake_backend)))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
//Provides:jsoo_stubs
|
||||
function jsoo_stubs() { return 1 }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
external prim : unit -> bool = "jsoo_stubs"
|
||||
|
||||
let _ = assert (Sys.int_size = 32)
|
||||
let _ = assert (prim ())
|
||||
let _ = print_endline "inline tests (JS)"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(name inline_tests_native)
|
||||
(inline_tests (modes native) (backend fake_backend)))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let _ = assert (Sys.backend_type = Native)
|
||||
let _ = print_endline "inline tests (Native)"
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
Run inline tests using node js
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.0)
|
||||
> EOF
|
||||
|
||||
(With the dev profile on OCaml 5, the warning is expected)
|
||||
|
||||
$ dune runtest
|
||||
inline tests (Byte)
|
||||
inline tests (Byte)
|
||||
inline tests (Byte - alias)
|
||||
inline tests (Byte - alias)
|
||||
inline tests (Native)
|
||||
inline tests (Native)
|
||||
Warning [missing-effects-backend]: your program contains effect handlers; you should probably run js_of_ocaml with option '--effects=cps'
|
||||
inline tests (JS)
|
||||
inline tests (JS)
|
||||
|
||||
CR-Alizter: This test has a different behaviour for the macos-latest in the CI and additionally runs the (Byte) tests. This seems unintentional and should be investigated. For now this test is disabled on macos.
|
||||
|
||||
$ dune runtest --profile release
|
||||
Warning [missing-effects-backend]: your program contains effect handlers; you should probably run js_of_ocaml with option '--effects=cps'
|
||||
inline tests (JS)
|
||||
inline tests (JS)
|
||||
inline tests (Native)
|
||||
inline tests (Native)
|
||||
|
||||
$ dune build js/.inline_tests_js.inline-tests/inline_test_runner_inline_tests_js.bc
|
||||
Error: Don't know how to build
|
||||
js/.inline_tests_js.inline-tests/inline_test_runner_inline_tests_js.bc
|
||||
[1]
|
||||
|
||||
$ dune build @runtest-js
|
||||
Warning [missing-effects-backend]: your program contains effect handlers; you should probably run js_of_ocaml with option '--effects=cps'
|
||||
inline tests (JS - alias)
|
||||
inline tests (JS - alias)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let name = "bin1"
|
||||
let hello name = print_endline ("Hi " ^ name)
|
||||
|
||||
let () = Library1.hello name
|
||||
|
||||
let () = hello Library1.name
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let name = "bin2"
|
||||
let hello name = print_endline ("Hi " ^ name)
|
||||
|
||||
let () = Library1.hello name
|
||||
|
||||
let () = hello Library1.name
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let name = "bin3"
|
||||
let hello name = print_endline ("Hi " ^ name)
|
||||
|
||||
let () = Library1.hello name
|
||||
|
||||
let () = hello Library1.name
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
(executable
|
||||
(name bin1)
|
||||
(modules bin1)
|
||||
(modes js)
|
||||
(libraries library1)
|
||||
(js_of_ocaml
|
||||
(flags (:standard --enable use-js-string))))
|
||||
|
||||
(executable
|
||||
(name bin2)
|
||||
(modules bin2)
|
||||
(modes js)
|
||||
(libraries library1)
|
||||
(js_of_ocaml
|
||||
(flags (:standard --disable use-js-string))))
|
||||
|
||||
(executable
|
||||
(name bin3)
|
||||
(modules bin3)
|
||||
(modes js)
|
||||
(libraries library1)
|
||||
(js_of_ocaml
|
||||
(flags (:standard --effects=cps))))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(env
|
||||
(_
|
||||
(js_of_ocaml
|
||||
(flags (:standard --quiet))
|
||||
(compilation_mode separate))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.0)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(library
|
||||
(name library1)
|
||||
(js_of_ocaml
|
||||
;; This will be ignored as the library is compiled once for every effect
|
||||
;; config and then the version needed by each individual executable is used
|
||||
(flags (:standard --effects=double-translation))))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let name = "library1"
|
||||
|
||||
let hello name = print_endline ("Hello " ^ name)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
This tests a js_of_ocaml config of linking the same library with different,
|
||||
incompatible `--effects` flags
|
||||
|
||||
$ dune build bin/bin1.bc.js bin/bin2.bc.js bin/bin3.bc.js
|
||||
$ node _build/default/bin/bin1.bc.js
|
||||
Hello bin1
|
||||
Hi library1
|
||||
$ node _build/default/bin/bin2.bc.js
|
||||
Hello bin2
|
||||
Hi library1
|
||||
$ node _build/default/bin/bin3.bc.js
|
||||
Hello bin3
|
||||
Hi library1
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let name = "bin1"
|
||||
let hello name = print_endline ("Hi " ^ name)
|
||||
|
||||
let () = Library1.hello name
|
||||
|
||||
let () = hello Library1.name
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let name = "bin2"
|
||||
let hello name = print_endline ("Hi " ^ name)
|
||||
|
||||
let () = Library1.hello name
|
||||
|
||||
let () = hello Library1.name
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let name = "bin3"
|
||||
let hello name = print_endline ("Hi " ^ name)
|
||||
|
||||
let () = Library1.hello name
|
||||
|
||||
let () = hello Library1.name
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
(executable
|
||||
(name bin1)
|
||||
(modules bin1)
|
||||
(modes js)
|
||||
(libraries library1)
|
||||
(js_of_ocaml
|
||||
(flags (:standard --enable use-js-string))))
|
||||
|
||||
(executable
|
||||
(name bin2)
|
||||
(modules bin2)
|
||||
(modes js)
|
||||
(libraries library1)
|
||||
(js_of_ocaml
|
||||
(flags (:standard --disable use-js-string))))
|
||||
|
||||
(executable
|
||||
(name bin3)
|
||||
(modules bin3)
|
||||
(modes js)
|
||||
(libraries library1))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(env
|
||||
(_
|
||||
(js_of_ocaml
|
||||
(flags (:standard --quiet))
|
||||
(compilation_mode separate))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.0)
|
||||
|
|
@ -0,0 +1 @@
|
|||
(library (name library1))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let name = "library1"
|
||||
|
||||
let hello name = print_endline ("Hello " ^ name)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
tests js_of_ocaml conigs
|
||||
|
||||
$ dune build bin/bin1.bc.js bin/bin2.bc.js bin/bin3.bc.js
|
||||
$ node _build/default/bin/bin1.bc.js
|
||||
Hello bin1
|
||||
Hi library1
|
||||
$ node _build/default/bin/bin2.bc.js
|
||||
Hello bin2
|
||||
Hi library1
|
||||
$ node _build/default/bin/bin3.bc.js
|
||||
Hello bin3
|
||||
Hi library1
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
We check that .bc-for-jsoo targets are built with -noautolink and do not depend
|
||||
on the shared stubs of dependent libraries.
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.7)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (library
|
||||
> (name libA)
|
||||
> (modules libA)
|
||||
> (foreign_stubs
|
||||
> (language c)
|
||||
> (names stubsA)))
|
||||
> (executable
|
||||
> (name mainA)
|
||||
> (libraries libA)
|
||||
> (modules mainA)
|
||||
> (modes js))
|
||||
> EOF
|
||||
$ touch stubsA.c mainA.ml libA.ml
|
||||
|
||||
$ dune build --display verbose --profile release mainA.bc.js 2>&1 | sed -n 's#.*\(-o mainA.bc-for-jsoo .*\)#\1#p'
|
||||
-o mainA.bc-for-jsoo -no-check-prims -noautolink libA.cma .mainA.eobjs/byte/dune__exe__MainA.cmo)
|
||||
|
||||
The file dlllibA_stubs.so should not appear in the next list.
|
||||
|
||||
$ find _build/default | sort
|
||||
_build/default
|
||||
_build/default/.dune
|
||||
_build/default/.dune/configurator
|
||||
_build/default/.dune/configurator.v2
|
||||
_build/default/.libA.objs
|
||||
_build/default/.libA.objs/byte
|
||||
_build/default/.libA.objs/byte/libA.cmi
|
||||
_build/default/.libA.objs/byte/libA.cmo
|
||||
_build/default/.libA.objs/byte/libA.cmt
|
||||
_build/default/.mainA.eobjs
|
||||
_build/default/.mainA.eobjs/byte
|
||||
_build/default/.mainA.eobjs/byte/dune__exe__MainA.cmi
|
||||
_build/default/.mainA.eobjs/byte/dune__exe__MainA.cmo
|
||||
_build/default/.mainA.eobjs/byte/dune__exe__MainA.cmt
|
||||
_build/default/.mainA.eobjs/byte/dune__exe__MainA.cmti
|
||||
_build/default/.merlin-conf
|
||||
_build/default/.merlin-conf/exe-mainA
|
||||
_build/default/.merlin-conf/lib-libA
|
||||
_build/default/libA.cma
|
||||
_build/default/libA.ml
|
||||
_build/default/mainA.bc-for-jsoo
|
||||
_build/default/mainA.bc.js
|
||||
_build/default/mainA.ml
|
||||
_build/default/mainA.mli
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(executables
|
||||
(names technologic)
|
||||
(libraries js_of_ocaml x)
|
||||
(js_of_ocaml
|
||||
(flags (:standard))
|
||||
(javascript_files runtime.js)))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
global.globalPrintFunction = function(x){
|
||||
console.log(x);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module Js = Js_of_ocaml.Js
|
||||
|
||||
let _ =
|
||||
print_endline X.buy_it;
|
||||
let obj = Js.Unsafe.obj [|"name", Js.Unsafe.inject (Js.string Z.use_it)|] in
|
||||
Printf.printf "%s\n%!" (X.print obj);
|
||||
X.external_print (Js.string "break it");
|
||||
(fun x ->
|
||||
let global = Js.Unsafe.get Js.Unsafe.global "global" in
|
||||
let globalPrintFunction : Js.js_string Js.t -> unit =
|
||||
Js.Unsafe.get global "globalPrintFunction" in
|
||||
globalPrintFunction x
|
||||
) (Js.string "fix it")
|
||||
|
|
@ -0,0 +1 @@
|
|||
let use_it = "use it"
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.11)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(library
|
||||
(name x)
|
||||
(libraries js_of_ocaml)
|
||||
(public_name x)
|
||||
(js_of_ocaml
|
||||
(flags (--pretty)) (javascript_files runtime.js)))
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
|
||||
//Provides: jsPrint
|
||||
function jsPrint(x){
|
||||
console.log(x);
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module Js = Js_of_ocaml.Js
|
||||
|
||||
let buy_it = "buy " ^ Y.it
|
||||
let print x = Js.to_string (Js.Unsafe.get x "name")
|
||||
external external_print : Js.js_string Js.t -> unit = "jsPrint"
|
||||
|
|
@ -0,0 +1 @@
|
|||
let it = "it"
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
Compilation using jsoo
|
||||
|
||||
$ dune build --display short bin/technologic.bc.js @install 2>&1 | \
|
||||
> sed s,^\ *$(ocamlc -config-var c_compiler),\ \ C_COMPILER,g
|
||||
ocamldep bin/.technologic.eobjs/technologic.impl.d
|
||||
ocamldep lib/.x.objs/x.impl.d
|
||||
ocamlc lib/.x.objs/byte/x__.{cmi,cmo,cmt}
|
||||
ocamldep lib/.x.objs/x__Y.impl.d
|
||||
js_of_ocaml bin/.technologic.eobjs/jsoo/technologic.bc.runtime.js
|
||||
ocamldep bin/.technologic.eobjs/z.impl.d
|
||||
ocamlopt lib/.x.objs/native/x__.{cmx,o}
|
||||
ocamlc lib/.x.objs/byte/x__Y.{cmi,cmo,cmt}
|
||||
js_of_ocaml .js/default/stdlib/stdlib.cma.js
|
||||
js_of_ocaml .js/default/stdlib/std_exit.cmo.js
|
||||
ocamlopt lib/.x.objs/native/x__Y.{cmx,o}
|
||||
ocamlc lib/.x.objs/byte/x.{cmi,cmo,cmt}
|
||||
js_of_ocaml .js/default/js_of_ocaml-compiler.runtime/jsoo_runtime.cma.js
|
||||
ocamlopt lib/.x.objs/native/x.{cmx,o}
|
||||
ocamlc bin/.technologic.eobjs/byte/z.{cmi,cmo,cmt}
|
||||
ocamlc lib/x.cma
|
||||
js_of_ocaml .js/default/js_of_ocaml/js_of_ocaml.cma.js
|
||||
ocamlopt lib/x.{a,cmxa}
|
||||
ocamlc bin/.technologic.eobjs/byte/technologic.{cmi,cmo,cmt}
|
||||
js_of_ocaml lib/.x.objs/jsoo/default/x.cma.js
|
||||
ocamlopt lib/x.cmxs
|
||||
js_of_ocaml bin/.technologic.eobjs/jsoo/z.cmo.js
|
||||
js_of_ocaml bin/.technologic.eobjs/jsoo/technologic.cmo.js
|
||||
js_of_ocaml bin/technologic.bc.js
|
||||
$ node ./_build/default/bin/technologic.bc.js
|
||||
buy it
|
||||
use it
|
||||
break it
|
||||
fix it
|
||||
$ dune build bin/technologic.bc.js @install --profile release
|
||||
$ node ./_build/default/bin/technologic.bc.js
|
||||
buy it
|
||||
use it
|
||||
break it
|
||||
fix it
|
||||
$ cat >dune-workspace <<EOF
|
||||
> (lang dune 2.0)
|
||||
> (context
|
||||
> (default (disable_dynamically_linked_foreign_archives true)))
|
||||
> EOF
|
||||
$ dune build bin/technologic.bc.js @install --profile dev
|
||||
$ dune build bin/technologic.bc.js @install --profile release
|
||||
|
|
@ -0,0 +1 @@
|
|||
let x = 12
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(public_name foo.a)
|
||||
(name a))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(executable
|
||||
(name main)
|
||||
(libraries a)
|
||||
(modes js))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let _ = A.x
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(lang dune 3.7)
|
||||
|
||||
(package (name foo))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Compilation of libraries with public-names
|
||||
|
||||
$ dune build
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(executables
|
||||
(names technologic)
|
||||
(libraries js_of_ocaml x)
|
||||
(js_of_ocaml
|
||||
(flags (:standard))
|
||||
(javascript_files runtime.js)))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
global.globalPrintFunction = function(x){
|
||||
console.log(x);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module Js = Js_of_ocaml.Js
|
||||
|
||||
let _ =
|
||||
print_endline X.buy_it;
|
||||
let obj = Js.Unsafe.obj [|"name", Js.Unsafe.inject (Js.string Z.use_it)|] in
|
||||
Printf.printf "%s\n%!" (X.print obj);
|
||||
X.external_print (Js.string "break it");
|
||||
(fun x ->
|
||||
let global = Js.Unsafe.get Js.Unsafe.global "global" in
|
||||
let globalPrintFunction : Js.js_string Js.t -> unit =
|
||||
Js.Unsafe.get global "globalPrintFunction" in
|
||||
globalPrintFunction x
|
||||
) (Js.string "fix it")
|
||||
|
|
@ -0,0 +1 @@
|
|||
let use_it = "use it"
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.11)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(library
|
||||
(name x)
|
||||
(libraries js_of_ocaml)
|
||||
(public_name x)
|
||||
(js_of_ocaml
|
||||
(flags (--pretty)) (javascript_files runtime.js))
|
||||
(c_names stubs))
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
|
||||
//Provides: jsPrint
|
||||
function jsPrint(x){
|
||||
console.log(x);
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
void jsPrint () { fprintf(stderr, "Unimplemented Javascript primitive myPrint!\n"); exit(1); }
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module Js = Js_of_ocaml.Js
|
||||
|
||||
let buy_it = "buy " ^ Y.it
|
||||
let print x = Js.to_string (Js.Unsafe.get x "name")
|
||||
external external_print : Js.js_string Js.t -> unit = "jsPrint"
|
||||
|
|
@ -0,0 +1 @@
|
|||
let it = "it"
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
Compilation using jsoo
|
||||
$ dune build bin/technologic.bc.js @install --profile dev
|
||||
$ node ./_build/default/bin/technologic.bc.js
|
||||
buy it
|
||||
use it
|
||||
break it
|
||||
fix it
|
||||
$ dune build @install --profile release
|
||||
$ node ./_build/default/bin/technologic.bc.js
|
||||
buy it
|
||||
use it
|
||||
break it
|
||||
fix it
|
||||
|
||||
Compilation using jsoo with disable_dynamically_linked_foreign_archives = true
|
||||
|
||||
$ cat >dune-workspace <<EOF
|
||||
> (lang dune 2.0)
|
||||
> (context
|
||||
> (default (disable_dynamically_linked_foreign_archives true)))
|
||||
> EOF
|
||||
$ dune clean
|
||||
$ dune build bin/technologic.bc.js @install --profile dev
|
||||
|
||||
Js_of_ocaml whole program compilation works with
|
||||
disable_dynamically_linked_foreign_archives = true:
|
||||
|
||||
$ dune build bin/technologic.bc.js @install --profile release
|
||||
|
||||
We expect a runtime error when running this bc-for-jsoo file.
|
||||
|
||||
$ ! if dune exe bin/technologic.bc-for-jsoo ; then true ; else false ; fi 2> /dev/null
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(executable
|
||||
(name main)
|
||||
(libraries mylib)
|
||||
(modes js)
|
||||
(js_of_ocaml
|
||||
(sourcemap file)))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let a,b = 1,2
|
||||
let () = Printf.printf "%d + %d = %d\n%!" a b (Mylib.add a b)
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.17 )
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(library
|
||||
(name mylib))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let add a b = a + b
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
$ dune build bin/main.bc.js
|
||||
|
||||
$ ls _build/default/bin
|
||||
main.bc.js
|
||||
main.bc.map
|
||||
main.ml
|
||||
main.mli
|
||||
|
||||
$ dune clean
|
||||
$ dune build bin/main.bc.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "a: ok"
|
||||
|
|
@ -0,0 +1 @@
|
|||
b: ok
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "b: ok"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
(tests
|
||||
(names a b)
|
||||
(modes byte js))
|
||||
|
||||
(env
|
||||
(_
|
||||
(js_of_ocaml
|
||||
(runtest_alias runtest-js)
|
||||
(compilation_mode whole_program))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.0)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
tests stanza with jsoo
|
||||
|
||||
There should anly be one 'ok' here since we only want to run the js mode tests.
|
||||
|
||||
$ dune build @default @runtest-js
|
||||
a: ok
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "a: ok"
|
||||
|
|
@ -0,0 +1 @@
|
|||
b: ok
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "b: ok"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(tests
|
||||
(names a b)
|
||||
(js_of_ocaml (compilation_mode whole_program))
|
||||
(modes js))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.17)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
tests stanza with jsoo
|
||||
|
||||
$ dune build @runtest
|
||||
a: ok
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.20)
|
||||
> EOF
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (executable
|
||||
> (name main)
|
||||
> (modes js)
|
||||
> (modules_without_implementation interface))
|
||||
> EOF
|
||||
|
||||
$ cat > main.ml <<EOF
|
||||
> let _ = Interface.Foo
|
||||
> EOF
|
||||
|
||||
$ cat > interface.mli <<EOF
|
||||
> type t = Foo
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
Loading…
Add table
Add a link
Reference in a new issue