[wg-camlp4] ocamlfind and -ppx option

Peter Zotov whitequark at whitequark.org
Thu May 15 14:44:01 BST 2014


On 2014-05-12 22:38, Gerd Stolpmann wrote:
> I think the user should simply invoke a ppx with
> 
> ocamlfind ... -syntax ppx_tools ...
> 
> (maybe with a subpackage ppx_tools.ppx_metaquot if there are several
> commands in the same package), just in the same way as it is currently
> possible with camlp4. findlib would have to figure out what to do. For
> constructing the -pp switch findlib is looking for a
> 
> preprocessor = ...
> 
> setting in the package or some ancestor. Similarly, it could look for a
> 
> ppx = ...
> 
> setting to construct the -ppx switch.

There is a valid point against that solution. Currently, the idiom for
invoking camlp4 extensions is to pass "-package foo.syntax", which
would internally specify the correct options to the camlp4 invocation.

As such, both the users and the tooling expect that it is possible to
fully activate an extension by passing a single -package option, which
would then require all the necessary components and pass all the flags.

In particular, OASIS makes it very convenient to pass -package options
(the BuildDepends: field), but not -syntax ones (you have to use both
ByteOpt: and NativeOpt: fields).

In addition, it's much more user-friendly if you consider the toplevel:
a single #require "package.syntax";; is much better than a disparate 
combo
of #require and #syntax.

This also avoids the need to disambiguate -syntax for camlp4 and ppx
extensions, and is simpler conceptually.

I have implemented this solution in a patchset:

1. Do not install safe_camlp4 if configured without it
https://github.com/whitequark/ocaml-findlib/commit/26d24392738c0232893115977b0c6b165dd89acb.diff
2. Interpret ppx directive in META files
https://github.com/whitequark/ocaml-findlib/commit/7862f3c7047376d6fa8cebfecadf71adc8b3d8e7.diff
3. Topfind support for ppx directive
https://github.com/whitequark/ocaml-findlib/commit/e45dd0a19b15d4697f15addae44a0f37802004b3.diff

Additionally, I have implemented a -ppxopt option, whose job is similar
to -ppopt: it passes additional arguments to ppx preprocessors. The 
syntax
is -ppxopt pkg,opt1,opt2,...:
https://github.com/whitequark/ocaml-findlib/commit/a24d53c04610efe204c7e9461d3b60e63b2d65de.diff

-- 
Peter Zotov
sip:whitequark at sipnet.ru



More information about the wg-camlp4 mailing list