let read_path_dependencies =
let path_dependencies = Hashtbl.create 103 in
let read path =
let module_name = module_name_of_pathname path in
let depends = path-.-"depends" in
with_input_file depends begin fun ic ->
let ocamldep_output =
try Lexers.ocamldep_output (Lexing.from_channel ic)
with Lexers.Error msg -> raise (Ocamldep_error(Printf.sprintf "Ocamldep.ocamldep: bad output (%s)" msg)) in
let deps =
List.fold_right begin fun (path, deps) acc ->
let module_name' = module_name_of_pathname path in
if module_name' = module_name
then List.union deps acc
else raise (Ocamldep_error(Printf.sprintf "Ocamldep.ocamldep: multiple files in ocamldep output (%s not expected)" path))
end ocamldep_output [] in
let deps =
if !Options.nostdlib && not (Tags.mem "nopervasives" (tags_of_pathname path)) then
"Pervasives" :: deps
else deps in
let deps' = List.fold_right begin fun dep acc ->
match path_importance path dep with
| `ignored -> acc
| (`just_try | `mandatory) as importance -> (importance, dep) :: acc
end deps [] in
Hashtbl.replace path_dependencies path
(List.union (try Hashtbl.find path_dependencies path with Not_found -> []) deps');
deps'
end
in read