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

Get rid of the ocamlbuild plugin #63

Merged
1 commit merged into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ next
- Fix Windows compatibility by setting the output to binary mode when
writing a binary ast (#57, @bryphe)

- Get rid of the ocamlbuild plugin. Nobody is using it in opam and it
is more work to maintain

v1.1.0 2018-09-05 London
------------------------

Expand Down
76 changes: 0 additions & 76 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Date: March 9, 2017
- [New registration interface](#new-registration-interface)
- [A minimal driver](#a-minimal-driver)
- [Custom and standalone drivers](#custom-and-standalone-drivers)
- [Custom drivers with OCamlbuild](#custom-drivers-with-ocamlbuild)
- [ppx_tools_versioned](#ppx_tools_versioned)
- [ppx_metaquots](#ppx_metaquots)
- [Findlib specification](#findlib-specification)
Expand Down Expand Up @@ -180,81 +179,6 @@ ocamlfind ocamlopt -linkpkg -package rewriter1,rewriter2,... \
-package ocaml-migrate-parsetree.driver-main -o myrewriter
```

## Custom drivers with OCamlbuild

To build a custom driver using ocamlfind, simply link all the ppx
rewriter libraries together with the
`ocaml-migrate-parsetree.driver-main` package at the end:

ocamlfind ocamlopt -predicates ppx_driver -o ppx -linkpkg \
-package ppx_sexp_conv -package ppx_bin_prot \
-package ocaml-migrate-parsetree.driver-main

Normally, ocaml-migrate-parsetree based rewriters should be build with
the approriate `-linkall` option on individual libraries. If one is
missing this option, the rewriter might not get linked in. If this is
the case, a workaround is to pass `-linkall` when linking the custom
driver.

The resulting `ppx` program can be used as follow:

- `./ppx file.ml` to print the transformed code
- `ocamlc -pp './ppx --as-pp ...` to use it as a pre-processor
- `ocamlc -ppx './ppx --as-ppx' ...` to use it as a `-ppx` rewriter

### Using the ocaml-migrate-parsetree driver with ocamlbuild

The ocaml-migrate-parsetree-ocamlbuild package provides an ocamlbuild
plugin to help building and using custom drivers on demand.

#### Setup

To use it you need to first tell ocamlbuild to use the plugin in
`myocamlbuild.ml`. If you are using oasis, add this to your `_oasis`
file:

```
AlphaFeatures: ocamlbuild_more_args
XOCamlbuildPluginTags: package(ocaml-migrate-parsetree-ocamlbuild)
```

If you are calling ocamlbuild directly, you need to call it this way:

```
$ ocamlbuild -plugin-tag "package(ocaml-migrate-parsetree-ocamlbuild)" ...
```

Once you have done that, you need to enable it in your myocamlbuild.ml:

```ocaml
let () =
Ocamlbuild_plugin.dispatch (fun hook ->
Migrate_parsetree_ocamlbuild.dispatch hook;
<other dispatch functions>
)
```

#### Usage

The plugin provides a new parametric tag: `omp-driver`. The tag takes
as argument a `+` separated list of rewriters (as findlib package
names) followed by any command line arguments.

For instance to use `ppx_sexp_conv` and `ppx_bin_prot` put this in
your tags file:

```
<**/*>: predicate(custom_ppx)
<src/*.{ml,mli}>: omp-driver(ppx_sexp_conv+ppx_bin_prot)
```

The first line is to instruct ocamlfind not to automatically add
implicit `-ppx` argument. Without this, you might still get individual
`-ppx` for both `ppx_sexp_conv` and `ppx_bin_prot` in addition to the
main driver that already contains them both, meaning your code would
be transformed more than it should...


# ppx_tools_versioned

Some rewriters make use of the *ppx_tools* package that offers conveniences for manipulating parsetrees. As *ppx_tools* itself uses compiler-libs, using it directly defeats the purpose of *ocaml-migrate-parsetree*.
Expand Down
52 changes: 0 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,58 +108,6 @@ The resulting `ppx` program can be used as follow:
- `ocamlc -pp './ppx --as-pp' ...` to use it as a pre-processor
- `ocamlc -ppx './ppx --as-ppx' ...` to use it as a `-ppx` rewriter

### Using the ocaml-migrate-parsetree driver with ocamlbuild

The ocaml-migrate-parsetree-ocamlbuild package provides an ocamlbuild
plugin to help building and using custom drivers on demand.

#### Setup

To use it you need to first tell ocamlbuild to use the plugin in
`myocamlbuild.ml`. If you are using oasis, add this to your `_oasis`
file:

```
AlphaFeatures: ocamlbuild_more_args
XOCamlbuildPluginTags: package(ocaml-migrate-parsetree-ocamlbuild)
```

If you are calling ocamlbuild directly, you need to call it this way:

```
$ ocamlbuild -plugin-tag "package(ocaml-migrate-parsetree-ocamlbuild)" ...
```

Once you have done that, you need to enable it in your myocamlbuild.ml:

```ocaml
let () =
Ocamlbuild_plugin.dispatch (fun hook ->
Migrate_parsetree_ocamlbuild.dispatch hook;
<other dispatch functions>
)
```

#### Usage

The plugin provides a new parametric tag: `omp-driver`. The tag takes
as argument a `+` separated list of rewriters (as findlib package
names) followed by any command line arguments.

For instance to use `ppx_sexp_conv` and `ppx_bin_prot` put this in
your tags file:

```
<**/*>: predicate(custom_ppx)
<src/*.{ml,mli}>: omp-driver(ppx_sexp_conv+ppx_bin_prot)
```

The first line is to instruct ocamlfind not to automatically add
implicit `-ppx` argument. Without this, you might still get individual
`-ppx` for both `ppx_sexp_conv` and `ppx_bin_prot` in addition to the
main driver that already contains them both, meaning your code would
be transformed more than it should...

# Development

It started from the work of Alain Frisch in
Expand Down
25 changes: 0 additions & 25 deletions ocaml-migrate-parsetree-ocamlbuild.opam

This file was deleted.

5 changes: 0 additions & 5 deletions ocamlbuild_plugin/dune

This file was deleted.

60 changes: 0 additions & 60 deletions ocamlbuild_plugin/migrate_parsetree_ocamlbuild.ml

This file was deleted.

1 change: 0 additions & 1 deletion ocamlbuild_plugin/migrate_parsetree_ocamlbuild.mli

This file was deleted.