dune icon indicating copy to clipboard operation
dune copied to clipboard

Inferring empty library files when they are missing

Open ddickstein opened this issue 7 months ago • 4 comments

Similar to https://github.com/ocaml/dune/issues/11798, it would be great to have a mode where if a library file (my_lib.ml for the library my_lib) is missing nothing is exported from the library.

ddickstein avatar May 13 '25 14:05 ddickstein

This is trivial to achieve simply by adding an empty my_lib.ml. Not sure a special mode brings anything to the table. Note that you would still need to do something per library, adding a file does not seem more work than adding a flag to the stanza.

nojb avatar May 13 '25 19:05 nojb

@ddickstein are you perhaps also hinting that this mode would be the better default than the current default of exporting everything? Otherwise, I agree with Nicolas that adding a feature or this is not going to be materially easier than writing (rule (write-file lib.mli "")) in your dune file.

rgrinberg avatar May 13 '25 21:05 rgrinberg

I do think it's the better default but I at least wanted to have something I could put in all my dune files, which that rule would do. Could some sort of %{lib} variable be added (or is there one already) to make this easier (so all the files could just have (rule (write-file %{lib}.ml ""))?

ddickstein avatar May 13 '25 23:05 ddickstein

It's worth remembering that dune allows for more than one library per dune file. So there's no good value to pick for %{lib} in some cases.

I suppose adding a project based default value would be a good idea.

rgrinberg avatar May 14 '25 21:05 rgrinberg