Source file coqloadpath.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
open Util
open Pp
let build_corelib_vo_path ~unix_path ~rocq_path =
let open Loadpath in
{ unix_path; coq_path = rocq_path; implicit = true; recursive = true; installed = true }
let build_userlib_path ~unix_path =
let open Loadpath in
if Sys.file_exists unix_path then
let vo_path =
{ unix_path
; coq_path = Libnames.default_root_prefix
; implicit = false
; recursive = true
; installed = true
} in
[vo_path]
else []
let init_load_path ~coqenv =
let open Loadpath in
let user_contrib = Boot.Env.user_contrib coqenv |> Boot.Path.to_string in
let xdg_dirs = Envars.xdg_dirs ~warn:(fun x -> Feedback.msg_warning (str x)) in
let rocqpath = Envars.coqpath in
let rocq_path = Names.DirPath.make [Libnames.rocq_init_root] in
let core_dir = Boot.Env.runtimelib coqenv in
let meta_dir = if Boot.Env.Path.(exists (relative core_dir "META"))
then [Boot.Env.Path.(to_string (relative core_dir ".."))]
else []
in
let corelib = Boot.Env.corelib coqenv |> Boot.Path.to_string in
let contrib_vo = build_userlib_path ~unix_path:user_contrib in
let misc_vo =
List.map (fun s -> build_userlib_path ~unix_path:s) (xdg_dirs @ (rocqpath())) in
let ml_loadpath = meta_dir in
let vo_loadpath =
[ { unix_path = "."
; coq_path = Libnames.default_root_prefix
; implicit = false
; recursive = false
; installed = false
} ] @
[build_corelib_vo_path ~unix_path:corelib ~rocq_path] @
contrib_vo @
List.concat misc_vo
in
ml_loadpath, vo_loadpath