(library
 (name ppxlib)
 (public_name ppxlib)
 (libraries
  ocaml-compiler-libs.common
  compiler-libs.common
  ocaml-compiler-libs.shadow
  ocaml-migrate-parsetree
  ppxlib_ast
  ppxlib_print_diff
  ppx_derivers
  ppxlib_traverse_builtins
  stdppx)
 (flags (:standard -open Ocaml_shadow -safe-string))
 (ppx.driver
  (main       Ppxlib.Driver.standalone)
  (replaces   ocaml-migrate-parsetree)
  (flags      (-corrected-suffix %{corrected-suffix} -diff-cmd - -dump-ast))
  (lint_flags (-corrected-suffix %{corrected-suffix} -diff-cmd - -null    ))))

(cinaps
 (files *.ml *.mli)
 (libraries ppxlib_cinaps_helpers))

(rule
 (targets ast_pattern_generated.ml)
 (deps    gen/gen_ast_pattern.exe)
 (action  (run ./gen/gen_ast_pattern.exe %{lib:ppxlib.ast:ast.ml})))

(rule
 (targets ast_builder_generated.ml)
 (deps gen/gen_ast_builder.exe)
 (action  (run ./gen/gen_ast_builder.exe %{lib:ppxlib.ast:ast.ml})))

;; This is to make the code compatible with different versions of
;; OCaml
(rule
 (targets compiler_specifics.ml)
 (deps    gen-compiler_specifics)
 (action  (run %{ocaml} %{deps} %{ocaml_version} %{targets})))
