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

Use the generic ppx driver support of Dune #40

Merged
2 commits merged into from
Mar 15, 2018
Merged

Use the generic ppx driver support of Dune #40

2 commits merged into from
Mar 15, 2018

Conversation

ghost
Copy link

@ghost ghost commented Mar 13, 2018

This feature is part of a larger work to remove the hard-coded knowledge of various ppx projects in Dune: ocaml/dune#576

Dune can link custom ppx drivers on demand. Currently, it hard-codes the fact that ocaml-migrate-parsetree and ppx_driver provide entry points for such drivers. This is not very satisfactory and it forces changes to the system to be synchronized between the various projects, which is painful.

Starting from Jbuilder 1.0+beta20, individual libraries will be able to declare themselves as ppx drivers and Dune will use this information to decide what driver to use and how to use it, i.e. what flags to pass it. One can declare that a library is a ppx driver by adding a ppx.driver field to the library stanza:

(ppx.driver
 ((main       Migrate_parsetree.Driver.run_main)
  (flags      (--dump-ast))
  (lint_flags (--null))))

We are doing this change in two steps: in Jbuilder 1.0+beta19 which is being released, the ppx.driver field is accepted and ignored. In Jbuilder 1.0+beta20, it will be used and Jbuilder will now longer have hard-coded knowledge of ocaml-migrate-parsetree and ppx_driver.

This PR adds the ppx.driver field to src/jbuild and bumps the version constraint on Dune to Jbuilder 1.0+beta19.

Additionally, in the new system ppx_driver will automatically be selected as soon as one uses a ppx_driver based rewriter. As a result we need ppx_driver to accept all the command line flags accepted by the ocaml-migrate-parsetree driver. To do that, we need to retreive the command line arguments that where registered with the omp driver by individual rewriters. This PR adds functions to do that.

@ghost ghost requested a review from let-def March 13, 2018 13:34
@let-def
Copy link
Collaborator

let-def commented Mar 14, 2018

That patch looks good. I will wait for jbuilder19 to be available in opam to pass the CI test.

@ghost ghost force-pushed the generic-ppx-driver branch from 9dcc455 to fe706b8 Compare March 14, 2018 16:19
@ghost
Copy link
Author

ghost commented Mar 14, 2018

We just released beta18.1 which accepts and ignores the field as well, I changed the constraint

@ghost
Copy link
Author

ghost commented Mar 15, 2018

CI's passing. @let-def I'm merging this and preparing a release, so that we can move forward with the dune PR

@ghost ghost merged commit 6f15a2d into master Mar 15, 2018
This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants