ppx_deriving
                                
                                
                                
                                    ppx_deriving copied to clipboard
                            
                            
                            
                        README example for running an individual deriver seems not to work in 4.2
I can't seem to run an individual deriver with -deriving-plugin as the README says I should be able to with version 4.2.  All output from ocamlfind seems correct and consistent, but I always get Failure("Ast_mapper: OCaml version mismatch or malformed input").
Please let me know what other diagnostic information would be helpful.
4.05.0🐫  user@mirageos:~$ cat test.ml
type foo = A of int | B of float
[@@deriving show]
4.05.0🐫  user@mirageos:~$ ocamlfind ppx_deriving/ppx_deriving     -deriving-plugin `ocamlfind query ppx_deriving`/ppx_deriving_show.cma     test.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
4.05.0🐫  user@mirageos:~$ ocamlfind ppx_deriving/ppx_deriving
Usage: /home/user/.opam/4.05.0/lib/ppx_deriving/ppx_deriving [extra_args] <infile> <outfile>
4.05.0🐫  user@mirageos:~$ ocamlfind query ppx_deriving
/home/user/.opam/4.05.0/lib/ppx_deriving
4.05.0🐫  user@mirageos:~$ 
                                    
                                    
                                    
                                
ppx_deriving is kind of broken right now, but I haven't had time to work properly on it due to FOSS overload. sorry.
Aw, I'm sorry to hear that. ppx_deriving looked like just the thing for a project I've just started on, and I was looking forward to working with it. Thanks for the quick reply, @whitequark , and I hope you have time and energy to work on the things you find rewarding :)
I hope we can find the manpower to complement @whitequark here, but I haven't been able to help much myself with the compiler distribution release work. (cc @let-def)
The command executed by ocamlfind ppx_deriving/ppx_deriving expects
the passed file to contain a marshalled AST, but test.ml is a plain source file.
Here is a temporary workaround:
ocamlfind ocamlopt -ppx '`ocamlfind query ppx_deriving`/ppx_deriving `ocamlfind query ppx_deriving`/ppx_deriving_show.cma' -dsource -c test.ml
                                    
                                    
                                    
                                
I pushed a tentative fix in a new branch, namely main-omp-driver.
The problem is that is ppx_deriving_main now uses the omp machinery
to register a driver. However, to make that happen and be able to set
command-line arguments for the driver, we need the registration in
ppx_deriving to be explicit (thus breaking other use cases).
My feeling is that moving to omp (and jbuilder for that matter) would make things easier, but I am not sure it can be done in a backward-compatible way.
@xclerc Can you explain why the registration has to be explicit? (I used to know a few months ago but I completely forgot, sorry)
I have quite possibly missed something, but by basing Ppx_deriving_main
on the omp registration mechanism I needed to register the driver from there
(not. to specify the command-line arguments to be processed).
Is there a way to replace an existing driver (in this case, previously registered
by the Ppx_deriving module) with a new one?