(* -*- tuareg -*- *)

let preprocess =
  match Sys.getenv "BISECT_ENABLE" with
  | "yes" -> "(preprocess (pps bisect_ppx))"
  | _ -> ""
  | exception Not_found -> ""

let () =
  Jbuild_plugin.V1.send @@
    {|
(rule
 (targets ident_env.ml)
  (deps   (:x ident_env.cppo.ml))
  (action (chdir %{workspace_root} (run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(rule
 (targets ident_env.mli)
  (deps (:x ident_env.cppo.mli))
  (action (chdir %{workspace_root} (run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(rule
 (targets compat.ml)
  (deps   (:x compat.cppo.ml))
  (action (chdir %{workspace_root} (run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(library
 (name odoc_model)
 (public_name odoc.model)
    |} ^ preprocess ^ {|
 (libraries result compiler-libs.common))
    |}
