Skip to content

Commit cb37784

Browse files
committed
Fix rocq-prover#7413: coqdep warning on repeated files
The same warning exists in ocamllibdep so I copied the change there. Detecting when 2 paths are the same is approximate, eg ././a.ml and a.ml are considered different. Implementing realpath probably isn't worth doing for this warning.
1 parent 90ac335 commit cb37784

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tools/coqdep_common.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,18 @@ let safe_hash_add cmp clq q (k, (v, b)) =
102102
For the ML files, the string is the basename without extension.
103103
*)
104104

105+
let same_path_opt s s' =
106+
let nf s = (* ./foo/a.ml and foo/a.ml are the same file *)
107+
if Filename.is_implicit s
108+
then "." // s
109+
else s
110+
in
111+
let s = match s with None -> "." | Some s -> nf s in
112+
let s' = match s' with None -> "." | Some s' -> nf s' in
113+
s = s'
114+
105115
let warning_ml_clash x s suff s' suff' =
106-
if suff = suff' then
116+
if suff = suff' && not (same_path_opt s s') then
107117
eprintf
108118
"*** Warning: %s%s already found in %s (discarding %s%s)\n" x suff
109119
(match s with None -> "." | Some d -> d)

tools/ocamllibdep.mll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,18 @@ let error_cannot_parse s (i,j) =
116116
Printf.eprintf "File \"%s\", characters %i-%i: Syntax error\n" s i j;
117117
exit 1
118118

119+
let same_path_opt s s' =
120+
let nf s = (* ./foo/a.ml and foo/a.ml are the same file *)
121+
if Filename.is_implicit s
122+
then "." // s
123+
else s
124+
in
125+
let s = match s with None -> "." | Some s -> nf s in
126+
let s' = match s' with None -> "." | Some s' -> nf s' in
127+
s = s'
128+
119129
let warning_ml_clash x s suff s' suff' =
120-
if suff = suff' then
130+
if suff = suff' && not (same_path_opt s s') then
121131
eprintf
122132
"*** Warning: %s%s already found in %s (discarding %s%s)\n" x suff
123133
(match s with None -> "." | Some d -> d)

0 commit comments

Comments
 (0)