Module Libresolver.Scope

Resolution scopes.

Resolution scopes allow to compose and order multiple library resolution mechanisms. In particular it allows b0 to lookup for libraries in builds before trying to resolve them in in the build environment.


type find = Conf.t -> B0_memo.t -> Libname.t -> Lib.t option B0_std.Fut.t

The type for the scope finding function.

type suggest = Conf.t -> B0_memo.t -> Libname.t -> string option B0_std.Fut.t

The type for the scope missing library suggestion function.

type t

The type for scopes. A scope has a name, a library lookup function and possibly a function to indicate how to troubleshoot a missing library.

val make : name:string -> find:find -> suggest:suggest -> t

make ~name ~find ~suggest is a scope named name looking up libraries with find and giving suggestions on missing libraries with suggest.


val find : t -> find

find scope is the lookup function of scope.

val name : t -> string

name scope is the name of scope.

val suggest : t -> suggest

suggest scope is the suggestion function of scope


val cache_dir_name : string

cache_dir_name is a name that can be used for the cache directory of resolution scopes.

val ocamlpath : cache_dir:B0_std.Fpath.t -> t

ocampath ~cache_dir looks up libraries according to the OCaml library convention in the OCAMLPATH of the memo using cache_dir to cache results.

Note. This is a nop for now.

val ocamlfind : cache_dir:B0_std.Fpath.t -> t

ocamlfind ~cache_dir looks up libraries using ocamlfind and caches the result in cache_dir.

A few simplyifing assumptions are made by the resolver, which basically boil down to query the library name LIB with:

ocamlfind query LIB -predicates byte,native -format "%m:%d:%A:%(requires)"

to derive a Lib.t value. This may fail on certain libraries. In particular it assumes a one-to-one map between ocamlfind package names and library names and that the archives are in the library directory.

Also the ocaml.threads, threads and threads.posix libraries are treated specially: they all lookup threads.posix with predicates mt,mt_posix on OCaml < 5.0.0 and simply threads otherwise. threads.vm is unsupported (but deprecated anyways).

val build : B0_build.t -> Conf.t -> t

build b conf is a library resolver scope for OCaml libraries that can be built in b. For a unit u to be recognized as such it has to:

  • It looks if the library name is defined by a unit that may be built. If that is the case it creates a library out of that build unit via Lib.of_unit and resolves to library name to it.
  • TODO public stuff