Module Omod_support.Cobj

Compilation objects

Package identifiers

type pkg_id = string * Omod.fpath

The type for package identifiers. A package name and its root directory.

val pp_pkg_id : Format.formatter -> pkg_id -> unit

pp_pkg_id formats package identifiers.

Dependencies

type dep = string * Digest.t option

The type for compilation object dependencies. A module name and an optional interface digest.

val pp_dep : Format.formatter -> dep -> unit

pp_dep formats a dependency.

Specifications

val spec_of_string : string -> (string option * string * string list, string) result

spec_of_string s parses a compilation object specification from s. This parses the [PKG.]M(\@VARIANT)+ syntax.

Compilation objects

type kind =
| Cmi
| Cmo
| Cmx

The type for kind of compilation objects.

val kind_of_string : string -> kind option

kind_of_string s parses s into a kind.

val kind_to_string : kind -> string

kind_to_string k is k as a string.

exts are the file extensions of compilation objects.

type t

The type for compilation objects.

val v : kind:kind -> pkg_id:pkg_id -> name:string -> iface_digest:Digest.t option -> iface_deps:dep list -> in_archive:bool -> path:Omod.fpath -> path_loads:t list Lazy.t -> t

v is a compilation object with the given parameters, see the documentation of accessors for semantics.

val add_file : pkg_id:pkg_id -> t list -> Omod.fpath -> (t list, string) result

add_file ~pkg_id acc f adds the compilation objects of file f in package pkg_id to acc. If f's extension doesn't match a supported compilation object file this is acc.

val kind : t -> kind

kind c is c's kind.

val pkg_id : t -> pkg_id

pkg_id c is c's package identifier.

val name : t -> string

name c is c's capitalized module name (more precisely compilation unit name).

val variant : t -> string

variant c is c's variant.

val iface_digest : t -> Digest.t option

iface_digest c is c's interface digest (if any).

val iface_deps : t -> dep list

iface_deps c is c's interface dependencies.

val in_archive : t -> bool

in_archive c is true if path is an object archive.

val path : t -> Omod.fpath

path c is c's file path.

val path_loads : t -> t list

path_loads c are all the objects that are loaded whenever path is loaded (includes c itself). For paths that point to archives this has all the objects of the archive.

val to_dep : t -> dep

to_dep c is c as an interface dependency.

Predicates

val is_kind : kind -> t -> bool

is_kind k c is true iff kind c = k.

val equal : t -> t -> bool

equal c c' tests c and c' for equality (all components must match).

val compare : t -> t -> int

compare is a total order compatible with equal.

val ui_compare : t -> t -> int

ui_compare orders by name, package, variant and path.

Formatters

val pp : Format.formatter -> t -> unit

pp formats a compilation object.

Indexes and dependency resolvers

module Index : sig ... end

Compilation object indexes.

The type for dependency resolutions. Maps module names to their resolved object.

val resolve_deps : variants:Omod.Private.String.Set.t -> sat:(t -> bool) -> kind:kind -> Index.t -> root_alts:t list list -> (res list, string) result

resolve_deps ~variants ~sat ~kind i roots is a list of resolutions that recursively resolve the dependencies of the alternative root object roots root_alts to compilation objects of kind kind and satisfying sat using the twists of Index.cobjs_for_dep_res.

val fold_res : res -> (t -> 'a -> 'a) -> 'a -> 'a

fold_res res f acc folds f with acc over the partial dependency order of res

  • raises Invalid_argument

    if the dependencies of objects in res are not defined in res, this can't happen if the map is a result of resolve_deps.

val loads : variants:Omod.Private.String.Set.t -> sat:(t -> bool) -> kind:kind -> Index.t -> root_alts:t list list -> (Omod.fpath list list, string) result

loads ~sat ~kind i root_alts resolves the alternative root objects roots root_alts to alternative load sequences of object paths of that have objects of kind kind or Cmis (mli-only modules). All the objects involved in the load sequence satisfy sat.