B000.OpSourceBuild operations.
This module provides a type for specifying operations and their result. Operation execution and caching are respectively handled by the Exec and Reviver modules.
type failure = | Exec of string optionExecution failure with a potential error msg.
*)| Missing_writes of B0_std.Fpath.t listWrite specification failure.
*)| Missing_reads of B0_std.Fpath.t listRead synchronisation failure.
*)The type for operation failures.
type status = | AbortedAborted due to prerequisite failure.
*)| DoneExecuted successfully.
*)| Failed of failureExecuted unsuccessfully.
*)| WaitingWaiting for execution.
*)The type for operation statuses.
The type for build operation identifiers.
The type for build operation marks. Marks have no special semantics they are just used to label operations for UI purposes.
The type for build operations.
Waiting on files.
The type for operation kinds.
val v :
id ->
mark:mark ->
time_created:B0_std.Mtime.span ->
time_started:B0_std.Mtime.span ->
duration:B0_std.Mtime.span ->
revived:bool ->
status:status ->
reads:B0_std.Fpath.t list ->
writes:B0_std.Fpath.t list ->
writes_manifest_root:B0_std.Fpath.t option ->
hash:B0_std.Hash.t ->
?post_exec:(op -> unit) ->
?k:(op -> unit) ->
kind ->
tv constructs an operation. See the corresponding accessors for the semantics of various arguments.
time_created o is o's creation time.
time_started o is o's execution start time. This is different from B0_std.Mtime.Span.max_span once the operation has been submitted for execution.
time_ended o is o's execution end time. This is different from B0_std.Mtime.Span.max_span once the operation has been completed and collected.
waited is o's waiting time between creation and execution.
duration is o's execution duration time.
revived o is true iff o was revived from a cache. Only relevant if hash is not B0_std.Hash.nil.
reads o are the file paths read by the operation.
writes o are the file paths written by o.
writes_manifest_root o if Some root, the operation is cached using a manifest key. This means the writes made relative to root are stored along-side the cache key.
hash o is the operation's hash. This is B0_std.Hash.nil before the operation hash has been effectively computed and set via set_hash. This remains B0_std.Hash.nil for operations that are not revivable.
exec_k o () invokes and discards o's continuation. Note that this does not protect against the continuation raising.
exec_post_exec o invokes and discards o's post execution hook. This hook called is right after the operation execution and, if applicable, before reviver recording. It is always called even if the operation fails or is revived (use status and revived to check these conditions). Note that if the hook unexpectedly raises this turns o in to a failure.
abort o sets the status of o to Op.status.Aborted and discards the operation closures (including kind specific ones).
set_time_started o t sets o's execution start time to t.
set_time_ended o t sets o's execution end time to s.
set_status_from_result o r sets status of operation o to Executed if r is Ok _ and Failed (Exec e) if r is Error e.
set_reads t fs sets the file paths read by o to fs. Note that this resets the hash.
set_writes t fs sets the file paths written by o to fs.
set_writes_manifest_root t r sets the writes manifest root to r.
set_hash o h sets the operation hash to h.
did_not_write o compares writes with the current state of the file system and reports those files that do not exist.
cannot_read o compares reads with the current state of the file system and reports those files that cannot be read.
unready_reads os are the file read by os that are not written by those and not in ready_roots.
read_write_maps ops is reads, writes with reads mapping file paths to operations that reads them and writes mapping file paths to operations that write them.
write_map os is snd (read_write_maps os). If one of the operation sets in the map is not a singleton the operations should likely not be run toghether.
find_read_write_cycle os is Some cs if there exists a read/write cycle among the operations os. This means each each element of cs writes a file read by its successor in the list with the successor of the last element being the first.
type aggregate_error = | FailuresSome operations failed.
*)| Cycle of t listDependency cycle.
*)| Never_became_ready of B0_std.Fpath.Set.tSome files never became ready.
*)The type for errors related to a list of operations. This is:
Failures, if there is one or more operations in the list that Failed.Cycle ops, if there is a set of Waiting operations in the list whose individual reads and writes leads to a dependency cycle. See also find_read_write_cycle.Never_became_ready fs, with fs files that are in the reads of Waiting operations but are written by no operation from the list and were not made ready.Note that formally more than one of these conditions can be true at the same time. But Never_became_ready is only reported once the first two kind of errors have been ruled out. The reason is that those files that never became ready may be created by continuations of the failed or cyclic operations and reporting them would not lead the user to focus on the right cause.
val find_aggregate_error :
ready_roots:B0_std.Fpath.Set.t ->
t list ->
(unit, aggregate_error) resultfind_aggregate_error ~ready_roots os finds an aggregate error among the list of operation os, assuming files ready_roots were made ready. This is Ok () if all operations os B000.Op.status.Done.