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.t
The 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 ofps
in the firstds
(if any).`Locked ps
, dependencies are only resolved inps
directories ofds
and in case of ambiguity in the first matching path ofps
in the firstds
(if any).
Note.
`Open
restrictions 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 : deps
unrestricted
is`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 deps
is a module resolver with restrictionsdeps
in dependency directoriesdep_dirs
usingm
andmemo_dir
to memoize its results.`Miss_dep
is the list of dependencies that couldn't be found in either of thedep_dirs
.
val memo : t -> B00.Memo.t
memo r
is the memoizer ofr
.
val index : t -> B0_findex.t
index r
is the file index ofr
, that is the unrestricted index ofdep_dirs
.
val dep_dirs : t -> B0_std.Fpath.t list
dep_dirs r
are 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.t
cmi_obj r file
asks 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 option
find_cmi_side_cmx_file r cmi
returns an existing sidecmx
file forcmi
located 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 list
find_cmi_files_for_mod_name r mn
finds 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.fiber
find_cmis_for_mod_name r mn
finds cmi information for files whose filename could resolve to module namemn
inr
.
val find_cmis_for_mod_ref : t -> B0_ocaml.Mod_ref.t -> Brzo_ocaml_cmi.t list B00.Memo.fiber
find_cmis_for_mod_ref r mref
are the cmis that resolve tomref
inr
.
val find_impl_for_mod_ref : t -> ext:string -> B0_ocaml.Mod_ref.t -> B0_ocaml.Cobj.t option B00.Memo.fiber
find_impl_for_mod_ref r ~ext mref
continues with an implementation file formref
with extensionext
and 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.fiber
find_rec_impls_for_mod_refs ~deps r ~ext mrefs
continues with a list of implementation files with extentionsext
formref
s and their recursive dependencies determined according todeps
(defaults toCobj
.link_deps). The list is sorted in link order.