Library
Module
Module type
Parameter
Class
Class type
OCaml compilation objects.
Note. All paths returned by functions of this module are made absolute (using for now, a fake realpath(2)
).
module Digest : sig ... end
Compilation object digests.
type digest = Digest.t
The type for compilation object digests.
type dep = string * digest option
The type for compilation object dependencies. A module name and an optional digest (often a cmi
digest).
module Mli : sig ... end
mli
files.
module Cmi : sig ... end
cmi
files.
module Cmti : sig ... end
cmti
files.
module Ml : sig ... end
ml
files.
module Cmo : sig ... end
cmo
files.
module Cmt : sig ... end
cmt
files.
module Cma : sig ... end
cma
files.
module Cmx : sig ... end
cmx
files.
module Cmxa : sig ... end
cmxa
files.
module Cmxs : sig ... end
cmxs
files.
val empty_set : set
empty_set
is an empty set of compilation objects.
cmos ~files s
is the list of cmo
s contained in s
. If files
is true
(defaults to false
), only the cmo
files are listed and cmo
s that are part of cma
files are omitted.
cmxs ~files s
is the list of cmx
s contained in s
. If files
is true
(defaults to false
), only the cmx
files are listed and cmx
s that are part of cmxa
files are omitted.
val set_of_dir :
?err:(Fpath.t -> ('a, [ `Msg of string ]) Pervasives.result -> unit) ->
Fpath.t ->
set
set_of_dir ~err d
is the set of compilation objects that are present in the file hierarchy rooted at d
.
This is a best-effort function, it will call err
on errors and continue; at worst you'll get an empty_set
. err
's default simply logs the error at level Logs.level.Error
.
See Index.t
.
module Index : sig ... end
Compilation object indexes
The type for dependency resolutions. Either no, some or an ambiguous resolution.
type ('a, 'o) dep_resolver = dep -> ('a * 'o) list -> ('a, 'o) dep_resolution
The type for dependency resolvers. Determines a resolution from a dependency and list of matching candidates.
val cmi_for_interface :
resolve:('a, cmi) dep_resolver ->
'a index ->
dep ->
('a, cmi) dep_resolution
cmi_for_interface ~resolve i dep
is the resolution resolve
of cmi
s matching module interface dep
in i
.
val cmo_for_interface :
resolve:('a, cmo) dep_resolver ->
'a index ->
dep ->
('a, cmo) dep_resolution
cmo_for_interface ~resolve i dep
is the resolution resolve
of cmo
s matching module interface dep
in i
.
val cmx_for_interface :
resolve:('a, cmx) dep_resolver ->
'a index ->
dep ->
('a, cmx) dep_resolution
cmx_for_interface ~resolve i dep
is the resolution resolve
of cmx
s matching module interface dep
in i
.
The type for dependency sources. Tracks an object (head) to its source (tail). This is only used to allow good end-user feedback.
type ('a, 'o) rec_dep_resolution = [
| `Resolved of ('a * 'o) * ('a, 'o) dep_src
| `Unresolved of dep * [ `None | `Amb of ('a * 'o) list ] * ('a, 'o) dep_src
| `Conflict of string * ('a, 'o) dep_src list Digest.map
]
The type for recursive dependency resolution:
`Resolved (obj, src)
, a resolved object obj
. src
is one of the sources for obj
.`Unresolved (dep, reason, src)
, unresolved dependency dep
for reason reason
; either not found or ambiguous. src
is one of the sources of dep
.`Conflict (n, dm)
, conflicting resolution for module name n
. dm
is the set of conflicting digests for n
mapped to one of their source.val pp_rec_dep_resolution :
('a * 'o) Fmt.t ->
('a, 'o) rec_dep_resolution Fmt.t
pp_rec_dep_resolution pp_obj
is an unspecified formatter for recursive dependency resolutions using pp_obj
to format objects.
val rec_cmis_for_interfaces :
resolve:('a, cmi) dep_resolver ->
'a index ->
(dep * ('a, cmi) dep_src) list ->
('a, cmi) rec_dep_resolution Astring.String.map
See, mutatis mutandis, rec_cmos_for_interfaces
.
val rec_cmos_for_interfaces :
?cmo_deps:(cmo -> dep list) ->
resolve:('a, cmo) dep_resolver ->
'a index ->
(dep * ('a, cmo) dep_src) list ->
('a, cmo) rec_dep_resolution Astring.String.map
rec_cmos_for_interfaces ~cmo_deps ~resolve i deps
maps module names to the result of recursively resolving module interface dependencies deps
(tupled with a dependency source) to cmo
s in i
using resolve
. More precisely:
deps
are resolved to cmo
s. Then for each of these cmo
s, their interface dependencies, as determined by cmo_deps
(defaults to Cmo.cmi_deps
) are resolved to cmo
s and recursively.index
, existing objects excluded by resolve
, ambiguous objects not decided by resolve
or because a module interface has no corresponding implementation – the OCaml compilation model allows this.val fold_rec_dep_resolutions :
deps:('o -> dep list) ->
(string -> ('a, 'o) rec_dep_resolution -> 'b -> 'b) ->
('a, 'o) rec_dep_resolution Astring.String.map ->
'b ->
'b
fold_rec_dep_resolutions ~deps f res acc
folds f
with acc
over the partial evaluation order of res
using deps
on resolved objects. Conflicts and unresolved dependencies are also folded over.