The documentation mentions “commands like dune build and dune runtest”. This works but unfortunately, it doesn’t work with the commands like dune build <target> that we use to save on build time.
Our use case is:
- We keep the opam package constraints in
dune-project. - Opam files are derived from
dune-projectby runningdune buildand ^C when the programmer remembers to do it. - The opam files are kept under version control.
- Our automated build (CI) uses the opam files to install the opam dependencies before building the project.
The problems are:
- Contributors don’t know or forget to run
dune buildafter editingdune-projectandmakedoesn’t call the exact commanddune buildeither. - After getting a CI failure (probably without knowing about
dune-project), contributors will modify the opam files manually and it will work until the files get overwritten accidentally bydune build. - We don’t want to run a full
dune buildbecause it takes too long.
Is there a fast command to regenerate the opam files from dune-project?
A workaround consists in calling this from a makefile:
$ timeout 0.5 dune build
This runs dune build and aborts after 0.5 s, which is sufficient to generate our opam files. The timeout command on my machine is from GNU and I don’t know yet if a compatible equivalent is installed by default on MacOS (the point is I don’t want to have to think about this).