Module B0_driver.Driver

module Driver: sig .. end
Drivers.

A driver is an executable that provides a service on a root description. Some commands of the driver may need the description to run and others may not.

For driver commands that need the description. Running the driver compiles and links the root description with libraries implementing the driver into a single executable called a driver instance. This executable is then run to provide the driver's service on the root description. If no description can be found the driver's executable is run with an indication that this is the case.

TODO A simple, complete example.



Driver setup


type exec = [ `Driver | `Instance ] 
The type for driver executions. `Driver is the driver executable. `Instance is the driver library linked with the root description.
type setup 
The type for information given to driver commands about the execution.
val b0_dir : setup -> B0_driver.B0_dir.t
b0_dir is the absolute path to the b0 directory.
val color : setup -> B0.Tty.cap option
color s is the requested terminal capability. Note. B0.Tty is already setup accordingly.
val verbosity : setup -> B0.Log.level
verbosity s is the requested log verbosity. Note. B0.Log is already setup accoringly.
val exec : setup -> exec
exec is the kind of execution. Note that if a command requests an `Instance execution, this will be `Driver if no root description was found.

Drivers


type cmd = (setup -> int) Cmdliner.Term.t * Cmdliner.Term.info *
exec
The type for driver command specifications.
type t 
The type for drivers.
val create : name:string ->
version:string ->
libs:string list -> cmd list -> t
create ~name ~version ~libs cmds main is a driver named name versioned with version that implements its service using the libraries libs sorted in dependency order (recursive dependencies are not looked up) and the given cmds. The B0_driver library and its recursive dependencies should not be mentioned in libs.

The given cmd terms are wrapped with additional options for configuring and setting up the driver instance. These options are documented in the B0_driver.Cli.s_driver_opts section of the commands manual. cmds that requested `Instance execution will be run as `Driver if no root description is found.

val set : t -> unit
set d sets the driver to d. This must be set by one of the driver's libraries mentioned in B0_driver.Driver.create.
Raises Invalid_argument if a driver is already set.
val driver_main : unit -> unit
driver_main () runs the driver executable's main function. This must be called by the driver executable.
Raises Invalid_argument if no driver was set.
val instance_main : unit -> unit
instance_main () runs the driver instance's main function. This gets called by the compiled driver instance.