Module Op.Spawn

Tool spawns.

Tool spawns

type stdo = [
| `Ui
| `File of B00_std.Fpath.t
| `Tee of B00_std.Fpath.t
]

The type for spawn standard outputs redirections.

  • `Ui redirects the output to the user interface of the build system (usually only shown in case of failure). Outputs are always first redirected to a file and read back by the program running the build on completion, this means that in the spawn program isatty(3) will be false on the fds.
  • `File p redirect the output to file path p.
  • `Tee p, is both `Ui and File `f.
type success_exits = int list

The list of process exit codes that indicate success. If the list is empty this any exit code.

type t

The type for process spawn operations.

val v_op : id:id -> mark:mark -> created:B00_std.Time.span -> reads:B00_std.Fpath.t list -> writes:B00_std.Fpath.t list -> ?writes_manifest_root:B00_std.Fpath.t -> ?post_exec:(op -> unit) -> ?k:(op -> unit) -> stamp:string -> env:B00_std.Os.Env.assignments -> stamped_env:B00_std.Os.Env.assignments -> cwd:B00_std.Fpath.t -> stdin:B00_std.Fpath.t option -> stdout:stdo -> stderr:stdo -> success_exits:success_exits -> B00_std.Cmd.tool -> B00_std.Cmd.t -> op

v_op declares a spawn build operation, see the corresponding accessors for the semantics of the various arguments.

val v : env:B00_std.Os.Env.assignments -> stamped_env:B00_std.Os.Env.assignments -> cwd:B00_std.Fpath.t -> stdin:B00_std.Fpath.t option -> stdout:stdo -> stderr:stdo -> success_exits:success_exits -> B00_std.Cmd.tool -> B00_std.Cmd.t -> stamp:string -> stdo_ui:(string, string) result option -> exit:B00_std.Os.Cmd.status option -> t

v constructs a bare spawn operation.

val get : op -> t

get o is the spawn o. Raises Invalid_argument if o is not a spawn.

env s is the environment in which s runs.

val stamped_env : t -> B00_std.Os.Env.assignments

stamped_env s are the assignements of env s that may influence the tool outputs.

val cwd : t -> B00_std.Fpath.t

cwd s is the cwd with which s runs.

val stdin : t -> B00_std.Fpath.t option

stdin s is the file s uses as stdin (if any).

val stdout : t -> stdo

stdout s is the redirection s uses for stdout.

val stderr : t -> stdo

stderr s is the redirection s uses for stderr.

val success_exits : t -> success_exits

success_exits s is the list of process exit codes s that indicate success.

val tool : t -> B00_std.Cmd.tool

tool t is the spawned tool. Note that this has to be a full path at that point.

val args : t -> B00_std.Cmd.t

args s are the spawned tool arguments.

val stamp : t -> string

stamp s is a stamp that is used for caching. Two spans operations all otherwise equal but differing only in their stamp must not cache to the same key.

val set_stamp : t -> string -> unit

set_stamp s st sets the stamp of s to st. See stamp.

val stdo_ui : t -> (string, string) result option

stdo_ui sr is the standard outputs redirection contents of s once it has executed (if any).

val set_stdo_ui : t -> (string, string) result option -> unit

set_stdo_ui w ui sets w's standard output redirection contents to ui.

val exit : t -> B00_std.Os.Cmd.status option

exit s is the spawn exit status of s.

val set_exit : t -> B00_std.Os.Cmd.status option -> unit

set_exit s e the spawn exit status of s to e.

val exit_to_status : t -> status

exit_to_status s assumes s has been executed and determines an operation status according to exit and success_exits.