[ANN] dune 3.14

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 bpattern 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.

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)

22 Likes

I never saw @doc-new before, where is it documented ? It is not part of the Built-In Aliases page.

It’s not documented, indeed. That’s a new driver for odoc which builds documentation for your packages and also external ones. It also uses a model closer to how docs are generated on ocaml.org. It’s still unstable and we hope to replace dune build @doc with it at some point. See doc: split files doc into smaller documents by emillon · Pull Request #9904 · ocaml/dune · GitHub.

1 Like

Thanks for the hard work on this!

I’m testing the dynamic_include feature, which we’re using a lot and the cyclic rules limitations seems very frustrating.

I’m trying to adapt a rule that needs all the files in doc/ to generate a dune.inc for doc/dune. How would you organize such dynamic import?

Yes, it’s a whole new pattern that’s not drop-in and will need a good how-to document. For now you can have a look at the PR, I think it has some examples and test cases demonstrating the feature.

I’m not seeing anything useful. Will file a ticket!

1 Like

We’re happy to announce that Dune 3.14.2 is now available.

Note that due to a regression that was detected before publishing to opam version 3.14.1 should not be used. The fix for the regression is part of this release.

This feature brings some small bugfixes around the handling of Coq as well as solves an issue where Dune is running on Windows in a path that contains Unicode characters. This affected e.g. users with diacritics or non-latin script in their name when running Dune within their home directory.

  • When a directory is changed to a file, correctly remove it in subsequent
    dune build runs. (#9327, fix #6575, @emillon)

  • Fix a problem with the doc-new target where transitive dependencies were
    missed during compile. This leads to missing expansions in the output docs.
    (#9955, @jonludlam)

  • coq: fix performance regression in coqdep unescaping (#10115, fixes #10088,
    @ejgallego, thanks to Dan Christensen for the report)

  • coq: memoize coqdep parsing, this will reduce build times for Coq users, in
    particular for those with many .v files (#10116, @ejgallego, see also #10088)

  • on Windows, use an unicode-aware version of CreateProcess to avoid crashes
    when paths contains non-ascii characters. (#10212, fixes #10180, @emillon)

  • fix compilation on non-glibc systems due to signal.h not being pulled in
    spawn stubs. (#10256, @emillon)

2 Likes