From 57f8ac4437ba275b9e0da129c287881793752231 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Mon, 25 Apr 2016 10:50:26 +0100 Subject: [PATCH] make ppx_tools dependency optional --- _oasis | 4 ++++ _tags | 2 +- myocamlbuild.ml | 10 +++++++++- opam | 1 + src/lib/uTop_main.cppo.ml | 9 +++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/_oasis b/_oasis index 17efb91..aa12795 100644 --- a/_oasis +++ b/_oasis @@ -33,6 +33,10 @@ Flag camlp4 Description: camlp4 support Default: false +Flag interact + Description: enable UTop_main.interact (requires ppx_tools) + Default: false + Library utop Path: src/lib Modules: diff --git a/_tags b/_tags index f9c97b0..69721d0 100644 --- a/_tags +++ b/_tags @@ -1,6 +1,6 @@ # -*- conf -*- -: cppo_V_OCAML, package(compiler-libs) +: cppo_V_OCAML, cppo_interact, package(compiler-libs) : use_camlp5 <**/*.ml>: warn(-3-40) diff --git a/myocamlbuild.ml b/myocamlbuild.ml index b07b545..48063c5 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -89,6 +89,14 @@ let () = ~prod:"src/top/uTop_top_full.byte" (fun _ _ -> cp "src/top/uTop_top.top" "src/top/uTop_top_full.byte"); + + let interact_enabled = BaseEnvLight.var_get "interact" env = "true" in + flag ["cppo"; "cppo_interact"] ( + if interact_enabled then + S [A "-D"; A "ENABLE_INTERACT"] + else + N); + rule "format lifter" ~prod:"src/lib/uTop_cmt_lifter.ml" (fun _ _ -> @@ -96,7 +104,7 @@ let () = Scanf.sscanf (BaseEnvLight.var_get "ocaml_version" env) "%u.%u" (fun a b -> (a, b)) in - if ocaml_version < (4, 02) then + if ocaml_version < (4, 02) || not interact_enabled then Echo ([], "src/lib/uTop_cmt_lifter.ml") else Cmd (S [ P "ocamlfind" diff --git a/opam b/opam index d57f4f4..c4e8423 100644 --- a/opam +++ b/opam @@ -30,5 +30,6 @@ depends: [ ] depopts: [ "camlp4" + "ppx_tools" ] available: [ ocaml-version >= "4.01" ] diff --git a/src/lib/uTop_main.cppo.ml b/src/lib/uTop_main.cppo.ml index 3ea3070..bf134e4 100644 --- a/src/lib/uTop_main.cppo.ml +++ b/src/lib/uTop_main.cppo.ml @@ -1373,6 +1373,15 @@ type value = V : string * _ -> value let interact ~search_path ~unit ~loc:(fname, lnum, cnum, _) ~values = failwith "UTop_main.interact is not supported on OCaml 4.01" +#elif not defined ENABLE_INTERACT + +let interact ~search_path ~unit ~loc:(fname, lnum, cnum, _) ~values = + failwith "\ +UTop_main.interact wasn't enabled at compile time. +If you installed utop through opam, just do this to enable this feature: + + $ opam install ppx_tools" + #else exception Found of Env.t