Module Brzo_b0_ocaml.Mod_resolver
Data-driven OCaml module and compilation objects resolver.
FIXME. The stdlib is difficult to specify for opam system switches. E.g. if one wants to use `Locked. In a regular opam switch the dependency restriction is ocaml, in a system switch it can't be specified.
Resolution restrictions
type dep= B0_std.Fpath.tThe type for dependency restrictions. This is a relative file path denoting a directory in one of the dependency directories.
type deps=[|`Open of dep list|`Locked of dep list]The type for dependency restrictions. Restrictions are expressed relative to dependency directories
ds.`Open ps, ambiguities are resolved by the first matching path ofpsin the firstds(if any).`Locked ps, dependencies are only resolved inpsdirectories ofdsand in case of ambiguity in the first matching path ofpsin the firstds(if any).
Note.
`Openrestrictions make compilation successes dependent on the state of the dependency directories. Technically so does`Locked, but it shouldn't assuming an opam like package install structure.
val unrestricted : depsunrestrictedis`Open [], unrestricted dependencies.
Resolver
val create : B00.Memo.t -> memo_dir:B0_std.Fpath.t -> dep_dirs:B0_std.Fpath.t list -> deps -> t * [ `Miss_deps of dep list ]create m ~memo_dir ~dep_dirs depsis a module resolver with restrictionsdepsin dependency directoriesdep_dirsusingmandmemo_dirto memoize its results.`Miss_depis the list of dependencies that couldn't be found in either of thedep_dirs.
val memo : t -> B00.Memo.tmemo ris the memoizer ofr.
val index : t -> B0_findex.tindex ris the file index ofr, that is the unrestricted index ofdep_dirs.
val dep_dirs : t -> B0_std.Fpath.t listdep_dirs rare the dependency directories.
Lookups
Note. File objects returned by find_* functions are made ready in memo r.
val cmi_obj : t -> B0_std.Fpath.t -> Brzo_ocaml_cmi.t B00.Memo.Fut.tcmi_obj r fileasks for the cmi compilation object of filefile. FIXME let the fut be a fiber.
val find_cmi_side_cmx_file : t -> Brzo_ocaml_cmi.t -> B0_std.Fpath.t optionfind_cmi_side_cmx_file r cmireturns an existing sidecmxfile forcmilocated along side it. FIXME be principled about that: makes as a side effect ready inmemo r.
val find_cmi_files_for_mod_name : t -> B0_ocaml.Mod_name.t -> B0_std.Fpath.t listfind_cmi_files_for_mod_name r mnfinds cmi files whose filename could resolve to module namemn.
val find_cmis_for_mod_name : t -> B0_ocaml.Mod_name.t -> Brzo_ocaml_cmi.t list B00.Memo.fiberfind_cmis_for_mod_name r mnfinds cmi information for files whose filename could resolve to module namemninr.
val find_cmis_for_mod_ref : t -> B0_ocaml.Mod_ref.t -> Brzo_ocaml_cmi.t list B00.Memo.fiberfind_cmis_for_mod_ref r mrefare the cmis that resolve tomrefinr.
val find_impl_for_mod_ref : t -> ext:string -> B0_ocaml.Mod_ref.t -> B0_ocaml.Cobj.t option B00.Memo.fiberfind_impl_for_mod_ref r ~ext mrefcontinues with an implementation file formrefwith extensionextand a suitable cmi file to use.
val find_rec_impls_for_mod_refs : ?deps:(B0_ocaml.Cobj.t -> B0_ocaml.Mod_ref.Set.t) -> t -> ext:string -> B0_ocaml.Mod_ref.Set.t -> B0_ocaml.Cobj.t list B00.Memo.fiberfind_rec_impls_for_mod_refs ~deps r ~ext mrefscontinues with a list of implementation files with extentionsextformrefs and their recursive dependencies determined according todeps(defaults toCobj.link_deps). The list is sorted in link order.