Module B0_ocaml

OCaml B0 file support.

Units

A few high-level build units.

val libname : string -> B00_ocaml.Lib.Name.t

libname n is n as an OCaml library name. This is shortcut for B00_ocaml.Lib.Name.v.

val exe : ?wrap:(B0_unit.proc -> B0_unit.proc) -> ?doc:string -> ?meta:B0_meta.t -> ?action:B0_unit.action -> ?requires:B00_ocaml.Lib.Name.t list -> ?name:string -> string -> srcs:B0_srcs.sels -> B0_unit.t

exe n is a build unit for an executable named n (without the platform specific extension).

  • doc is the unit doc string.
  • meta is the initial metadata.
  • requires are the OCaml libraries required to compile the executable.
  • name is the name of the unit (defaults to n).
  • srcs are the executable sources. All files with extension .ml, .mli, .c and .h are considered for compiling and linking the executable.
  • wrap allows to extend the build procedure you must call the given build procedure. TODO maybe remove once we have good Build fragments.
val lib : ?wrap:(B0_unit.proc -> B0_unit.proc) -> ?doc:string -> ?meta:B0_meta.t -> ?action:B0_unit.action -> ?requires:B00_ocaml.Lib.Name.t list -> ?name:string -> B00_ocaml.Lib.Name.t -> srcs:B0_srcs.sels -> B0_unit.t

lib n ~srcs is a built unit for a library named l made of sources src.

  • doc is the unit doc string.
  • meta is the initial metadata.
  • requires are the OCaml libraries required to compile the library.
  • name is the name of the build unit (default to n with . substituted by -)
  • srcs are the library sources. extension .ml, .mli, .c and .h are considered for compiling and linking the executable.
  • wrap allows to extend the build procedure you must call the given build procedure. TODO maybe remove once we have good Build fragments.

Build configuration

conf is a memo key store with the OCaml configuration.

val version : B0_build.t -> (int * int * int * string option) B00_std.Fut.t

ocaml_version b gets B00_ocaml.Tool.Conf.version from conf.

Generated code

In a build it is desirable to know which code is being produced because if both are produced the compilers may compete to produce some of the shared build artefacts. The following store keys allow to express build code desires and determine the actual decision. Note the desires may actually be altered units that may build FIXME maybe we should stick to must.

type built_code = [
| `Byte
| `Native
| `All
]

The type indicating which code is being built.

val pp_built_code : built_code B00_std.Fmt.t

pp_built_code formats built_code values.

val wanted_code : [ built_code | `Auto ] B00.Store.key

wanted_code indicates which code should be built, default determines to `Auto. If `Auto is used and no unit that may build has specific Meta.needs_code then `Native is used if ocamlopt can be found in the memo environment and `Byte otherwise.

val built_code : built_code B00.Store.key

build_code is a memo key indicating the built code. By default determines by consulting wanted_code.

Build fragments

See TODO.

Metadata

val tag : unit B0_meta.key

tag indicates the entity is related to OCaml.

module Meta : sig ... end

Metadata keys

Library resolution

lib_resolver is the library resolver used by the build units defined by this module. See default_lib_resolver for the default.

default_lib_resolver determines the default value of lib_resolver. This resolver does the following:

  1. It first 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.
  2. It looks into the build environment via B00_ocaml.Lib.Resolver.ocamlpath and B00_ocaml.Lib.Resolver.ocamlfind using the B0_build.shared_build_dir directory of the build.

lib_of_unit b ocaml_conf u defines a library from unit u by consulting Meta.requires, Meta.library and Meta.mod_srcs. As a side effect this B0_build.require u.

val lib_resolver_build_scope : B0_build.t -> B00_ocaml.Conf.t -> B00_ocaml.Lib.Resolver.scope

lib_resolver_build_scope 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: