Skip to content

Commit 75fb47b

Browse files
committed
voodoo: transitive-close lib_deps before per-compile -I emission
We've been missing some include paths when building docs for some packages. This doesn't affect other modes of odoc_driver as they go through `Packages.fix_missing_deps`.
1 parent 6451247 commit 75fb47b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/driver/voodoo.ml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,29 @@ let of_voodoo pkg =
104104
(Util.StringMap.empty, []) metas
105105
in
106106

107+
(* Transitively close [all_lib_deps] over itself so each lib's deps
108+
reflect every lib reachable through META requires. *)
109+
let all_lib_deps =
110+
let cache : (string, Util.StringSet.t) Hashtbl.t =
111+
Hashtbl.create (Util.StringMap.cardinal all_lib_deps) in
112+
let rec close lib =
113+
match Hashtbl.find_opt cache lib with
114+
| Some r -> r
115+
| None ->
116+
Hashtbl.add cache lib Util.StringSet.empty;
117+
let direct = match Util.StringMap.find_opt lib all_lib_deps with
118+
| Some s -> s
119+
| None -> Util.StringSet.empty
120+
in
121+
let closed = Util.StringSet.fold (fun dep acc ->
122+
Util.StringSet.union (Util.StringSet.add dep (close dep)) acc
123+
) direct Util.StringSet.empty in
124+
Hashtbl.replace cache lib closed;
125+
closed
126+
in
127+
Util.StringMap.mapi (fun lib _ -> close lib) all_lib_deps
128+
in
129+
107130
let ss_pp fmt ss = Format.fprintf fmt "[%d]" (Util.StringSet.cardinal ss) in
108131
Logs.debug (fun m ->
109132
m "all_lib_deps: %a\n%!"

0 commit comments

Comments
 (0)