Let's say I have a file
src/template that is used to generate the file
theories/result.v using some tool that is difficult to run, and I add a rule
(rule (target result.v) (deps ../src/template) (action (run <complicated-tool-command>)))
To avoid everyone having to run this tool and this command, I add
theories/result.v into version control. This works fine using a Makefile. However, dune will complain:
Error: Multiple rules generated for _build/default/theories/result.v: - file present in source tree - theories/dune:XX Hint: rm -f theories/result.v
How can I avoid this error and get the usual make behavior, i.e.,
result.v is only regenerated if it is older than
You have two options:
(mode promote)and then have everyone pass
--ignore-promoted-rules. This is what's enabled
-pin release builds.
(mode fallback)and just check in the file. To regenerate it, just delete it in the source and dune will regenerate it by running the rule again.
To avoid everyone having to run this tool and this command
It also depend on how users are using your library. If they are just cloning it running
$ dune build, I recommend the 2nd approach. If they are installing it from opam, then the 1st approach is better.
thanks, I'm going with
fallback for now, this looks as follows for the benefit of others reading this:
(rule (target result.v) (deps ../src/template) (action (run <complicated-tool-command>)) (mode fallback))
Sounds good. Just for reference,
fallback was added to support
./configure like configuration. The idea would be that you'd have a
./configure script that would generate
config.ml in the source. Without this step, there would be a
fallback rule to create a default configuration.
Last updated: Oct 16 2021 at 09:07 UTC