package b0

  1. Overview
  2. Docs

OCaml toolchain configuration.

Thid module provides access to the OCaml toolchain configuration as output by ocaml{c,opt} -config.

It also provides bits to orchestrate byte and native OCaml builds.

Configuration

type t

The type for the OCaml toolchain configuration.

val find : string -> t -> string option

find f c looks up the field f in configuration c. See ocamlc -config for the list of fields.

val version : t -> int * int * int * string option

version c is the compiler version string "major.minor[.patchlevel][+additional-info]" parsed using (major, minor, patch, additional-info). If patch-level is absent it is turned into a 0.

val where : t -> B00_std.Fpath.t

where c is the location of OCaml's library directory.

val asm_ext : t -> B00_std.Fpath.ext

asm_ext is the file extension for assembly files.

val dll_ext : t -> B00_std.Fpath.ext

dll_ext is the file extension for C dynamic libraries.

val exe_ext : t -> B00_std.Fpath.ext

ext_ext is the file extension for executable binaries.

val lib_ext : t -> B00_std.Fpath.ext

ext_lib is the file extension for C static libraries.

val obj_ext : t -> B00_std.Fpath.ext

obj_ext is the file extension for C object files.

Converting

val to_string_map : t -> string B00_std.String.Map.t

to_string_map c are the fields of c as a string map.

val of_string_map : string B00_std.String.Map.t -> (t, string) result

of_string_map m is a configuration from string map m. m needs at least a "version" key otherwise the function errors.

IO

val write : B00.Memo.t -> comp:B00.Tool.t -> o:B00_std.Fpath.t -> unit

write m ~o writes the toolchain configuration to o by running comp with -config.

read m file reads a toolchain configuration from file.

val of_string : ?file:B00_std.Fpath.t -> string -> (t, string) result

of_string ~file data parses toolchain configuration from data as output by the compiler's -config option assuming it was read from file file (defaults to B00_std.Os.File.dash.

Build orchestration

XXX Maybe move that to B0_ocaml.

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.

type built_code = [
  1. | `Byte
  2. | `Native
  3. | `Both
]

The type indicating which code is being built.

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

build_code indicates which code should be built, default determines to `Auto. `Auto indicates `Native should be 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 build_code.

val key : t B00.Store.key

key is a memo key store with the OCaml configuration.

TODO remove that

val exists : B00.Memo.t -> bool B00.Memo.fiber
val if_exists : B00.Memo.t -> (unit -> 'a B00.Memo.fiber) -> 'a option B00.Memo.fiber
val stdlib_dir : B00.Memo.t -> unit -> B00_std.Fpath.t B00.Memo.fiber
OCaml

Innovation. Community. Security.