Debian Codegraph @

sysinit/coqloadpath.ml

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 open Util
12 open Pp
13
14 (* Recursively puts `.v` files in the LoadPath *)
15 let build_corelib_vo_path ~unix_path ~rocq_path =
16 let open Loadpath in
17 { unix_path; coq_path = rocq_path; implicit = true; recursive = true; installed = true }
18
19 let build_userlib_path ~unix_path =
20 let open Loadpath in
21 if Sys.file_exists unix_path then
22 let vo_path =
23 { unix_path
24 ; coq_path = Libnames.default_root_prefix
25 ; implicit = false
26 ; recursive = true
27 ; installed = true
28 } in
29 [vo_path]
30 else []
31
32 (* LoadPath for Rocq user libraries *)
33 let init_load_path ~coqenv =
34
35 let open Loadpath in
36 let user_contrib = Boot.Env.user_contrib coqenv |> Boot.Path.to_string in
37 let xdg_dirs = Envars.xdg_dirs ~warn:(fun x -> Feedback.msg_warning (str x)) in
38 let rocqpath = Envars.coqpath in
39 let rocq_path = Names.DirPath.make [Libnames.rocq_init_root] in
40 (* ML includes *)
41 let core_dir = Boot.Env.runtimelib coqenv in
42
43 (* EJGA: this needs clenaup, we must be deterministic *)
44 let meta_dir = if Boot.Env.Path.(exists (relative core_dir "META"))
45 then [Boot.Env.Path.(to_string (relative core_dir ".."))]
46 else []
47 in
48 let corelib = Boot.Env.corelib coqenv |> Boot.Path.to_string in
49 let contrib_vo = build_userlib_path ~unix_path:user_contrib in
50
51 let misc_vo =
52 List.map (fun s -> build_userlib_path ~unix_path:s) (xdg_dirs @ (rocqpath())) in
53
54 let ml_loadpath = meta_dir in
55 let vo_loadpath =
56 (* current directory (not recursively!) *)
57 [ { unix_path = "."
58 ; coq_path = Libnames.default_root_prefix
59 ; implicit = false
60 ; recursive = false
61 ; installed = false (* not considered "installed" *)
62 } ] @
63
64 (* then standard library *)
65 [build_corelib_vo_path ~unix_path:corelib ~rocq_path] @
66
67 (* then user-contrib *)
68 contrib_vo @
69
70 (* then directories in XDG_DATA_DIRS and XDG_DATA_HOME and ROCQPATH *)
71 List.concat misc_vo
72 in
73 ml_loadpath, vo_loadpath