Factorize dune rules for ocamlorg_frontend#1181
Factorize dune rules for ocamlorg_frontend#1181gpetiot wants to merge 3 commits intoocaml:mainfrom gpetiot:factorize-dune-rules-frontend
Conversation
|
Beautiful! Thanks a lot @gpetiot this is great. BTW, I discovered Dune's |
From what I understand, it's only used to specify formatting rules, but no build rules. The doc says:
|
|
That's my understanding of the docs too. I'm not sure if this discussion suggests otherwise or likewise: https://discuss.ocaml.org/t/htmx-hc-web-development-approach/9993/44 Maybe we should ask @emillon? |
|
You can use a dialect for this. A dialect is a way for dune to support an alternative syntax for ocaml files. That means that in addition to the usual You can optionally define a formatter for
This is a confusing sentence to say that by default, the "preprocessor" action is a no-op, and there is no default "formatting" action. If you define a dialect like this for the |
|
Sidenote, I had a look at the diff in this PR. If I understand correctly you're replacing N rules with each 1 dependency and 1 target, by a single rule that has N dependencies and N targets. I don't have the whole context but usually this is not the right move because it has the following drawbacks:
|
|
Thanks, @emillon, for this great insight. |
|
I tried a few things without success. The preprocessing of *.eml files generates empty *.eml.ml files, although the pp command looks alright (it was the same on the previous commit and no error is reported). |
|
I tried to define a wrapper around |
|
What is the status on this? Waiting for a dune release? |
|
Yes camlworks/dream#228 has been merged but dream has not been released yet |
|
The dune part has been released in 3.9.0. |
|
This is stalled, so closing, but to anyone who'd be interested in picking this up: a PR to factorize the rule using the new I was also wondering if we could simplify the whole build configuration by leveraging |
I noticed the duplications when adding new templates for the playground.
dream_emlaccepts many files and produces an.mlfile for each.emlfile. Maybe the former rules were an optimization to not rebuild everything but honestly I didn't notice any overhead with my patch, we don't have too many files. But the rules are much more maintainable now.