package b0

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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.

type lib = t

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

type 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.

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

The type for the scope finding function.

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

The type for the scope missing library suggestion function.

val 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.

val scope_name : scope -> string

scope_name s is the name of s.

val scope_find : scope -> scope_find

scope_find s is the lookup funtion of s.

val scope_suggest : scope -> scope_suggest

scope_suggest s is the scope suggestion function.

Predefined resolution scopes

val 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.

val 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

type t

The type for library resolvers.

val 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.

val ocaml_conf : t -> Conf.t

ocaml_conf r is the OCaml configuration of the resolver.

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

find r n finds library name n in l.

val 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.

val 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.

val 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.

OCaml

Innovation. Community. Security.