Module B0.Variant.Scheme

module Scheme: sig .. end
Variant schemes.

A variant scheme sets up the environment for a build variant.


type t 
The type for variant schemes.

Direct schemes


type trigger = [ `After | `Before ] 
The type for event triggers.
type direct 
The type for direct variant schemes. These schemes can only run on the same machine as the build program.
val direct : ?preset:B0.Conf.Preset.t ->
?setup:(B0.Conf.t -> unit B0.result) ->
?delete:(B0.Conf.t -> unit B0.result) ->
?env:(unit -> B0.Env.t B0.result) ->
?build:(trigger -> B0.Build.t -> unit B0.result) ->
?stage:(trigger -> B0.Outcome.t -> unit B0.result) ->
unit -> direct
direct ~preset ~setup ~build ~stage ~delete () is direct variant which applies preset preset to the empty configuration on variant creation, uses setup to setup the variant, build before and after building in the variant, stage before and after executing a program in the variant's deployments install environment post_build after building in the variant, and delete when the variant is deleted.
val direct_preset : direct -> B0.Conf.Preset.t option
direct_preset d is d's direct preset.
val direct_env : direct -> unit -> B0.Env.t B0.result
direct_env d is d's build environment setup function.

Proxy schemes


type proxy_conf 
The type for proxy configuration.
val proxy_conf : root_dir:B0.Fpath.t ->
b0_dir:B0.Fpath.t ->
variant_dir:B0.Fpath.t -> unit -> proxy_conf
val proxy_conf_root_dir : proxy_conf -> B0.Fpath.t
val proxy_conf_b0_dir : proxy_conf -> B0.Fpath.t
val proxy_conf_variant_dir : proxy_conf -> B0.Fpath.t
type proxy 
The type for proxy variant schemes. These schemes forward the build command to a variant scheme in another context.
val proxy : ?create:(proxy_conf -> unit B0.result) ->
?setup:(proxy_conf -> unit B0.result) ->
?delete:(proxy_conf -> unit B0.result) ->
run:(proxy_conf -> B0.Cmd.t -> B0.OS.Cmd.status B0.result) ->
t -> proxy
proxy ?create ?setup ?delete run scheme is a proxy scheme variant using run to proxy the given build program command to build with variant scheme.

TODO semantics of setup should be to put in a workable state if it's not. Basically this should do whathever happens in create assuming it failed or a condition changed. In general run should check conditions an invoke run if it's not satisfied.

val proxy_run : proxy ->
proxy_conf -> B0.Cmd.t -> B0.OS.Cmd.status B0.result
proxy_run p cmd is the exit status of the run of the build command cmd via the proxy p.
val proxy_create : proxy -> proxy_conf -> unit B0.result
val proxy_delete : proxy -> proxy_conf -> unit B0.result
val proxy_setup : proxy -> proxy_conf -> unit B0.result

Schemes


type kind = [ `Direct of direct | `Proxy of proxy ] 
The kind of variant scheme.
val v : ?loc:B0.Def.loc ->
?doc:string -> string -> kind -> t
v ?src ?doc name kind is the variant scheme named name with kind kind.

Warning. Schemes need to be defined at toplevel and are subject to namespacing, see details.

val kind : t -> kind
kind s is s's scheme kind.
val nop : t
The nop scheme. The nop scheme does nothing, it is a nop on all amost every acccounts. It runs builds in the environment in which the b0 tool itself is run.
val with_preset : ?loc:B0.Def.loc ->
?doc:string ->
t ->
B0.Conf.Preset.t option -> string -> t
with_preset s preset n is the scheme s but with name n and preset preset.
Raises Invalid_argument on proxy presets.
val wrap : t -> t -> string -> t
wrap snd fst n is a scheme named n that behaviourly performs the functional composition snd o fst.
include B0.Def.S

Proxy schemes

Proxy schemes can build in containers or on virtual or remote machines. Exactly how this is performed depends on the scheme but in general an proxy scheme n tries to:

  1. Mount or sync the description root directory on a different machine.
  2. Run the build there using the direct build variant n and the local directory _b0/v/n/proxy as the build directory.
  3. Mount or sync the resulting direct variant directory to the _b0/v/n directory.