camlspotter/ocaml

Camleopard and ocamldep

Closed this issue · 2 comments

ocamlfind ocamldep -package leopard -syntax leopard x.ml tries to compile x.ml even when modules which it depends on are not compiled.

Currently ocamlfind has no way to change the preprocessor only for ocamldep. Therefore leopardc has no idea whether it is used for compilation or pure syntax preprocessing.

A possible workaround is to add an option to change the behaviour of leopardc: at any error, it prints out the original source code.

Another idea is to split leopardc to two preprocessors:

  • One is a simple PP which desugars its syntax extensions.
  • The other is a PPX which does the real program transformation.

Since PPXs are told what is the parent command is, it can change its behaviour if the parent is ocamldep.

I decided to take somewhat conservative solution using OCamlfind env var:

OCAMLFIND_COMMANDS='ocamlc=leopardc ocamlopt=leopardopt ocamldep=leoparddep