package b0
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=00a6868b4dfa34565d0141b335622a81a0e8d5b9e3c6dfad025dabfa3df2db2a1302b492953bbbce30c3a4406c324fcec25250a00b38f6d18a69e15605e3b07e
doc/b0.kit/B0_ocaml/index.html
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 ->
?c_requires:B0_std.Cmd.t ->
?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.c_requires
FIXME hack, something more sensitive should be done. This each of these options are passed as-cclib
options.requires
are the OCaml libraries required to compile the executable.name
is the name of the unit (defaults ton
).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 ->
?c_requires:B0_std.Cmd.t ->
?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.c_requires
FIXME hack, something more sensitive should be done. This each of these options are passed as-cclib
options.requires
are the OCaml libraries required to compile the library.name
is the name of the build unit (default ton
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
val conf : B00_ocaml.Conf.t B00.Store.key
conf
is a memo key store with the OCaml configuration.
val version : B0_build.t -> (int * int * int * string option) B0_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.
val pp_built_code : built_code B0_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
val lib_resolver : B00_ocaml.Lib.Resolver.t B00.Store.key
lib_resolver
is the library resolver used by the build units defined by this module. See default_lib_resolver
for the default.
val default_lib_resolver :
B00.Store.t ->
B00.Memo.t ->
B00_ocaml.Lib.Resolver.t B0_std.Fut.t
default_lib_resolver
determines the default value of lib_resolver
. This resolver does the following:
- 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
. - It looks into the build environment via
B00_ocaml.Lib.Resolver.ocamlpath
andB00_ocaml.Lib.Resolver.ocamlfind
using theB0_build.shared_build_dir
directory of the build.
val lib_of_unit :
B0_build.t ->
B00_ocaml.Conf.t ->
B0_unit.t ->
B00_ocaml.Lib.t option B0_std.Fut.t
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:
- Be in the
B0_build.may_build
set ofb
. - Define the
Meta.library
andMeta.requires
in its metadata.