From eb7b5e2be49306de1b329713f49106cc157da018 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Thu, 8 Jun 2017 11:33:59 +0100 Subject: [PATCH] Help users to not use non-future proof features in jbuild files --- doc/jbuild.rst | 2 ++ src/jbuild_load.ml | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/jbuild.rst b/doc/jbuild.rst index 183ed524..3837c629 100644 --- a/doc/jbuild.rst +++ b/doc/jbuild.rst @@ -1001,3 +1001,5 @@ syntax is not enough. It is not clear whether the OCaml syntax will be supported in the long term as it doesn't work well with incremental builds. It is possible that it will be replaced by just an ``include`` stanza where one can include a generated file. + +Consequently **you must not** build complex systems based on it. diff --git a/src/jbuild_load.ml b/src/jbuild_load.ml index c340fc41..f01866c4 100644 --- a/src/jbuild_load.ml +++ b/src/jbuild_load.ml @@ -55,7 +55,13 @@ module Jbuilds = struct let plugin_contents = Io.read_file plugin in Io.with_file_out (Path.to_string wrapper) ~f:(fun oc -> Printf.fprintf oc {| -let () = Hashtbl.add Toploop.directive_table "require" (Toploop.Directive_string ignore) +let () = + Hashtbl.add Toploop.directive_table "require" (Toploop.Directive_string ignore); + Hashtbl.add Toploop.directive_table "use" (Toploop.Directive_string (fun _ -> + failwith "#use is not allowed inside jbuild in OCaml syntax")); + Hashtbl.add Toploop.directive_table "use_mod" (Toploop.Directive_string (fun _ -> + failwith "#use is not allowed inside jbuild in OCaml syntax")) + module Jbuild_plugin = struct module V1 = struct let context = %S