Add an example to build a toplevel
This commit is contained in:
parent
85ae1c75e4
commit
65a54f405b
|
@ -256,3 +256,28 @@ And run the tests with:
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
jbuilder runtest
|
jbuilder runtest
|
||||||
|
|
||||||
|
Building a custom toplevel
|
||||||
|
==========================
|
||||||
|
|
||||||
|
A toplevel is simply an executable calling ``Topmain.main ()`` and
|
||||||
|
linked with the compiler libraries and ``-linkall``. Moreover,
|
||||||
|
currently toplevels can only be built in bytecode.
|
||||||
|
|
||||||
|
As a result, write this in your ``jbuild`` file:
|
||||||
|
|
||||||
|
.. code:: scheme
|
||||||
|
|
||||||
|
(jbuild_version 1)
|
||||||
|
|
||||||
|
(executable
|
||||||
|
((name mytoplevel)
|
||||||
|
(libraries (compiler-libs.toplevel mylib))
|
||||||
|
(link_flags (-linkall))
|
||||||
|
(modes (byte))))
|
||||||
|
|
||||||
|
And write this in ``mytoplevel.ml``
|
||||||
|
|
||||||
|
.. code:: ocaml
|
||||||
|
|
||||||
|
let () = Topmain.main ()
|
||||||
|
|
Loading…
Reference in New Issue