Yocaml.ActionSourceActions consume Pipeline to produce artifacts. This is the entry point for a construction rule. In general, a chain of actions maitizes a cache and is used in this way:
let open Eff.Infix in
restore_cache ~on path_of_cache
>>= action_a
>>= action_b
>>= action_c
>>= store_cache ~on path_of_cacheAs it is necessary to maintain the cache during the various artifact production phases, an action is a function that takes a cache and returns the modified cache, wrapped in an effect.
restore_cache ?on path Reads or initiates the cache in a given path.
store_cache ?on path cache saves the cache in a given path.
with_cache ?on path f restores the cache from the given path, executes the action f using the cache, and then stores the updated cache back to the same path.
This helps avoid repeating restore_cache and store_cache calls manually when chaining multiple cache-aware actions.
write_dynamic_file target task cache Writes target file with content generated by task if necessary. Returns the modified cache once the action has been performed.
The task passed as an argument returns the contents of the file to be built and the dynamic dependencies produced by the task (which will be cached).
write_static_file target task cache is exactly write_dynamic_file target task cache but the action assume that no dynamic dependencies are involved in the task. It is like using t ||> no_dynamic_deps at the end of the task pipeline.
exec_cmd ?is_success cmd target produces a target performing cmd target (the argument of the given callback, cmd is prefilled with the target as a not watched path). When is_success is provided, it is called with the exit code to determine whether it indicates success or failure. Without is_success, success requires the process to return an exit code of 0.
val perform :
Path.t ->
('a, 'b) Task.t ->
when_creation:(int -> Path.t -> ('a -> 'b Eff.t) -> t) ->
when_update:(int -> Path.t -> ('a -> 'b Eff.t) -> t) ->
tperform target task ~when_creation ~when_update cache is a generic task performer. (It executes when_creation if the target has to be created, and need_update if the target must be updated).
copy_file ?new_name ~into:target source cache Copies the source file to the target directory (potentially giving it a new name), taking account of dependencies. The copy is obviously static.
copy_directory ?new_name ~into:target source cache Copies recursively the source file to the target directory (potentially giving it a new name), taking account of dependencies. The copy is obviously static.
Warning The use of this action is relatively optimistic. If only one child has been modified, the entire copy will be replayed.
val batch :
?only:[ `Files | `Directories | `Both ] ->
?where:(Path.t -> bool) ->
Path.t ->
(Path.t -> t) ->
tbatch ?only ?where path action cache Executes the given action on all child files of the given path. The cache is passed from call to call.
val fold :
?only:[ `Files | `Directories | `Both ] ->
?where:(Path.t -> bool) ->
state:'a ->
Path.t ->
(Path.t -> 'a -> Cache.t -> (Cache.t * 'a) Eff.t) ->
Cache.t ->
(Cache.t * 'a) Eff.tfold ?only ?where ~state path action cache Executes the given action on all child files of the given path. The cache is passed from call to call and instead of batch, you can maintain your own additional state.
batch_list list action cache Executes the given action on all element of the given list. The cache is passed from call to call.
val fold_list :
state:'a ->
'b list ->
('b -> 'a -> Cache.t -> (Cache.t * 'a) Eff.t) ->
Cache.t ->
(Cache.t * 'a) Eff.tfold_list ~state list action cache Executes the given action on all element of the given list. The cache is passed from call to call and instead of batch_list, you can maintain your own additional state.
The API can change considerably when processing tasks with or without dynamic dependencies, so we are exposing two modules to simplify this processing.