summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2015-08-15 15:57:57 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2015-08-15 15:57:57 +0000
commit02abd6c2442c30ecc7dc42ba2d6d6ccc526843f7 (patch)
treee875d13aa72f6fc4b8efc8e2f5517d1d9179f480 /tools
parent459061e182aebb646fbd460ffa1822a6d19c9a3f (diff)
downloadocaml-02abd6c2442c30ecc7dc42ba2d6d6ccc526843f7.tar.gz
ocamldep: make printing of cyclic dependencies deterministic
Hashtbl.iter used to be deterministic, but it's now an observable source of randomness. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16351 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools')
-rw-r--r--tools/ocamldep.ml9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/ocamldep.ml b/tools/ocamldep.ml
index 0206846547..c57521d22f 100644
--- a/tools/ocamldep.ml
+++ b/tools/ocamldep.ml
@@ -440,14 +440,19 @@ let sort_files_by_dependencies files =
if !worklist <> [] then begin
Format.fprintf Format.err_formatter
"@[Warning: cycle in dependencies. End of list is not sorted.@]@.";
- Hashtbl.iter (fun _ (file, deps) ->
+ let sorted_deps =
+ let li = ref [] in
+ Hashtbl.iter (fun _ file_deps -> li := file_deps :: !li) h;
+ List.sort (fun (file1, _) (file2, _) -> String.compare file1 file2) !li
+ in
+ List.iter (fun (file, deps) ->
Format.fprintf Format.err_formatter "\t@[%s: " file;
List.iter (fun (modname, kind) ->
Format.fprintf Format.err_formatter "%s.%s " modname
(if kind=ML then "ml" else "mli");
) !deps;
Format.fprintf Format.err_formatter "@]@.";
- Printf.printf "%s " file) h;
+ Printf.printf "%s " file) sorted_deps;
end;
Printf.printf "\n%!";
()