Is it currently possible to use ppx_deriving in a jbuilder project

jbuilder
ppx

#1

Is there a (not too complex) way to have jbuilder successfully build a small project relying on ppx_deriving?

“not too complex”: because I’ll do it with ocamlbuild if it appears to be simpler

I tried to add (preprocess (pps (ppx_deriving.enum))) to my library, but when compiling the relevant module, the functions that should be generated by ppx_deriving are not found.

Thanks for any tip


#2

As far as I can tell - no. I gave it a go to make ppx_deriving work with jbuilder a few weeks back https://github.com/whitequark/ppx_deriving/pull/135. However, due to time constraints I had to abandon my attempt. I am guessing ppx_deriving plugin based design + omp has something to do with it.


#3

There have been a few attempts. Currently it seems that you only need to wait for this to be merged: https://github.com/whitequark/ppx_deriving/pull/141


#4

I’d like to use ppx_deriving_yojson with jbuilder. I’ve tried pinning ppx_deriving to ppx_deriving#141 as suggested, but my project still fails to compile:

Error: Attribute `deriving' was not used

Has anybody successfully used ppx_deriving with jbuilder? Would greatly appreciate more details on how to get jbuilder working with ppx_deriving_yojson (or another ppx_deriving-plugin).


#5

I think ppx_derivign_yojson also needs to be ported to ocaml-migrate-parsetree (on the lines of https://github.com/whitequark/ppx_deriving_yojson/pull/49 ± adaptations), but I might be wrong.


#6

I’m running into something which I think is an instance of this issue, but I’m not sure. I’m using a jbuild file which has (preprocess (pps (ppx_jane ppx_deriving.std))), but when running jbuilder build @install I get errors such as the following for eq and enum:

         ppx lib/Frenetic_NetKAT.pp.ml (exit 1)
(cd _build/default && ./.ppx/ppx_jane+ppx_deriving.std/ppx.exe --dump-ast --cookie 'library-name="frenetic"' -o lib/Frenetic_NetKAT.pp.ml --impl lib/Frenetic_NetKAT.ml)
File "lib/Frenetic_NetKAT.ml", line 8, characters 55-72:
Error: ppx_type_conv: 'eq' is not a supported type type-conv generator

Is this the same issue as previously described in the thread?


#7

If you want to use ppx_deriving in the mean time, with pds, one can do deps = ["ppx_deriving.blah"] or deps = ["ppx_deriving_yojson"], although it applies to a whole project rather than just to specific source files.


#8

I wanted the same: ppx_deriving works with jbuilder now, but you’ll need ppx_deriving_yojson with this change (pin or wait for it to get merged/released) ppx_deriving_yojson#60. With that, it works now!