you’re saying these tools don’t support preprocessing with PPX, right? If so, you could preprocess before invoking the ocaml tools. From reverse-engineering what dune does, I believe dune always preprocesses before invoking ocaml. So that’s one way to do it.
If you’re using ocamlfind, it isn’t very difficult to figure out the preprocessing commands, though I can understand why it would be a bit of a pain. So I wrote a little tool,
ocamlfind2 (that merely trampolines over to
ocamlfind for everything else) that supports a command
preprocess. It takes all the arguments as
ocamlfind ocamlc (at least, those that concern preprocessing) and runs the preprocessor. I wrote it so I could debug PPX rewriters and camlp5, but hey, it might be useful to you.
ocamlfind2 preprocess -package camlp5,compiler-libs.common,ounit2,fmt,pcre,rresult,compiler-libs.common,yojson,sexplib,ounit2,ppx_import,ppx_deriving.show,ppx_deriving.eq,ppx_deriving.ord,ppx_deriving.enum,ppx_deriving.iter,ppx_deriving.map,ppx_deriving.fold,ppx_deriving.make,ppx_deriving_yojson,ppx_here test_deriving_show.ml.ppx.ml > test_deriving_show.ml.ppx.ppo
[my apologies for the lack of -any- documentation – the tool really is just something i wrote for my own needs, though I do plan to release it at some point, b/c this sort of thing is useful for sure.]