Debian Codegraph @

boot/env.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** Rocq runtime enviroment API.
12
13 This module provides functions for manipulation of Rocq's runtime
14 enviroment, including the standard directories and support files.
15
16 This API is similar in spirit to findlib's or dune-sites API,
17 see their documentation for more information:
18
19 - http://projects.camlcity.org/projects/dl/findlib-1.9.1/doc/ref-html/lib/index.html
20 - https://dune.readthedocs.io/en/stable/sites.html#sites
21
22 It is important that this library has a minimal dependency set.
23
24 The Rocq runtime enviroment needs to be properly initialized before use;
25 we detail the rules below. It is recommended that applications requiring
26 multiple accesses to the environment, do initialize it once and keep a ref
27 to it. We don't forbid yet double initialization, (second time is a noop)
28 but we may do so in the future. Rules for "coqlib" are:
29
30 - the [ROCQLIB] env variable will be used if set
31 - if not, the existence of [theories/Init/Prelude.vo] will be checked,
32 in the following order:
33 + [coqlibsuffix] given in configure
34 + [coqlib] given in configure
35 - if none of the above succeeds, the initialization will fail
36
37 - The [ROCQRUNTIMELIB] env variable is also used if set, if not, the location
38 of the rocq-runtime files will be assumed to be [ROCQLIB/../rocq-runtime], except
39 if [ROCQLIB/plugins] exists [as in some developers layouts], in which case
40 we will set [ROCQRUNTIMELIB:=ROCQLIB].
41
42 Note that [set_coqlib] is used by some commands to process the [-coqlib] option,
43 as of now this sets both [coqlib] and [coqcorelib]; this part of the initialization
44 will be eventually moved here.
45
46 The error handling policy of this module is simple for now: failing to
47 initialize Rocq's env will produce a fatal error, and the application will exit with
48 code 1. No error handling is thus required on the client yet.
49
50 *)
51
52 module Path : sig
53
54 (** This API is loosely inspired by [Stdune.Path], for now we keep
55 it minimal, but at some point we may extend it. *)
56
57 (** Paths are private, and owned by the functions below *)
58 type t
59
60 (** [relative path string] build a path relative to an existing one *)
61 val relative : t -> string -> t
62
63 (** We should gradually add some more functions to handle common dirs
64 here such the theories directories or share files. Abstracting it
65 hereere does allow to use system-specific functionalities *)
66
67 (** [exists file] checks if [file] exists *)
68 val exists : t -> bool
69
70 (** String representation *)
71 val to_string : t -> string
72
73 end
74
75 (** Rocq runtime enviroment, including location of Rocq's Corelib *)
76 type t
77
78 type maybe_env =
79 | Env of t
80 | Boot
81
82 (** Returns [None] if the environment has not been initialized. *)
83 val initialized : unit -> maybe_env option
84
85 (** Init, possibly with a user provided coqlib *)
86 val init_with : coqlib:string option -> t
87
88 (** Init if boot:false, possibly with a user provided coqlib.
89 Incompatible arguments run [warn_ignored_coqlib] (ie with boot:true and coqlib:Some) *)
90 val maybe_init : warn_ignored_coqlib:(unit -> unit) ->
91 boot:bool -> coqlib:string option -> maybe_env
92
93 (** Usual messsage used for warn_ignored_coqlib *)
94 val ignored_coqlib_msg : string
95
96 (** If the query list is empty, behave as [maybe_init].
97 Otherwise, print the queries.
98
99 If the [usage] argument is [None], the queries must not be PrintHelp.
100
101 If a query needs an environment, [boot] must not be [true].
102 If there are queries and none need an environment,
103 returns [Ok Boot] even if [boot] was [false].
104 *)
105 val print_queries_maybe_init : warn_ignored_coqlib:(unit -> unit) ->
106 boot:bool -> coqlib:string option ->
107 Usage.specific_usage option -> Usage.query list -> (maybe_env, string) result
108
109 (** [Corelib directory] *)
110 val corelib : t -> Path.t
111
112 (** [plugins directory] *)
113 val plugins : t -> Path.t
114
115 (** [user contrib directory] *)
116 val user_contrib : t -> Path.t
117
118 (** [tool-specific directory] *)
119 val tool : t -> string -> Path.t
120
121 (** .cmi files needed for native compilation *)
122 val native_cmi : t -> string -> Path.t
123
124 (** The location of the revision file *)
125 val revision : t -> Path.t
126
127 (** rocq-runtime/lib directory, not sure if to keep this *)
128 val runtimelib : t -> Path.t
129
130 (** coq/lib directory, not sure if to keep this *)
131 val coqlib : t -> Path.t
132
133 (** [camlfind ()] is the path to the ocamlfind binary. *)
134 val ocamlfind : unit -> string
135
136 val print_config : ?prefix_var_name:string -> t -> out_channel -> unit
137
138 val relocate : Coq_config.relocatable_path -> string
139
140 val rocqbin : string