genjsapi: installation and usage instructions
February 10, 2022 ยท View on GitHub
Dependencies
gen_js_api does not have any external build-time dependency except the OCaml compiler (version 4.03). Of course, it will be used in conjuncion with the js_of_ocaml compiler and runtime support.
Installation (with OPAM)
opam install gen_js_api
Or, to track the development version:
opam pin add gen_js_api https://github.com/LexiFi/gen_js_api.git
Manual installation
git clone https://github.com/LexiFi/gen_js_api.git
cd gen_js_api
make all
make install # assuming opam-installer is installed
Usage (with dune)
-
Invoking the standalone tool (
.mli->.mlgenerator):(rule (targets my_unit.ml) (deps my_unit.mli) (action (run %{bin:gen_js_api} %{deps}))) -
Compiling binding (
.mliand generated.mlfiles), user code which rely on theOjsor with the ppx processor:(executables (names test_jquery) (js_of_ocaml) (libraries ojs js_of_ocaml) (preprocess (pps gen_js_api.ppx)) (modes byte) ) -
Compiling into JavaScript: Just ask dune to build the
*.bc.jstarget. (e.g.dune build test_jquery.bc.js)
Usage (with ocamlfind)
-
Invoking the standalone tool (
.mli->.mlgenerator):ocamlfind gen_js_api/gen_js_api my_unit.mli -
Compiling binding (
.mliand generated.mlfiles) and user code which rely on theOjsmodule:ocamlfind ocamlc -package gen_js_api my_unit.mli ocamlfind ocamlc -package gen_js_api my_unit.ml -
Compiling with the ppx processor:
ocamlfind ocamlc -c -package gen_js_api my_prog.ml -
Linking the bytecode program:
ocamlfind ocamlc -o my_prog -package gen_js_api -linkpkg ... -
Compiling into JavaScript:
js_of_ocaml -o my_prog.js +gen_js_api/ojs_runtime.js my_prog