Why Do Many Dune Projects Contain a
Many Dune projects contain a root
Makefile. It’s often only there for
convenience for the following reasons:
- There are many different build systems out there, all with a different CLI.
If you have been hacking for a long time, the one true invocation you know
make && make install, possibly preceded by
- You often have a few common operations that aren’t part of the build, so
make <blah>is a good way to provide them.
makeis shorter to type than
dune build @install
How to Add a Configure Step to a Dune Project¶
The with-configure-step example shows one way to add a configure step that
preserves composability; i.e., it doesn’t require manually running the
./configure script when working on multiple projects simultaneously.
Can I Use
topkg with Dune?¶
How Do I Publish My Packages with Dune?¶
Dune is just a build system and considers publishing outside of its scope. However, the dune-release project is specifically designed for releasing Dune projects to opam. We recommend using this tool for publishing Dune packages.
Where Can I Find Some Examples of Projects Using Dune?¶
The dune-universe repository contains a snapshot of the latest versions of all opam packages that depend on Dune. Therefore, it’s a useful reference to find different approaches for constructing build rules.
What is Jenga?¶
jenga is a build system developed by Jane Street, mainly for internal use. It was never usable outside of Jane Street, so it’s not recommended for general use. It has no relationship to Dune apart from Dune being the successor to Jenga externally. Eventually, Dune is expected to replace Jenga internally at Jane Street as well.
How to Make Warnings Non-Fatal¶
jbuilder formerly displayed warnings, but most of them wouldn’t stop the build. However, Dune makes all warnings fatal by default. This can be a challenge when porting a codebase to Dune. There are two ways to make warnings non-fatal:
jbuildercompatibility executable works even with
dunefiles. You can use it while some warnings remain and then switch over to the
duneexecutable. This is the recommended way to handle the situation.
- You can pass
dune. It will set up different compilation options that usually make sense for release builds, including making warnings non-fatal. This is done by default when installing packages from opam.
- You can change the flags used by the
devprofile by adding the following stanza to a
(env (dev (flags (:standard -warn-error -A))))
How to Display the Output of Commands as They Run¶
When Dune runs external commands, it redirects and saves their output, then displays it when complete. This ensures that there’s no interleaving when writing to the console.
But this might not be what the you want. For example, when you debug a hanging build.
In that case, one can pass
-j1 --no-buffer so the commands are directly
printed on the console (and the parallelism is disabled so the output stays
How Can I Generate an
mli File From an
When a module starts as just an implementation (
.ml file), it can be
tedious to define the corresponding interface (
It is possible to use the
ocaml-print-intf program (available on opam
$ opam install ocaml-print-intf) to generate the right
$ dune exec -- ocaml-print-intf ocaml_print_intf.ml val root_from_verbose_output : string list -> string val target_from_verbose_output : string list -> string val build_cmi : string -> string val print_intf : string -> unit val version : unit -> string val usage : unit -> unit
ocaml_print-intf program has special support for Dune, so it will
automatically understand external dependencies.