package b0

  1. Overview
  2. Docs

Build operations.

This module only provides a type for specifying operations and the result of their execution. No execution or caching logic lives here.

Operations kinds

module Spawn : sig ... end

Tool spawns.

module Read : sig ... end

File reads.

module Write : sig ... end

File writes.

module Mkdir : sig ... end

Directory creation.

type kind =
  1. | Spawn of Spawn.t
  2. | Read of Read.t
  3. | Write of Write.t
  4. | Mkdir of Mkdir.t
  5. | Wait_files

The type for operation kinds.

val kind_name : kind -> string

kind_name k is a end user name for kind k.

Operation status

type status =
  1. | Waiting
    (*

    Waiting for execution.

    *)
  2. | Executed
    (*

    Executed successfully.

    *)
  3. | Cached
    (*

    Revived from the cache.

    *)
  4. | Failed
    (*

    Executed unsucessfully.

    *)
  5. | Aborted
    (*

    A prerequisite operation failed.

    *)

The type for operation statuses.

val pp_status : status B0_std.Fmt.t

pp_status formats execution status.

Operations

type id = int

The type for build operation identifiers.

type t

The type for build operations.

val id : t -> id

id o is the identifier of operation o.

val creation_time : t -> B0_std.Time.span

creation_time o is o's creation time.

val exec_start_time : t -> B0_std.Time.span

exec_start_time o is o's execution start time. This is different from B0_std.Time.Span.zero once the operation has been submitted to the OS for execution.

val exec_end_time : t -> B0_std.Time.span

exec_end_time o is o's execution end time. This is different from B0_std.Time.Span.zero once the operation has been completed by the OS and collected.

val exec_duration : t -> B0_std.Time.span

exec_duration is the difference between exec_end_time and exec_start_time.

val status : t -> status

status o is o execution status.

val reads : t -> B0_std.Fpath.t list

reads o are the file paths read by the operation.

val writes : t -> B0_std.Fpath.t list

writes o are the file paths written by o.

val did_not_write : t -> B0_std.Fpath.t list

did_not_write o are the file of writes that do not exist or are not readable.

val hash : t -> B0_std.Hash.t

hash o is the operation's hash. This is Hash.nil before the operation hash has been effectively computed and set via set_hash.

val kind : t -> kind

kind o is o's kind.

val get_spawn : t -> Spawn.t

get_spawn o is the spawn o.

val get_read : t -> Read.t

get_read o is the read o.

val get_write : t -> Write.t

get_write o is the write o.

val get_mkdir : t -> Mkdir.t

get_mkdir o is the mkdir o.

val equal : t -> t -> bool

equal o0 o1 is id o0 = id o1.

val compare : t -> t -> int

compare o0 o1 is Pervasives.compare (id o0) (id o1).

Formatters

val pp : t B0_std.Fmt.t

pp formats a build operation.

val pp_short : t B0_std.Fmt.t

pp_short formats a build operation on a single line.

val pp_did_not_write : (t * B0_std.Fpath.t list) B0_std.Fmt.t

pp_did_not_write formats a build operation and the files it failed to write.

val pp_spawn_status_fail : t B0_std.Fmt.t

pp_spawn_status_fail formats a spawn operation failure due to exit result.

Updating the build operation

val set_exec_start_time : t -> B0_std.Time.span -> unit

exec_start_time o t sets o's execution start time to t.

val set_exec_end_time : t -> B0_std.Time.span -> unit

set_exec_end_time o t sets o's execution end time to s.

val set_status : t -> status -> unit

set_status o s sets the execution status to s.

val set_reads : t -> B0_std.Fpath.t list -> unit

set_reads t fs sets the file paths read by o to fs. Note that this resets the hash.

val set_writes : t -> B0_std.Fpath.t list -> unit

set_writes t fs sets the file paths written by o to fs.

val set_hash : t -> B0_std.Hash.t -> unit

set_hash o h sets the operation hash to h.

Operation contructors

val spawn : id:id -> B0_std.Time.span -> reads:B0_std.Fpath.t list -> writes:B0_std.Fpath.t list -> env:B0_std.Os.Env.assignments -> relevant_env:B0_std.Os.Env.assignments -> cwd:B0_std.Fpath.t -> stdin:B0_std.Fpath.t option -> stdout:Spawn.stdo -> stderr:Spawn.stdo -> success_exits:Spawn.success_exits -> B0_std.Cmd.tool -> B0_std.Cmd.t -> t

spawn declares a spawn build operation, see the corresponding accessors in Spawn for the semantics of the various fields.

val read : id:id -> B0_std.Time.span -> B0_std.Fpath.t -> t

read declares a file read operation, see the corresponding accessors in Read for the semantics of the various fields.

val write : id:id -> B0_std.Time.span -> salt:string -> reads:B0_std.Fpath.t list -> mode:int -> write:B0_std.Fpath.t -> (unit -> (string, string) result) -> t

write declares a file write operations, see the corresponding accessors in Write for the semantics of the various fields.

val mkdir : id:id -> B0_std.Time.span -> B0_std.Fpath.t -> t

mkdir declares a directory creation operation, see the corresponding accessors for the semantics of the various fields.

val wait_files : id:id -> B0_std.Time.span -> B0_std.Fpath.t list -> t

wait_files declares a wait files operation, these are stored in reads.

Operation sets and map

module Set : Set.S with type elt := t

Operation sets

module Map : Map.S with type key := t

Operation maps