The findlib User's Guide
Prev | Chapter 7. FAQs | Next

# Does Findlib support ppx-style preprocessors?

Short answer: Yes, but there is only little documentation.

Since findlib-1.5, ppx-style preprocessors are supported to some extent. A package can now define a "ppx" property which is simply a command to run as preprocessor (the command gets the marshalled AST as input, and must generate the transformed AST in its output; see the -ppx option of ocamlc/ocamlopt). A META file can simply look like:

    ppx = "./command"

when "command" is installed in the package directory (but you can also omit "./" to search it, and you can prefix it with "@name/" if the command is taken from another package "name").

For more complex scenarios, additional options or arguments for the ppx preprocessor can be specified in descendant packages with the "ppxopt" property. Package "A" might provide a generic ppx preprocessor with a META file containing

    ppx = "./generic_ppx"

Package B might instantiate that preprocessor with

    requires = "A"
    ppxopt = "A,ppx_b.cmo"

In this case "ocamlfind ocamlc -package B" would add `-ppx "path_to_A/genric_ppx ppx_b.cmo"` to the ocamlc invocation. The format of the "ppxopt" property is specified in the findlib reference manual.

This feature is still a bit experimental.

Prev | Home | Next
Does Findlib support camlp4? | Up | Why do some people install the .cmx files?