Description
Context
I've been working on allowing dune to use ppx in the past few months. If you want detailed context you can take a look at the original issue, the draft PR or this PR that makes use of it to derive Dyn.t
converters using a ppx in dune.
In short, since dune cannot have a build dependency on ppxlib we're going to include a preprocessed (.ml
or .mli
, not the marshalled AST) version of the source files that use any ppx in a specific folder of dune's source tree. These files will be used by the bootstrap program in place of the original files to build dune while in development, we will simply use ppx as we would in any other project and just keep that extra folder up to date.
This works well but at the moment, using a ppx in a library in dune means we're going to keep a copy of every single file composing it, even if they do not require to be preprocessed. What we would like is to instead only have a preprocessed copy if it's necessary.
We don't want to use the per module ppx specification as this requires a lot of configuration and maintenance over the time.
Feature
The most convenient way would be to have an option to tell the ppxlib driver not to produce an output file if it knows there is no rewriting to be done.
There are cases where the driver wouldn't be able to tell accurately, for instance with ppx that aren't written as context free rules but that's not the majority and likely something we won't use in dune.
I'm thinking of a fairly simple feature, no comparison between ASTs, just keeping track of context free rule applications. I.e. if there is no whole AST transformation registered and if none of the context free rule were applied, the driver would not produce an output.
Let me know what you think about adding such a feature.
I would of course take care of implementing it.