aboutsummaryrefslogtreecommitdiffhomepage
path: root/topbin
diff options
context:
space:
mode:
authorGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2018-03-07 01:33:17 +0100
committerGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2018-05-21 03:07:27 +0200
commit382ee49700c4b4ee78ba95b2e86866ebd3b35d74 (patch)
tree995cb88f7dfa62bb265e5cc2eb3adf4b18653ada /topbin
parent053812dc5f32635f177fafbf566936aa079bfeed (diff)
[stm] Make toplevels standalone executables.
We turn coqtop "plugins" into standalone executables, which will be installed in `COQBIN` and located using the standard `PATH` mechanism. Using dynamic linking for `coqtop` customization didn't make a lot of sense, given that only one of such "plugins" could be loaded at a time. This cleans up some code and solves two problems: - `coqtop` needing to locate plugins, - dependency issues as plugins in `stm` depended on files in `toplevel`. In order to implement this, we do some minor cleanup of the toplevel API, making it functional, and implement uniform build rules. In particular: - `stm` and `toplevel` have become library-only directories, - a new directory, `topbin`, contains the new executables, - 4 new binaries have been introduced, for coqide and the stm. - we provide a common and cleaned up way to locate toplevels.
Diffstat (limited to 'topbin')
-rw-r--r--topbin/coqproofworker_bin.ml14
-rw-r--r--topbin/coqqueryworker_bin.ml13
-rw-r--r--topbin/coqtacticworker_bin.ml13
-rw-r--r--topbin/coqtop_bin.ml16
-rw-r--r--topbin/coqtop_byte_bin.ml34
5 files changed, 90 insertions, 0 deletions
diff --git a/topbin/coqproofworker_bin.ml b/topbin/coqproofworker_bin.ml
new file mode 100644
index 000000000..7ae91cfbd
--- /dev/null
+++ b/topbin/coqproofworker_bin.ml
@@ -0,0 +1,14 @@
+(************************************************************************)
+(* * The Coq Proof Assistant / The Coq Development Team *)
+(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
+(* <O___,, * (see CREDITS file for the list of authors) *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(* * (see LICENSE file for the text of the license) *)
+(************************************************************************)
+
+module W = AsyncTaskQueue.MakeWorker(Stm.ProofTask) ()
+
+let () =
+ WorkerLoop.start ~init:W.init_stdout ~loop:W.main_loop
diff --git a/topbin/coqqueryworker_bin.ml b/topbin/coqqueryworker_bin.ml
new file mode 100644
index 000000000..98c858121
--- /dev/null
+++ b/topbin/coqqueryworker_bin.ml
@@ -0,0 +1,13 @@
+(************************************************************************)
+(* * The Coq Proof Assistant / The Coq Development Team *)
+(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
+(* <O___,, * (see CREDITS file for the list of authors) *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(* * (see LICENSE file for the text of the license) *)
+(************************************************************************)
+
+module W = AsyncTaskQueue.MakeWorker(Stm.QueryTask) ()
+
+let () = WorkerLoop.start ~init:W.init_stdout ~loop:W.main_loop
diff --git a/topbin/coqtacticworker_bin.ml b/topbin/coqtacticworker_bin.ml
new file mode 100644
index 000000000..2634baa83
--- /dev/null
+++ b/topbin/coqtacticworker_bin.ml
@@ -0,0 +1,13 @@
+(************************************************************************)
+(* * The Coq Proof Assistant / The Coq Development Team *)
+(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
+(* <O___,, * (see CREDITS file for the list of authors) *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(* * (see LICENSE file for the text of the license) *)
+(************************************************************************)
+
+module W = AsyncTaskQueue.MakeWorker(Stm.TacTask) ()
+
+let () = WorkerLoop.start ~init:W.init_stdout ~loop:W.main_loop
diff --git a/topbin/coqtop_bin.ml b/topbin/coqtop_bin.ml
new file mode 100644
index 000000000..4490db59e
--- /dev/null
+++ b/topbin/coqtop_bin.ml
@@ -0,0 +1,16 @@
+(************************************************************************)
+(* * The Coq Proof Assistant / The Coq Development Team *)
+(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
+(* <O___,, * (see CREDITS file for the list of authors) *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(* * (see LICENSE file for the text of the license) *)
+(************************************************************************)
+
+let drop_setup () = Mltop.remove ()
+
+(* Main coqtop initialization *)
+let _ =
+ drop_setup ();
+ Coqtop.(start_coq coqtop_toplevel)
diff --git a/topbin/coqtop_byte_bin.ml b/topbin/coqtop_byte_bin.ml
new file mode 100644
index 000000000..abe397830
--- /dev/null
+++ b/topbin/coqtop_byte_bin.ml
@@ -0,0 +1,34 @@
+(************************************************************************)
+(* * The Coq Proof Assistant / The Coq Development Team *)
+(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
+(* <O___,, * (see CREDITS file for the list of authors) *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(* * (see LICENSE file for the text of the license) *)
+(************************************************************************)
+
+let drop_setup () =
+ begin try
+ (* Enable rectypes in the toplevel if it has the directive #rectypes *)
+ begin match Hashtbl.find Toploop.directive_table "rectypes" with
+ | Toploop.Directive_none f -> f ()
+ | _ -> ()
+ end
+ with
+ | Not_found -> ()
+ end;
+ let ppf = Format.std_formatter in
+ Mltop.(set_top
+ { load_obj = (fun f -> if not (Topdirs.load_file ppf f)
+ then CErrors.user_err Pp.(str ("Could not load plugin "^f))
+ );
+ use_file = Topdirs.dir_use ppf;
+ add_dir = Topdirs.dir_directory;
+ ml_loop = (fun () -> Toploop.loop ppf);
+ })
+
+(* Main coqtop initialization *)
+let _ =
+ drop_setup ();
+ Coqtop.(start_coq coqtop_toplevel)