Debian Codegraph @

tools/coqdep/lib/rocqdep_main.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 (** The basic parts of coqdep are in [Common]. *)
12
13 let warn_home_dir =
14 let category = CWarnings.CoreCategories.filesystem in
15 CWarnings.create ~name:"cannot-locate-home-dir" ~category Pp.str
16
17 let coqdep args =
18 let open Common in
19
20 ignore (Feedback.(add_feeder (console_feedback_listener Format.err_formatter)));
21
22 (* Initialize coqdep, add files to dependency computation *)
23 if CList.is_empty args then Args.usage ();
24 let args = Args.parse (Args.make ()) args in
25 let v_files = args.Args.files in
26 (* We are in makefile hack mode *)
27 let make_separator_hack = true in
28 let rocqenv, st = init ~make_separator_hack args in
29 let lst = Common.State.loadpath st in
30 let st = List.fold_left treat_file_command_line st v_files in
31
32 (* XXX: All the code below is just setting loadpaths, refactor to
33 Common coq.boot library *)
34 (* Add current dir with empty logical path if not set by options above. *)
35 (try ignore (Loadpath.find_dir_logpath (Sys.getcwd()))
36 with Not_found -> Loadpath.add_norec_dir_import (Loadpath.add_known lst) "." []);
37 (* We don't setup any loadpath if the -boot is passed *)
38 let () = match rocqenv with
39 | Boot -> ()
40 | Env env ->
41 let corelib = Boot.Env.(corelib env |> Path.to_string) in
42 let user_contrib = Boot.Env.(user_contrib env |> Path.to_string) in
43 Loadpath.add_rec_dir_import (Loadpath.add_coqlib_known lst) corelib ["Corelib"];
44 if Sys.file_exists user_contrib then
45 Loadpath.add_rec_dir_no_import (Loadpath.add_coqlib_known lst) user_contrib [];
46 let add_dir s = Loadpath.add_rec_dir_no_import (Loadpath.add_coqlib_known lst) s [] in
47 List.iter add_dir (Envars.xdg_dirs ~warn:warn_home_dir);
48 List.iter add_dir (Envars.coqpath())
49 in
50 if args.Args.sort then
51 sort st
52 else
53 compute_deps st |> List.iter (Makefile.print_dep Format.std_formatter)
54
55 let main args =
56 try
57 coqdep args
58 with exn ->
59 Format.eprintf "*** Error: @[%a@]@\n%!" Pp.pp_with (CErrors.print exn);
60 exit 1