aboutsummaryrefslogtreecommitdiff
path: root/stm/stm.ml
diff options
context:
space:
mode:
authorEnrico Tassi2021-01-05 11:34:35 +0100
committerEnrico Tassi2021-01-27 09:45:49 +0100
commit4264aec518d5407f345c58e18e014e15e9ae96af (patch)
tree03209892ae2549f171af39efa5d6925b745d54ec /stm/stm.ml
parent4390b6907b3d07793c2e8f9e7ad3cc38d9488711 (diff)
[sysinit] new component for system initialization
This component holds the code for initializing Coq: - parsing arguments not specific to the toplevel - initializing all components from vernac downwards (no stm) This commit moves stm specific arguments parsing to stm/stmargs.ml
Diffstat (limited to 'stm/stm.ml')
-rw-r--r--stm/stm.ml71
1 files changed, 11 insertions, 60 deletions
diff --git a/stm/stm.ml b/stm/stm.ml
index 27f2b6fc5c..f4e370e7bc 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -297,13 +297,11 @@ end (* }}} *)
(*************************** THE DOCUMENT *************************************)
(******************************************************************************)
-type interactive_top = TopLogical of DirPath.t | TopPhysical of string
-
(* The main document type associated to a VCS *)
type stm_doc_type =
| VoDoc of string
| VioDoc of string
- | Interactive of interactive_top
+ | Interactive of Coqargs.interactive_top
(* Dummy until we land the functional interp patch + fixed start_library *)
type doc = int
@@ -517,7 +515,7 @@ end = struct (* {{{ *)
type vcs = (branch_type, transaction, vcs state_info, box) t
let vcs : vcs ref = ref (empty Stateid.dummy)
- let doc_type = ref (Interactive (TopLogical (Names.DirPath.make [])))
+ let doc_type = ref (Interactive (Coqargs.TopLogical (Names.DirPath.make [])))
let ldir = ref Names.DirPath.empty
let init dt id ps =
@@ -2308,23 +2306,6 @@ end (* }}} *)
(** STM initialization options: *)
-type option_command =
- | OptionSet of string option
- | OptionAppend of string
- | OptionUnset
-
-type injection_command =
- | OptionInjection of (Goptions.option_name * option_command)
- (** Set flags or options before the initial state is ready. *)
- | RequireInjection of (string * string option * bool option)
- (** Require libraries before the initial state is
- ready. Parameters follow [Library], that is to say,
- [lib,prefix,import_export] means require library [lib] from
- optional [prefix] and [import_export] if [Some false/Some true]
- is used. *)
- (* -load-vernac-source interleaving is not supported yet *)
- (* | LoadInjection of (string * bool) *)
-
type stm_init_options =
{ doc_type : stm_doc_type
(** The STM does set some internal flags differently depending on
@@ -2338,7 +2319,7 @@ type stm_init_options =
(** [vo] load paths for the document. Usually extracted from -R
options / _CoqProject *)
- ; injections : injection_command list
+ ; injections : Coqargs.injection_command list
(** Injects Require and Set/Unset commands before the initial
state is ready *)
@@ -2355,6 +2336,10 @@ let doc_type_module_name (std : stm_doc_type) =
| Interactive mn -> Names.DirPath.to_string mn
*)
+let init_process stm_flags =
+ Spawned.init_channels ();
+ CoqworkmgrApi.(init stm_flags.AsyncOpts.async_proofs_worker_priority)
+
let init_core () =
if !cur_opt.async_proofs_mode = APon then Control.enable_thread_delay := true;
if !Flags.async_proofs_worker_id = "master" then Partac.enable_par ~nworkers:!cur_opt.async_proofs_n_tacworkers;
@@ -2379,44 +2364,10 @@ let new_doc { doc_type ; ml_load_path; vo_load_path; injections; stm_options } =
let mfrom = Option.map Libnames.qualid_of_string from in
Flags.silently (Vernacentries.vernac_require mfrom exp) [mp] in
- let interp_set_option opt v old =
- let open Goptions in
- let err expect =
- let opt = String.concat " " opt in
- let got = v in (* avoid colliding with Pp.v *)
- CErrors.user_err
- Pp.(str "-set: " ++ str opt ++
- str" expects " ++ str expect ++
- str" but got " ++ str got)
- in
- match old with
- | BoolValue _ ->
- let v = match String.trim v with
- | "true" -> true
- | "false" | "" -> false
- | _ -> err "a boolean"
- in
- BoolValue v
- | IntValue _ ->
- let v = String.trim v in
- let v = match int_of_string_opt v with
- | Some _ as v -> v
- | None -> if v = "" then None else err "an int"
- in
- IntValue v
- | StringValue _ -> StringValue v
- | StringOptValue _ -> StringOptValue (Some v) in
-
- let set_option = let open Goptions in function
- | opt, OptionUnset -> unset_option_value_gen ~locality:OptLocal opt
- | opt, OptionSet None -> set_bool_option_value_gen ~locality:OptLocal opt true
- | opt, OptionSet (Some v) -> set_option_value ~locality:OptLocal (interp_set_option opt) opt v
- | opt, OptionAppend v -> set_string_option_append_value_gen ~locality:OptLocal opt v in
-
let handle_injection = function
- | RequireInjection r -> require_file r
+ | Coqargs.RequireInjection r -> require_file r
(* | LoadInjection l -> *)
- | OptionInjection o -> set_option o in
+ | Coqargs.OptionInjection o -> Coqargs.set_option o in
(* Set the options from the new documents *)
AsyncOpts.cur_opt := stm_options;
@@ -2437,8 +2388,8 @@ let new_doc { doc_type ; ml_load_path; vo_load_path; injections; stm_options } =
begin match doc_type with
| Interactive ln ->
let dp = match ln with
- | TopLogical dp -> dp
- | TopPhysical f -> dirpath_of_file f
+ | Coqargs.TopLogical dp -> dp
+ | Coqargs.TopPhysical f -> dirpath_of_file f
in
Declaremods.start_library dp