8
8
(* * (see LICENSE file for the text of the license) *)
9
9
(* ***********************************************************************)
10
10
11
- open Printf
11
+ open Format
12
12
open Coqdep_lexer
13
13
open Coqdep_common
14
- open System
14
+ open Minisys
15
15
16
16
(* * The basic parts of coqdep (i.e. the parts used by [coqdep -boot])
17
17
are now in [Coqdep_common]. The code that remains here concerns
18
18
the other options. Calling this complete coqdep with the [-boot]
19
19
option should be equivalent to calling [coqdep_boot].
20
+
21
+ As of today, this module depends on the following Coq modules:
22
+
23
+ - Flags
24
+ - Envars
25
+ - CoqProject_file
26
+
27
+ All of it for `coqlib` handling. Ideally we would like to clean
28
+ coqlib handling up so this can be bootstrapped earlier.
20
29
*)
21
30
22
31
let option_D = ref false
@@ -31,8 +40,7 @@ let warning_mult suf iter =
31
40
let d' = Hashtbl. find tab f in
32
41
if (Filename. dirname (file_name f d))
33
42
<> (Filename. dirname (file_name f d')) then begin
34
- eprintf " *** Warning : the file %s is defined twice!\n " (f ^ suf);
35
- flush stderr
43
+ coqdep_warning " the file %s is defined twice!" (f ^ suf)
36
44
end
37
45
with Not_found -> () end ;
38
46
Hashtbl. add tab f d
@@ -80,9 +88,7 @@ let mL_dep_list b f =
80
88
while true do
81
89
let (Use_module str) = caml_action buf in
82
90
if str = b then begin
83
- eprintf " *** Warning : in file %s the" f;
84
- eprintf " notation %s. is useless !\n " b;
85
- flush stderr
91
+ coqdep_warning " in file %s the notation %s. is useless !\n " f b
86
92
end else
87
93
if not (List. mem str ! deja_vu) then addQueue deja_vu str
88
94
done ; []
@@ -98,16 +104,13 @@ let affiche_Declare f dcl =
98
104
printf " \n *** In file %s: \n " f;
99
105
printf " Declare ML Module" ;
100
106
List. iter (fun str -> printf " \" %s\" " str) dcl;
101
- printf " .\n " ;
102
- flush stdout
107
+ printf " .\n %!"
103
108
104
109
let warning_Declare f dcl =
105
- eprintf " *** Warning : in file %s, the ML modules" f;
106
- eprintf " declaration should be\n " ;
110
+ eprintf " *** Warning : in file %s, the ML modules declaration should be\n " f;
107
111
eprintf " *** Declare ML Module" ;
108
112
List. iter (fun str -> eprintf " \" %s\" " str) dcl;
109
- eprintf " .\n " ;
110
- flush stderr
113
+ eprintf " .\n %!"
111
114
112
115
let traite_Declare f =
113
116
let decl_list = ref ([] : string list ) in
@@ -149,7 +152,7 @@ let declare_dependencies () =
149
152
List. iter
150
153
(fun (name ,_ ) ->
151
154
traite_Declare (name^ " .v" );
152
- flush stdout )
155
+ pp_print_flush std_formatter () )
153
156
(List. rev ! vAccu)
154
157
155
158
(* * DAGs guaranteed to be transitive reductions *)
@@ -426,11 +429,11 @@ let coq_dependencies_dump chan dumpboxes =
426
429
(DAG. empty, List. fold_left (fun ih (file , _ ) -> insert_raw_graph file ih) [] ! vAccu,
427
430
List. map fst ! vAccu) ! vAccu
428
431
in
429
- fprintf chan " digraph dependencies {\n " ; flush chan;
432
+ fprintf chan " digraph dependencies {\n " ;
430
433
if dumpboxes then print_graphs chan (pop_common_prefix graphs)
431
434
else List. iter (fun (name , _ ) -> fprintf chan " \" %s\" [label=\" %s\" ]\n " name (basename_noext name)) ! vAccu;
432
435
DAG. iter (fun name dep -> fprintf chan " \" %s\" -> \" %s\"\n " dep name) deps;
433
- fprintf chan " }\n "
436
+ fprintf chan " }\n %! "
434
437
435
438
end
436
439
@@ -498,7 +501,7 @@ let rec parse = function
498
501
| "-suffix" :: s :: ll -> suffixe := s ; parse ll
499
502
| "-suffix" :: [] -> usage ()
500
503
| "-slash" :: ll ->
501
- Printf. eprintf " warning: option -slash has no effect and is deprecated.\n " ;
504
+ coqdep_warning " warning: option -slash has no effect and is deprecated." ;
502
505
parse ll
503
506
| "-dyndep" :: "no" :: ll -> option_dynlink := No ; parse ll
504
507
| "-dyndep" :: "opt" :: ll -> option_dynlink := Opt ; parse ll
@@ -520,7 +523,6 @@ let coqdep () =
520
523
if ! option_boot then begin
521
524
add_rec_dir_import add_known " theories" [" Coq" ];
522
525
add_rec_dir_import add_known " plugins" [" Coq" ];
523
- add_caml_dir " tactics" ;
524
526
add_rec_dir_import (fun _ -> add_caml_known) " theories" [" Coq" ];
525
527
add_rec_dir_import (fun _ -> add_caml_known) " plugins" [" Coq" ];
526
528
end else begin
@@ -531,7 +533,7 @@ let coqdep () =
531
533
let user = coqlib// " user-contrib" in
532
534
if Sys. file_exists user then add_rec_dir_no_import add_coqlib_known user [] ;
533
535
List. iter (fun s -> add_rec_dir_no_import add_coqlib_known s [] )
534
- (Envars. xdg_dirs ~warn: (fun x -> Feedback. msg_warning ( Pp. str x) ));
536
+ (Envars. xdg_dirs ~warn: (fun x -> coqdep_warning " %s " x ));
535
537
List. iter (fun s -> add_rec_dir_no_import add_coqlib_known s [] ) Envars. coqpath;
536
538
end ;
537
539
List. iter (fun (f ,d ) -> add_mli_known f d " .mli" ) ! mliAccu;
@@ -547,7 +549,8 @@ let coqdep () =
547
549
| None -> ()
548
550
| Some (box , file ) ->
549
551
let chan = open_out file in
550
- try Graph. coq_dependencies_dump chan box; close_out chan
552
+ let chan_fmt = formatter_of_out_channel chan in
553
+ try Graph. coq_dependencies_dump chan_fmt box; close_out chan
551
554
with e -> close_out chan; raise e
552
555
end
553
556
@@ -556,4 +559,4 @@ let _ =
556
559
coqdep ()
557
560
with CErrors. UserError (s ,p ) ->
558
561
let pp = (match s with | None -> p | Some s -> Pp. (str s ++ str " : " ++ p)) in
559
- Format. eprintf " %a@\n %!" Pp. pp_with pp
562
+ eprintf " %a@\n %!" Pp. pp_with pp
0 commit comments