package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/b0.file/B0_ocaml/Code/index.html
Module B0_ocaml.Code
Source
OCaml compiler code generation specification.
In an OCaml build, the codes that are generated must be precisely known because the OCaml compilers compete to produce shared build artefacts. Besides, the code that needs to be generated for a unit depends on how it will be used. Here are a few examples:
- When compiling a library for installation, all codes supported by the installation must be generated.
- When compiling an executable tool only one code needs to be generated. For example most often native code if available and bytecode if not.
- For a browser executable and considering
B0_jsoo
, only the bytecode must be generated. Native code compilation is technically incompatible.
The user of the build may also want to choose the codes to be generated. If unspecified, a reasonable default should be derived depending on the units that must build.
We call built codes the codes generated in a build. They are stored in Code.built
which OCaml build procedures should consult and adapt to.
Build units can constrain the codes they want their build procedure to generate by defining the Code.restrict
function which given Code.built
must return which codes must be generated for the unit (or the empty set if they can't build). The result is used by the unit's build procedure to act accordingly.
Now remains how to describe how Code.built
is determined. The user can specify a build desire with the Code.wanted
key, see its documentation for details.
Code
The type for codes.
Metadata keys
The type for codes restrictions. Given a set of codes to generate, indicates which ones to generate in a given context. The string is used for documentation.
restrict
can be set on a unit to define which codes should should be generated for the unit. It is invoked by build procedures with the values of Code.built
and should return a subset of it. It default to Fun.id
.
For example B0_ocaml.exe
uses unique_favour_native
.
TODO.
- This should be able to access the configuration.
- This should rather be a per unit
B0_store.key
, determined once and user settable from the cli or a conf spec
unique_favour_native
returns a single code which is Native
if in the given set and Set.min_elt
otherwise, that is Byte
if it's in the set.
check_any ~supported ~by:build
fails the current build unit if the intersection of supported
and built
in build
is empty. This should be used by build procedures to check they can be built. These empty intersections may happen on dynamic requests of may units.
Store keys
type wanted =
| Auto
(*The set made of the union of calling all
*)Code.restrict
of OCaml executable units that must build withB0_ocaml.Conf.codes
orB0_ocaml.Conf.codes
itself if there is no such executable.| Wanted of t list
(*These exact codes.
*)
The type for generated code wanted by the user.
wanted
indicates which codes should be generated. Defaults to Auto
.
Formatting
pp
formats code values.
pp_wanted
formats desires.