B0_unitBuild units.
A unit is a named build procedure and an optional action to perform once the unit has built. Units are the smallest unit of build in b0 files.
Either of the build procedure or the action can be a nop. Actions can also require a bit more than the unit itself from the build in order to run.
type build_proc = B0_build.t -> unit B0_std.Fut.tThe type for unit build procedures. Note that when the future determines the build may not be finished.
val build_nop : build_procbuild_nop does nothing.
val make : ?doc:string -> ?meta:B0_meta.t -> string -> build_proc -> tmake n proc ~doc ~meta ~action is a build unit named n with build procedure proc, synopsis doc and metada meta.
val build_proc : t -> build_procproc u are the unit's build procedure.
val tool_name : string B0_meta.keytool_name is an executable name without the platform specific executable extension.
val exe_file : B0_std.Fpath.t B0_std.Fut.t B0_meta.keyexe_file is an absolute file path to an executable build by the unit.
val outcomes : B0_std.Fpath.t list B0_std.Bval.t B0_meta.keyoutcomes is the set of public file outcomes.
val copy_outcomes_to_dir : B0_memo.t -> t -> dst_dir:B0_std.Fpath.t -> unitcopy_outcomes m u ~dst_dir copies the outcome of u to destination directory dst_dir.
val is_public : t -> boolis_public u is true iff u's meta has B0_meta.public set to true.
get_or_suggest_tool tool_name are tools names whose tool_name match tool_name and are filtered by keep
val tool_is_user_accessible : t -> booltool_is_user_accessible u assumes u has a tool name. This then returns true iff u is_public or in_root_scope.
module Action : sig ... endActions.
val is_actionable : t -> boolactionable u is true if u has an action that can be run. This checks that either u has an exe_file or a `Fun action.
These helper functions create units with a build_nop build procedure.
val of_action' :
?store:B0_store.binding list ->
?packs:B0_pack.t list ->
?units:t list ->
?dyn_units:(args:B0_std.Cmd.t -> t list) ->
?doc:string ->
?meta:B0_meta.t ->
string ->
Action.func ->
tof_action' name func is an action named name implemented with action function func. units and packs are units and packs that must be built to run the action. store are store bindings that must be enforced in the build.
val of_action :
?store:B0_store.binding list ->
?packs:B0_pack.t list ->
?units:t list ->
?dyn_units:(args:B0_std.Cmd.t -> t list) ->
?doc:string ->
?meta:B0_meta.t ->
string ->
(B0_env.t -> t -> args:B0_std.Cmd.t -> (unit, string) Stdlib.result) ->
tof_action is like of_action' but with a function func that evaluates to unit which are turned into Ok Os.Exit.ok.
Use B0_std_cli to parse actions arguments and Os.Exit for exit codes. Given a suitable Cmdliner term this function can be used to implement the action's command.
TODO Add a quick getopt interface.
val of_cmdliner_cmd :
?store:B0_store.binding list ->
?packs:B0_pack.t list ->
?units:t list ->
?dyn_units:(args:B0_std.Cmd.t -> t list) ->
?doc:string ->
?meta:B0_meta.t ->
string ->
(B0_env.t -> t -> B0_std.Os.Exit.t Cmdliner.Cmd.t) ->
tof_cmdliner_cmd name cmd is like of_action is an action from the Cmdliner command cmd. See also Action.of_cmdliner_term.
Note. The command is under a thunk to avoid toplevel inits. This entails a bit of repetition for name and doc but you can access those of the action in the thunk to define the cmdliner command.
include B0_def.S with type t := t with type Set.t = B0_defs.Unit.Set.tval define : ?doc:string -> ?meta:B0_meta.t -> string -> B0_def.defval def : t -> B0_def.defval name : t -> stringval basename : t -> stringval doc : t -> stringval mem_meta : 'a B0_meta.key -> t -> boolval has_tag : bool B0_meta.key -> t -> boolval find_meta : 'a B0_meta.key -> t -> 'a optionval find_or_default_meta : 'a B0_meta.key -> t -> 'aval get_meta : 'a B0_meta.key -> t -> ('a, string) Stdlib.resultval add : t -> unitval fold : (t -> 'a -> 'a) -> 'a -> 'aval list : unit -> t listval find : string -> t optionval get : string -> tval get_or_hint : string -> (t, string) Stdlib.resultval get_list_or_hint :
all_if_empty:bool ->
string list ->
(t list, string) Stdlib.resultval scope_path : t -> string listval in_root_scope : t -> boolval in_current_scope : t -> boolval scope_dir : t -> B0_std.Fpath.t optionval scope_dir' : t -> (B0_std.Fpath.t, string) Stdlib.resultval in_scope_dir : t -> B0_std.Fpath.t -> B0_std.Fpath.t optionval in_scope_dir' :
t ->
B0_std.Fpath.t ->
(B0_std.Fpath.t, string) Stdlib.resultval pp_name_str : string B0_std.Fmt.tval pp_name : t B0_std.Fmt.tval pp_doc : t B0_std.Fmt.tval pp_synopsis : t B0_std.Fmt.tval pp : t B0_std.Fmt.tmodule Set : sig ... endmodule Map : sig ... endval tool_name_map : Set.t -> t B0_std.String.Map.ttool_name_map units are the user accessible tools defined by the set of units units.