Source file rocqdep_main.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
(** The basic parts of coqdep are in [Common]. *)
let warn_home_dir =
let category = CWarnings.CoreCategories.filesystem in
CWarnings.create ~name:"cannot-locate-home-dir" ~category Pp.str
let coqdep args =
let open Common in
ignore (Feedback.(add_feeder (console_feedback_listener Format.err_formatter)));
if CList.is_empty args then Args.usage ();
let args = Args.parse (Args.make ()) args in
let v_files = args.Args.files in
let make_separator_hack = true in
let rocqenv, st = init ~make_separator_hack args in
let lst = Common.State.loadpath st in
let st = List.fold_left treat_file_command_line st v_files in
(try ignore (Loadpath.find_dir_logpath (Sys.getcwd()))
with Not_found -> Loadpath.add_norec_dir_import (Loadpath.add_known lst) "." []);
let () = match rocqenv with
| Boot -> ()
| Env env ->
let corelib = Boot.Env.(corelib env |> Path.to_string) in
let user_contrib = Boot.Env.(user_contrib env |> Path.to_string) in
Loadpath.add_rec_dir_import (Loadpath.add_coqlib_known lst) corelib ["Corelib"];
if Sys.file_exists user_contrib then
Loadpath.add_rec_dir_no_import (Loadpath.add_coqlib_known lst) user_contrib [];
let add_dir s = Loadpath.add_rec_dir_no_import (Loadpath.add_coqlib_known lst) s [] in
List.iter add_dir (Envars.xdg_dirs ~warn:warn_home_dir);
List.iter add_dir (Envars.coqpath())
in
if args.Args.sort then
sort st
else
let deps = compute_deps st in
let worker = Dep_info.Dep.Other (Loadpath.get_worker_path @@ Common.State.loadpath st) in
let add_worker ({Dep_info.deps; _} as dep_info) =
let deps = deps @ [worker] in
{dep_info with deps}
in
let deps = Seq.map add_worker deps in
deps |> Seq.iter (Makefile.print_dep Format.std_formatter)
let main args =
try
coqdep args
with exn ->
let exn = Exninfo.capture exn in
let loc = Loc.get_loc (snd exn) in
Feedback.msg_notice ?loc Pp.(str "Error: " ++ CErrors.iprint exn);
exit 1