make ppx_tools dependency optional

This commit is contained in:
Jeremie Dimino 2016-04-25 10:50:26 +01:00
parent 80f4b60058
commit 57f8ac4437
5 changed files with 24 additions and 2 deletions

4
_oasis
View File

@ -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:

2
_tags
View File

@ -1,6 +1,6 @@
# -*- conf -*-
<src/**/*.ml{,i}>: cppo_V_OCAML, package(compiler-libs)
<src/**/*.ml{,i}>: cppo_V_OCAML, cppo_interact, package(compiler-libs)
<src/camlp5/**/*.ml{,i}>: use_camlp5
<**/*.ml>: warn(-3-40)

View File

@ -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"

1
opam
View File

@ -30,5 +30,6 @@ depends: [
]
depopts: [
"camlp4"
"ppx_tools"
]
available: [ ocaml-version >= "4.01" ]

View File

@ -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