janestreet / ppx_optcomp

Optional compilation for OCaml
MIT License
65 stars 18 forks source link

How to use in conjunction with ppx_deriving? #1

Closed rgrinberg closed 6 years ago

rgrinberg commented 8 years ago

I've added ppx_deriving and ppx_optcomp as findlib packages but that doesn't seem to trigger the preprocessing as I get syntax error when I build (they go away when I remove the ppx_optcomp lines).

All I see the following findlib package https://github.com/janestreet/ppx_optcomp/blob/dbd6212be666376d138b66386f730fdd250452d3/META.ab#L9-L15

But it says not to use directly.

ghost commented 8 years ago

Ah, ppx_optcomp is not an AST mapper, so it can't be used as a -ppx. It can only be used as a pre-processor.

The standalone version is indeed missing from the repository, I'll add it soon. In the meantime, since ppx_optcomp is built-in ppx_driver, you can get it through ppx-jane:

$ cat test.ml 
#if true
let x = 1
#else
let y = 2
#endif

$ ocamlc -c -dsource -pp 'ppx-jane -apply "" -no-check' test.ml
let x = 1
rgrinberg commented 8 years ago

Has the standalone preprocessor been released? If so then I will close this issue.

hhugo commented 6 years ago

@diml, @rgrinberg, is this still an issue ?

rgrinberg commented 6 years ago

Not anymore