ocamlfind icon indicating copy to clipboard operation
ocamlfind copied to clipboard

would an "ocamlfind preprocess" subcommand be useful?

Open chetmurthy opened this issue 4 years ago • 3 comments

It seems like, often there's a use for getting one's hands on the output of the preprocessing step of an "ocamlfind ocamlc ..." command. Both for debugging, but also for interfacing with dune. I can't find a way to do this right now ..... but I'm guessing that I could figure out how to implement it in not much time. Would this be useful? Is there something I'm missing?

Thanks in advance.

chetmurthy avatar Apr 24 '20 02:04 chetmurthy

Yes, that would be useful, but keep in mind that some preprocessors do not output text but the binary AST - which is understood by the compiler but not by a human. So you'd probably also need a pretty-printer for ASTs.

gerdstolpmann avatar Apr 29 '20 12:04 gerdstolpmann

I already have a little tool I wrote, a wrapper of Ocaml's compiler-libs, that prints a serialized AST. grin I'll write an addition to ocamlfind, then. I was considering writing a new "ocamlfind2" that would implement new commands, and fallback to the old ocamlfind for everything else, but if you're OK with putting this into ocamlfind, I won't bother.

chetmurthy avatar Apr 29 '20 17:04 chetmurthy

Gerd, a little progress-report. I have written a tool, "ocamlfind2", which implements the "preprocess" function (stealing code from the "ocamlc" entrypoint in frontend.ml), and use it regularly. I'm planning on implementing "reinstall-if-diff" in this little tool soon (busy/busy/busy with PPX rewriters). Two reasons I wrote this status update: (1) link: https://github.com/chetmurthy/ocamlfind2 (2) I'm -painfully- cognizant of the importance of ocamlfind to the ocaml ecosystem. It would ..... be incredibly embarrassing if some change I submitted, were to break ocamlfind. So .... I would propose that for a good while, we leave these commands in "ocamlfind2", and move them into ocamlfind. Actually, I don't think you ever commented on "reinstall-if-diff", so I do not mean to go so far as to suggest that you would even be open to moving reinstall-if-diff into ocamlfind, anyway.

Anyway, just thought I should give you a status update, since it's been a while and I've been silent about this.

chetmurthy avatar May 11 '20 05:05 chetmurthy