B0_unit.Exec
Unit executions.
These properties pertain to the interface that allows to execute units after they have been built as is done for example by the b0
command.
The execution procedure, will likely be refined when we get proper build environments and cross but basically:
Exec.get_env
and Exec.get_cwd
. Additional cli arguments may be provided by the driver.Exec.key
if present or by B0_unit.exe_file
type b0_unit := t
type env = [
| `Build_env
The build environment.
*)| `Driver_env
The b0 invocation process environment.
*)| `Override of [ `Build_env | `Driver_env ] * B0_std.Os.Env.t
Environment overriden by given values.
*)| `Env of B0_std.Os.Env.t
This exact environment.
*)| `Fun of string * (b0_env -> b0_unit -> (B0_std.Os.Env.t, string) Stdlib.result)
Doc string and function.
*) ]
The type for execution environments.
val env : env B0_meta.key
env
specifies the environement for executing a unit. If unspecified this is `Build_env
.
val get_env : b0_env -> b0_unit -> (B0_std.Os.Env.t, string) Stdlib.result
get_env env u
performs the logic to get the execution environment env
for unit u
in environment env
.
type cwd = [
| `Cwd
The user's current working directory.
*)| `Root_dir
The root B0 file directory.
*)| `Scope_dir
The directory of the scope where the entity is defined.
*)| `Unit_dir
The unit's build directory.
*)| `In of [ `Cwd | `Unit_dir | `Root_dir | `Scope_dir ] * B0_std.Fpath.t
| `Fun of
string * (b0_env -> b0_unit -> (B0_std.Fpath.t, string) B0_std.Result.t)
Doc string and function.
*) ]
The type for execution working directories.
val cwd : cwd B0_meta.key
cwd
specifies the current working directory for executing a unit. If unspecified this is `Cwd
.
val get_cwd : b0_env -> b0_unit -> (B0_std.Fpath.t, string) Stdlib.result
get_cwd env u
performs the logic to get the cwd cwd
for unit u
in environment env
.
type t = [
| `Unit_exe
| `Cmd of
string
* (b0_env ->
b0_unit ->
args:B0_std.Cmd.t ->
(B0_std.Cmd.t, string) Stdlib.result)
| `Fun of
string
* (b0_env ->
?env:B0_std.Os.Env.assignments ->
?cwd:B0_std.Fpath.t ->
b0_unit ->
args:B0_std.Cmd.t ->
(B0_std.Os.Exit.t, string) Stdlib.result)
]
The type for specifying unit executions.
val key : t B0_meta.key
key
specifies the execution for a unit. If unspecified this is `Unit_exe
.
val find :
b0_unit ->
(b0_env ->
b0_unit ->
args:B0_std.Cmd.t ->
(B0_std.Os.Exit.t, string) Stdlib.result)
option
find u
is a function, if any, for executing unit u
according to key
. Given the environment, the unit and additional arguments potentially provided by the driver it performs the full execution logic.