Dune: rule to generate a file that may be present in the source tree

Hi,

I have a file that I want to store in compressed form in git but I also need it uncompressed when working with it, plus I want to store in dune how to create the compressed version.

This means I have a rule to generate foo.xz from foo and another one to generate foo from foo.xz. I only keep foo.xz in git (but I may have foo uncompressed in the source tree while working on the software).

Dune complains that it has several rules to create foo.xz: from fooand from the source tree. That’s obviously true but that also sounds like it shouldn’t be an issue in practice.

I’ve create a reproducer SpecialSnowflake/dune-regenerate-artifacts: Reproduce for cases where dune finds circular dependencies but may be too eager to avoid them - Codeberg.org .

I’ve tried various things using %{file-available} but this always ends with a circular dependency computing directory contents (because I have a deps on that file?).

Hopefully this is something simple that is already known and is easy to fix.

Thanks.

Yes, what you’re describing is mode fallback: If the output of a fallback rule already exists in the source tree the rule is basically dropped.

Check out the documentation of the rule stanza.

2 Likes

Thanks a lot, that’s indeed exactly what I needed.