Module B0_env

Execution environments.

This is notably what actions get access to.

Note. At some point we need a build/host distinction here.

type t

The type for execution environments.

val make : b0_dir:B0_std.Fpath.t -> build:B0_build.t -> cwd:B0_std.Fpath.t -> root_dir:B0_std.Fpath.t -> scope_dir:B0_std.Fpath.t -> t

make ~cwd ~scope_dir ~root_dir ~action is an execution context with given parameters. See corresponding accessors for semantics.


See also the relative file resolutions.

val b0_dir : t -> B0_std.Fpath.t

b0_dir env is the b0 directory.

val cwd : t -> B0_std.Fpath.t

cwd env is the absolute path to the current working directory.

val root_dir : t -> B0_std.Fpath.t

root_dir env is the root directory.

val scope_dir : t -> B0_std.Fpath.t

scope_dir env is the absolute path to the directory of the B0 file in which the action is defined or the root directory if the action is defined the global scope.

val scratch_dir : t -> B0_std.Fpath.t

scratch_dir env is a shared scratch directory for actions in b0_dir. The directory must be created it may not exist, it's content may be destroyed at any time and actions are in charge of inventing a naming scheme to avoid collisions.

val unit_dir : t -> B0_unit.t -> B0_std.Fpath.t

unit_dir env u is the build directory if u in the build build env. That is B0_build.build_dir (build env) u.

Relative file resolution

val in_root_dir : t -> B0_std.Fpath.t -> B0_std.Fpath.t

in_scope_dir env p is Fpath.(root_dir env // p).

val in_scope_dir : t -> B0_std.Fpath.t -> B0_std.Fpath.t

in_scope_dir env p is Fpath.(scope_dir env // p).

val in_scratch_dir : t -> B0_std.Fpath.t -> B0_std.Fpath.t

in_scope_dir env p is Fpath.(scratch_dir env // p).

val in_unit_dir : t -> B0_unit.t -> B0_std.Fpath.t -> B0_std.Fpath.t

in_unit_dir env u p is Fpath.(unit_build_dir env // p).


val build : t -> B0_build.t

build env is the current build (if any).

Tool lookup

val get_tool : ?no_build:bool -> t -> B0_std.Fpath.t -> (B0_std.Fpath.t, string) Stdlib.result
val get_cmd : ?no_build:bool -> t -> B0_std.Cmd.t -> (B0_std.Cmd.t, string) Stdlib.result
val unit_file_exe : t -> B0_unit.t -> (B0_std.Fpath.t, string) Stdlib.result
val unit_cmd : t -> B0_unit.t -> (B0_std.Cmd.t, string) Stdlib.result