Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README example for running an individual deriver seems not to work in 4.2 #150

Open
yomimono opened this issue Sep 25, 2017 · 7 comments
Open

Comments

@yomimono
Copy link

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:~$ 
@whitequark
Copy link
Collaborator

ppx_deriving is kind of broken right now, but I haven't had time to work properly on it due to FOSS overload. sorry.

@yomimono
Copy link
Author

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 :)

@gasche
Copy link
Contributor

gasche commented Sep 26, 2017

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)

@xclerc
Copy link

xclerc commented Sep 26, 2017

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

@xclerc
Copy link

xclerc commented Sep 27, 2017

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.

@let-def
Copy link
Contributor

let-def commented Oct 2, 2017

@xclerc Can you explain why the registration has to be explicit? (I used to know a few months ago but I completely forgot, sorry)

@xclerc
Copy link

xclerc commented Oct 3, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants