Module Lib.ResolverSource

Library resolvers.

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.

Sourcetype lib = t

The type for libraries, see B00_ocaml.Lib.t.

Sourcetype scope

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.

Sourcetype scope_find = Conf.t -> B00.Memo.t -> Name.t -> lib option B0_std.Fut.t

The type for the scope finding function.

Sourcetype scope_suggest = Conf.t -> B00.Memo.t -> Name.t -> string option B0_std.Fut.t

The type for the scope missing library suggestion function.

Sourceval scope : name:string -> find:scope_find -> suggest:scope_suggest -> scope

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

Sourceval scope_name : scope -> string

scope_name s is the name of s.

Sourceval scope_find : scope -> scope_find

scope_find s is the lookup funtion of s.

Sourceval scope_suggest : scope -> scope_suggest

scope_suggest s is the scope suggestion function.

Predefined resolution scopes

Sourceval ocamlpath : cache_dir:B0_std.Fpath.t -> ocamlpath:B0_std.Fpath.t list -> scope

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

Note. This is a nop for now.

Sourceval ocamlfind : cache_dir:B0_std.Fpath.t -> scope

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, the all lookup the latter and mt,mt_posix is added to the predicates. threads.vm is unsupported (but deprecated anyways).

Resolver

Sourcetype t

The type for library resolvers.

Sourceval create : B00.Memo.t -> Conf.t -> scope list -> t

create m ocaml_conf scopes is a library resolver looking for libraries in the given scopes, in order. ocaml_conf is the toolchain configuration. m gets marked by ocamlib.

Sourceval ocaml_conf : t -> Conf.t

ocaml_conf r is the OCaml configuration of the resolver.

Sourceval find : t -> Name.t -> lib option B0_std.Fut.t

find r n finds library name n in l.

Sourceval get : t -> Name.t -> lib B0_std.Fut.t

find r l finds library name l using r. The memo of r fails if a library cannot be found.

Sourceval get_list : t -> Name.t list -> lib list B0_std.Fut.t

get_list b ns looks up the libraries ns in the build b using lib_resolver. Libraries are returned in the given order and the memo of r fails if a library cannot be found.

Sourceval get_list_and_deps : t -> Name.t list -> lib list B0_std.Fut.t

get_list_and_deps b ns looks up the libraires ns and their dependencies in the build b using lib_resolver. The result is a sorted in (stable) dependency order.