Dune 3.14.0

We're happy to announce that Dune 3.14.0 is now available. This feature has many fixes and new features that you can find in the changelog.

There are a few new features that we would like to specially highlight.

Dynamic dune files with (dynamic_include)

It is common for some parts of a build to be dynamic: for example a source file can be generated, or some parts of the configuration like C flags can be generated from a Dune rule. But until now it was not possible to generate rules dynamically.

For example, one might want to do it is to set up one rule per input file. This is a common pattern in test suites and is easy to do with Make. But Dune does not have a concept of parameterized rules, so it is necessary to set up one rule per input file.

The pattern to do this with Dune is to:

  • Write a generator that lists the input files and emits Dune stanzas (as text);
  • Add a rule that makes a dune.inc file using this generator;
  • Add (include dune.inc) in the main dune file,

However, this requires checking in the generated dune.inc file in the repository. Another drawback is that when modifying the list of input files, it is necessary to run tests twice: one to update dune.inc, one to run the new test.

This release of Dune adds a new (dynamic_include) stanza that lifts these restrictions: dune.inc does not have to be part of the source tree, it can be generated transparently. This comes with some restrictions: some stanzas can not be generated, in particular the ones that define public libraries. And due to how rule loading works, the generated stanza needs to be defined in a different directory.

Still, this should be useful for many users that rely on the generate-include-commit pattern described above.

Sherlodoc integration

Sherlodoc is a search engine for OCaml documentation, which supports search by name, documentation and fuzzy type search (similar to Hoogle in the Haskell world). It can be obtained from opam using opam install sherlodoc.

When it is available, Dune commands that produce HTML documentation, such as dune build @doc and dune build @doc-new, will include a search bar in the generated output.

See full changelog

Added

  • Introduce a (dynamic_include ..) stanza. This is like (include foo) but allows foo to be the target of a rule. Currently, there are some limitations on the stanzas that can be generated. For example, public executables, libraries are currently forbidden. (#9913, @rgrinberg)

  • Introduce $ dune promotion list to print the list of available promotions. (#9705, @moyodiallo)

  • If Sherlodoc is installed, add a search bar in generated HTML docs (#9772, @EmileTrotignon)

  • Add only_sources field to copy_files stanza (#9827, fixes #9709, @jchavarri)

  • The (foreign_library) stanza now supports the (enabled_if) field. (#9914, @nojb)

Fixed

  • Fix $ dune install -p incorrectly recognizing packages that are supposed to be filtered (#9879, fixes #4814, @rgrinberg)

  • subst: correctly handle opam files in opam/ subdirectory (#9895, fixes #9862, @emillon)

  • Odoc private rules are not set up if a library is not available due to enabled_if (#9897, @rgrinberg and @jchavarri)

Changed

  • When dune language 3.14 is enabled, resolve the binary in (run %{bin:..} ..) from where the binary is built. (#9708, @rgrinberg)

  • boot: remove single-command bootstrap. This was an alternative bootstrap strategy that was used in certain conditions. Removal makes the bootstrap a bit slower on Linux when only a single core is available, but bootstrap is now reproducible in all cases. (#9735, fixes #9507, @emillon)