Skip to content
Commits on Source (7)
disable
\ No newline at end of file
v1.4.0 2019-07-04 London
------------------------
- Initial support for 4.09, tested with 4.09+beta1 (#76, @hhugo)
- When encoding errors into the AST, duplicate the error message for
"ocaml.error" nodes for OCaml versions < 4.08 (#75, @xclerc)
v1.3.1 2019-05-20 London
------------------------
- Make sure opening `Ast_408` doesn't shadow `Int` or `Misc` (#71,
@hhugo)
- Fix a couple of issues related to upgrading the AST from 4.07 to
4.08 (#71, @hhugo)
v1.3.0 2019-05-08 London
------------------------
- Get rid of the ocamlbuild plugin. Nobody is using it in opam and it
is more work to maintain (#63, @diml)
- Set `Location.input_name` to the original filename when reading a
binary AST (#66, @diml)
- Add support 4.08 (#70, @xclerc)
v1.2.0 2018-12-19 London
------------------------
......
......@@ -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)
......@@ -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*.
......
......@@ -28,7 +28,7 @@ test:
.PHONY: all-supported-ocaml-versions
all-supported-ocaml-versions:
dune runtest --workspace jbuild-workspace.dev
dune runtest --workspace dune-workspace.dev
.PHONY: cinaps
cinaps:
......
......@@ -3,14 +3,14 @@ Convert OCaml parsetrees between different major versions
This library converts between parsetrees of different OCaml versions.
Supported versions are 4.02, 4.03, 4.04, 4.05 and 4.06.
Supported versions are 4.02, 4.03, 4.04, 4.05, 4.06, 4.07, 4.08 and 4.09.
For each version, there is a snapshot of the parsetree and conversion functions
to the next and/or previous version.
## Asts
```ocaml
module Ast_402, Ast_403, Ast_404, Ast_405, Ast_406, Ast_407 : sig
module Ast_402, Ast_403, Ast_404, Ast_405, Ast_406, Ast_407, Ast_408, Ast_409 : sig
(* These two modules didn't change between compiler versions.
Just share the ones from compiler-libs. *)
......@@ -78,9 +78,9 @@ Using a single driver for several rewritings has the advantage that it
is faster. Especially when using many ppx rewriters, it can speed up
compilation a lot.
If using [Jbuilder](https://github.com/janestreet/jbuilder), you can
consult the Jbuilder manual to see how to define and use ppx
rewriters. Jbuilder automatically creates drivers based on
If using [Dune](https://github.com/ocaml/dune), you can
consult the dune manual to see how to define and use ppx
rewriters. Dune automatically creates drivers based on
ocaml-migrate-parsetree on demand.
The rest of this section describes how to do things manually or with
......@@ -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
......@@ -170,13 +118,10 @@ The library is distributed under LGPL 2.1 and is copyright INRIA.
## Adding a new OCaml version
We use [Cinaps](https://github.com/janestreet/cinaps) to generate boilerplate.
Try `opam install cinaps`. If it is not available, you might need to pin the
package:
`opam pin add jbuilder --dev-repo`
`opam pin add cinaps https://github.com/janestreet/cinaps.git`
You can install it via opam: `opam install cinaps`.
Add the new version in
[src/cinaps.ml](https://github.com/let-def/ocaml-migrate-parsetree/blob/master/src/cinaps.ml)
[src/cinaps_helpers](https://github.com/ocaml-ppx/ocaml-migrate-parsetree/blob/master/src/cinaps_helpers)
`supported_versions`.
Snapshot the ast in file "asts/ast\_NEW.ml".
......@@ -191,19 +136,19 @@ Snapshot the ast in file "asts/ast\_NEW.ml".
* Call `tools/add_special_comments.native` on the file
Add migration functions:
- Manually compile the ast (`ocamlc -c ast_NEW.ml`)
- Using `gencopy` from [ppx\_tools](https://github.com/alainfrisch/ppx_tools), generate copy code to and from previous version (assuming it is 404):
- Manually compile the asts (`ocamlc -c src/ast_{NEW,OLD}.ml -I +compiler-libs -I _build/default/src/.migrate_parsetree.objs/byte/ -open Migrate_parsetree__`)
- Using `tools/gencopy.exe` (`dune build tools/gencopy.exe`), generate copy code to and from previous version (assuming it is 408):
```
gencopy -I . -map Ast_404:Ast_NEW Ast_404.Parsetree.expression Ast_404.Parsetree.toplevel_phrase Ast_404.Outcometree.out_phrase > migrate_parsetree_404_NEW_migrate.ml
gencopy -I . -map Ast_NEW:Ast_404 Ast_NEW.Parsetree.expression Ast_NEW.Parsetree.toplevel_phrase Ast_NEW.Outcometree.out_phrase > migrate_parsetree_NEW_404_migrate.ml
_build/default/tools/gencopy.exe -I . -I src/ -I +compiler-libs -map Ast_409:Ast_408 Ast_409.Parsetree.{expression,expr,pattern,pat,core_type,typ,toplevel_phrase} Ast_409.Outcometree.{out_phrase,out_type_extension} > src/migrate_parsetree_409_408_migrate.ml
_build/default/tools/gencopy.exe -I . -I src/ -I +compiler-libs -map Ast_408:Ast_409 Ast_408.Parsetree.{expression,expr,pattern,pat,core_type,typ,toplevel_phrase} Ast_408.Outcometree.{out_phrase,out_type_extension} > src/migrate_parsetree_408_409_migrate.ml
```
- Fix the generated code by implementing new cases
- By default generated code use very long identifiers, simplify unambiguous ones (e.g. `copy_Ast_NEW_Parsetree_structure` -> `copy_structure`). The migration functor expects specific names, look at `Migrate_parsetree_versions` interface.
- The migration functor expects specific names, look at `Migrate_parsetree_versions` interface.
*TODO*: specialize and improve gencopy for these cases
Add mapper lifting functions in the files `migrate_parsetree_NEW_404.ml` and
`migrate_parsetree_404_NEW.ml`:
Add mapper lifting functions in the files `migrate_parsetree_NEW_408.ml` and
`migrate_parsetree_408_NEW.ml`:
- include the corresponding `Migrate_parsetree_40x_40y_migrate` module
- define `copy_mapper` function, look at existing `Migrate_parsetree_40x_40y`
for guidance.
......@@ -211,6 +156,5 @@ Add mapper lifting functions in the files `migrate_parsetree_NEW_404.ml` and
At any time, you can expand boilerplate code by running `make cinaps`.
Update build system:
- in [Makefile](Makefile), add "src/ast\_NEW.ml" to `OCAML_ASTS` and migration modules to `OBJECTS`
- make sure `make cinaps` reaches a fixed point :)
- `make` should succeed
(executables
(names ocaml_migrate_parsetree)
(libraries migrate_parsetree))
(*$ #use "src/cinaps_helpers" $*)
let usage_msg =
Printf.sprintf "Usage: %s <input-ast> [-to-ocaml40x <output-ast>]"
Sys.argv.(0)
let conversions = ref []
let input = ref ""
let () =
let add v name = conversions := (v, name) :: !conversions in
let set_input name =
if !input = "" then input := name
else
raise (Arg.Bad (Printf.sprintf
"You can pass only one input filename (got %S and %S)"
!input name))
in
let arg_spec = [
(*$ foreach_version (fun suffix version ->
printf "(\"-to-ocaml%s\", Arg.String (add Migrate_parsetree.OCaml_%s),\n" suffix suffix;
printf "\"<filename> Produce an ast valid for OCaml %s in <filename>\");\n" version;
)
*)
("-to-ocaml402", Arg.String (add Migrate_parsetree.OCaml_402),
"<filename> Produce an ast valid for OCaml 4.02 in <filename>");
("-to-ocaml403", Arg.String (add Migrate_parsetree.OCaml_403),
"<filename> Produce an ast valid for OCaml 4.03 in <filename>");
("-to-ocaml404", Arg.String (add Migrate_parsetree.OCaml_404),
"<filename> Produce an ast valid for OCaml 4.04 in <filename>");
("-to-ocaml405", Arg.String (add Migrate_parsetree.OCaml_405),
"<filename> Produce an ast valid for OCaml 4.05 in <filename>");
("-to-ocaml406", Arg.String (add Migrate_parsetree.OCaml_406),
"<filename> Produce an ast valid for OCaml 4.06 in <filename>");
("-to-ocaml407", Arg.String (add Migrate_parsetree.OCaml_407),
"<filename> Produce an ast valid for OCaml 4.07 in <filename>");
(*$*)
] in
Arg.parse arg_spec set_input usage_msg;
if !input = "" then (
Arg.usage arg_spec usage_msg;
exit 1
);
let (src_filename, ast) =
let ic = open_in_bin !input in
match Migrate_parsetree.from_channel ic with
| exception (Migrate_parsetree.Unknown_magic_number number) ->
Printf.eprintf "Input file has unknown magic number: %s\n" number;
close_in ic;
exit 1
| exception exn -> close_in ic; raise exn
| ast -> close_in ic; ast
in
Printf.printf "Ast of %S for OCaml %s\n"
src_filename (Migrate_parsetree.string_of_ocaml_version
(Migrate_parsetree.ast_version ast));
List.iter (fun (version, dst_filename) ->
match
let ast' = Migrate_parsetree.migrate_to_version ast version in
let oc = open_out_bin dst_filename in
Migrate_parsetree.to_channel oc src_filename ast';
close_out_noerr oc
with
| () ->
Printf.printf "Successfully converted %S to OCaml %s in %S\n"
!input (Migrate_parsetree.string_of_ocaml_version version) dst_filename
| exception exn ->
Printf.eprintf "Failed to convert %S to OCaml %s in %S:\n%s%!\n"
!input (Migrate_parsetree.string_of_ocaml_version version) dst_filename
(Printexc.to_string exn)
) (List.rev !conversions)
ocaml-migrate-parsetree (1.4.0-1) UNRELEASED; urgency=medium
* New upstream release
- remove binary packages libmigrate-parsetree-ocamlbuild-ocaml{,-dev}
- do no longer provide automatic doc with dh_ocamldoc
-- Stéphane Glondu <glondu@debian.org> Tue, 13 Aug 2019 09:06:32 +0200
ocaml-migrate-parsetree (1.2.0-3) unstable; urgency=high
* Team upload
......
......@@ -7,13 +7,11 @@ Standards-Version: 4.3.0
Build-Depends:
debhelper (>= 10.3),
ocaml-nox (>= 4.02.0),
ocamlbuild,
dune (>= 1.6.0),
ocaml-dune (>= 1.6.0),
libppx-derivers-ocaml-dev,
libresult-ocaml-dev,
ocaml-compiler-libs,
ocaml-findlib,
opam-installer,
dh-ocaml
Homepage: https://github.com/ocaml-ppx/ocaml-migrate-parsetree
Vcs-Browser: https://salsa.debian.org/ocaml-team/ocaml-migrate-parsetree
......@@ -47,39 +45,6 @@ Description: Convert OCaml parsetrees between different major versions (Developm
For each version, there is a snapshot of the parsetree and conversion
functions to the next and/or previous version.
Package: libmigrate-parsetree-ocamlbuild-ocaml
Architecture: any
Depends:
${shlibs:Depends},
${misc:Depends},
${ocaml:Depends}
Provides:
${ocaml:Provides}
Recommends:
ocaml-findlib,
libmigrate-parsetree-ocaml
Enhances: ocamlbuild
Description: Provide an ocaml-migrate-parsetree plugin for ocamlbuild (Runtime library)
The package libmigrate-parsetree-ocamlbuild-ocaml provides an
ocaml-migrate-parsetree plugin for ocamlbuild, to help building and using
custom drivers on demand.
Package: libmigrate-parsetree-ocamlbuild-ocaml-dev
Architecture: any
Depends:
${shlibs:Depends},
${misc:Depends},
${ocaml:Depends}
Provides:
${ocaml:Provides}
Recommends:
ocaml-findlib,
libmigrate-parsetree-ocaml-dev
Description: Provide an ocaml-migrate-parsetree plugin for ocamlbuild (Development package)
The package libmigrate-parsetree-ocamlbuild-ocaml provides an
ocaml-migrate-parsetree plugin for ocamlbuild, to help building and using
custom drivers on demand.
Package: libmigrate-parsetree-ocaml-doc
Section: doc
Architecture: all
......
@OCamlStdlibDir@/ocaml-migrate-parsetree/{,**/}*.dune
@OCamlStdlibDir@/ocaml-migrate-parsetree/{,**/}*dune*
@OCamlStdlibDir@/ocaml-migrate-parsetree/{,**/}*.cmi
@OCamlStdlibDir@/ocaml-migrate-parsetree/{,**/}*.cmt
@OCamlStdlibDir@/ocaml-migrate-parsetree/{,**/}*.cmti
......
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.dune
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cmi
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cmt
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cmti
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.ml
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.mli
OPT: @OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.a
OPT: @OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cmxa
OPT: @OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cmx
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/META
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/opam
@OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cma
DYN: @OCamlStdlibDir@/ocaml-migrate-parsetree-ocamlbuild/{,**/}*.cmxs
usr/doc/ocaml-migrate-parsetree-ocamlbuild/{CHANGES.md,README.md,LICENSE.md} /usr/share/doc/ocaml-migrate-parsetree-ocamlbuild/
\ No newline at end of file
......@@ -2,7 +2,6 @@
DESTDIR=$(CURDIR)/debian/tmp
include /usr/share/ocaml/ocamlvars.mk
export OCAMLFIND_DESTDIR=$(DESTDIR)$(OCAML_STDLIB_DIR)
%:
dh $@ --with ocaml
......@@ -10,8 +9,7 @@ export OCAMLFIND_DESTDIR=$(DESTDIR)$(OCAML_STDLIB_DIR)
override_dh_auto_configure:
override_dh_auto_install:
mkdir -p '$(OCAMLFIND_DESTDIR)'
dh_auto_install -- INSTALL_ARGS='--destdir=$(DESTDIR) --verbose'
dune install --destdir=$(DESTDIR) --prefix=/usr --libdir=..$(OCAML_STDLIB_DIR)
override_dh_missing:
dh_missing --fail-missing
......@@ -23,4 +21,5 @@ debian/preprocess-ocamldoc.sh:
chmod +x "$@"
override_dh_ocamldoc: debian/preprocess-ocamldoc.sh
dh_ocamldoc -u "-pp $<"
# Broken as of 1.4.0-1
# dh_ocamldoc -u "-pp $<"
(lang dune 1.6)
(lang dune 1.9)
(name ocaml-migrate-parsetree)
(allow_approximate_merlin)
(lang dune 1.0)
;; This file is used by `make all-supported-ocaml-versions`
(context (opam (switch 4.02.3)))
(context (opam (switch 4.03.0)))
(context (opam (switch 4.04.2)))
(context (opam (switch 4.05.0)))
(context (opam (switch 4.06.1)))
(context (opam (switch 4.07.1)))
(context (opam (switch 4.08.0)))
;; (context (opam (switch ocaml-variants.4.09.0+beta1)))
;; Install the following opam switches, copy this file as
;; jbuild-workspace and run:
;;
;; $ jbuilder build @install
;;
;; This will build ocmal-migrate-parsee against all these version of OCaml
(context ((switch 4.02.3)))
(context ((switch 4.03.0)))
(context ((switch 4.04.0)))
(context ((switch 4.05.0+trunk)))
(context ((switch 4.06.0+trunk)))
opam-version: "2.0"
maintainer: "frederic.bour@lakaban.net"
authors: [
"Jérémie Dimino <jeremie@dimino.org>"
]
license: "LGPL-2.1"
homepage: "https://github.com/let-def/ocaml-migrate-parsetree"
bug-reports: "https://github.com/let-def/ocaml-migrate-parsetree/issues"
dev-repo: "git+https://github.com/let-def/ocaml-migrate-parsetree.git"
tags: [ "syntax" "org:ocamllabs" ]
build: [
["jbuilder" "build" "-p" name "-j" jobs]
]
depends: [
"jbuilder" {build & >= "1.0+beta7"}
"ocaml-migrate-parsetree"
"ocamlbuild"
"ocaml" {>= "4.02.0"}
]
synopsis: "Ocamlbuild plugin for ocaml-migrate-parsetree"
description: """
This package provides an ocamlbuild plugin that can be used to produce
optimized on-demand statically linked ppx drivers, as Dune does
by default.
"""
......@@ -4,20 +4,20 @@ authors: [
"Frédéric Bour <frederic.bour@lakaban.net>"
"Jérémie Dimino <jeremie@dimino.org>"
]
license: "LGPL-2.1"
license: "LGPL-2.1 with OCaml linking exception"
homepage: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree"
bug-reports: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/issues"
dev-repo: "git+https://github.com/ocaml-ppx/ocaml-migrate-parsetree.git"
doc: "https://ocaml-ppx.github.io/ocaml-migrate-parsetree/"
tags: [ "syntax" "org:ocamllabs" ]
build: [
["jbuilder" "build" "-p" name "-j" jobs]
["dune" "build" "-p" name "-j" jobs]
]
depends: [
"result"
"ppx_derivers"
"dune" {build}
"ocaml" {>= "4.02.0"}
"dune" {build & >= "1.9.0"}
"ocaml" {>= "4.02.3"}
]
synopsis: "Convert OCaml parsetrees between different versions"
description: """
......
(library
(name migrate_parsetree_ocamlbuild)
(public_name ocaml-migrate-parsetree-ocamlbuild)
(synopsis "ocamlbuild plugin for automatically generating ppx dirvers")
(libraries ocamlbuild))
open Ocamlbuild_plugin
let split s ~on =
let rec loop i =
match String.index_from s i on with
| exception Not_found -> [String.sub s i (String.length s - i)]
| j -> String.sub s i (j - i) :: loop (j + 1)
in
loop 0
let exe_ext ~native = if native then "native" else "byte"
let parse_tag_arg s =
let set, args =
match String.index s ' ' with
| exception Not_found -> (s, "")
| i -> (String.before s i, String.after s i)
in
let libs = split set ~on:'+' in
(List.sort String.compare libs, args)
let prog_of_libs ~native libs =
"omp-driver-" ^ String.concat "+" libs -.- exe_ext ~native
let pp_command_of_string ~native s =
let libs, args = parse_tag_arg s in
S [ A "-pp"
; A (Printf.sprintf "./%s --dump-ast%s" (prog_of_libs ~native libs) args)
]
let deps_of_string ~native s =
let libs, _ = parse_tag_arg s in
[ prog_of_libs ~native libs ]
let dispatch = function
| After_rules -> begin
(* If we are using a native plugin, we might as well use a native preprocessor. *)
let native = !Options.native_plugin in
pflag [ "ocaml"; "compile" ] "omp-driver" (pp_command_of_string ~native);
pflag [ "ocaml"; "ocamldep" ] "omp-driver" (pp_command_of_string ~native);
pflag [ "ocaml"; "doc" ] "omp-driver" (pp_command_of_string ~native);
pdep [ "ocaml"; "compile" ] "omp-driver" (deps_of_string ~native);
pdep [ "ocaml"; "ocamldep" ] "omp-driver" (deps_of_string ~native);
pdep [ "ocaml"; "doc" ] "omp-driver" (deps_of_string ~native);
let target = "omp-driver-%" -.- exe_ext ~native in
rule "autogenerated ocaml-migrate-parsetree driver"
~prod:target
(fun env _ ->
let pkgs = split (env "%") ~on:'+' @ ["ocaml-migrate-parsetree.driver-main"] in
Cmd (S [ if native then !Options.ocamlopt else !Options.ocamlc
; A "-predicates"; A "ppx_driver"
; A "-linkpkg"
; A "-o"; A (env target)
; A "-package"; A (String.concat "," pkgs)
]))
end
| _ -> ()