2016-12-15 11:20:46 +00:00
|
|
|
(** The build arrow *)
|
|
|
|
|
|
|
|
open! Import
|
|
|
|
|
|
|
|
type ('a, 'b) t
|
|
|
|
|
|
|
|
val arr : ('a -> 'b) -> ('a, 'b) t
|
|
|
|
|
|
|
|
val return : 'a -> (unit, 'a) t
|
|
|
|
|
2017-05-15 13:46:23 +00:00
|
|
|
module Vspec : sig
|
|
|
|
type 'a t = T : Path.t * 'a Vfile_kind.t -> 'a t
|
|
|
|
end
|
|
|
|
|
|
|
|
val store_vfile : 'a Vspec.t -> ('a, Action.t) t
|
|
|
|
|
2016-12-15 11:20:46 +00:00
|
|
|
module O : sig
|
|
|
|
val ( >>> ) : ('a, 'b) t -> ('b, 'c) t -> ('a, 'c) t
|
|
|
|
val ( ^>> ) : ('a -> 'b) -> ('b, 'c) t -> ('a, 'c) t
|
|
|
|
val ( >>^ ) : ('a, 'b) t -> ('b -> 'c) -> ('a, 'c) t
|
|
|
|
val ( *** ) : ('a, 'b) t -> ('c, 'd) t -> ('a * 'c, 'b * 'd) t
|
|
|
|
val ( &&& ) : ('a, 'b) t -> ('a, 'c) t -> ('a, 'b * 'c) t
|
|
|
|
end
|
|
|
|
|
|
|
|
val first : ('a, 'b) t -> ('a * 'c, 'b * 'c) t
|
|
|
|
val second : ('a, 'b) t -> ('c * 'a, 'c * 'b) t
|
|
|
|
|
|
|
|
(** Same as [O.(&&&)]. Sends the input to both argument arrows and combine their output.
|
|
|
|
|
|
|
|
The default definition may be overridden with a more efficient version if desired. *)
|
|
|
|
val fanout : ('a, 'b) t -> ('a, 'c) t -> ('a, 'b * 'c) t
|
|
|
|
val fanout3 : ('a, 'b) t -> ('a, 'c) t -> ('a, 'd) t -> ('a, 'b * 'c * 'd) t
|
2017-07-05 20:11:33 +00:00
|
|
|
val fanout4 : ('a, 'b) t -> ('a, 'c) t -> ('a, 'd) t -> ('a, 'e) t -> ('a, 'b * 'c * 'd * 'e) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
|
|
|
val all : ('a, 'b) t list -> ('a, 'b list) t
|
|
|
|
|
|
|
|
val path : Path.t -> ('a, 'a) t
|
|
|
|
val paths : Path.t list -> ('a, 'a) t
|
|
|
|
val path_set : Path.Set.t -> ('a, 'a) t
|
2018-01-15 13:28:32 +00:00
|
|
|
val paths_glob : loc:Loc.t -> dir:Path.t -> Re.re -> ('a, Path.t list) t
|
2017-05-29 17:53:54 +00:00
|
|
|
val files_recursively_in : dir:Path.t -> file_tree:File_tree.t -> ('a, Path.Set.t) t
|
2017-05-15 13:46:23 +00:00
|
|
|
val vpath : 'a Vspec.t -> (unit, 'a) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
|
|
|
val dyn_paths : ('a, Path.t list) t -> ('a, 'a) t
|
|
|
|
|
2017-11-09 12:41:52 +00:00
|
|
|
(** [contents path] returns an arrow that when run will return the contents of
|
|
|
|
the file at [path]. *)
|
2017-03-05 12:04:19 +00:00
|
|
|
val contents : Path.t -> ('a, string) t
|
2017-11-09 12:41:52 +00:00
|
|
|
|
|
|
|
(** [lines_of path] returns an arrow that when run will return the contents of
|
|
|
|
the file at [path] as a list of lines. *)
|
2017-03-05 12:04:19 +00:00
|
|
|
val lines_of : Path.t -> ('a, string list) t
|
|
|
|
|
2017-11-09 12:41:52 +00:00
|
|
|
(** [strings path] is like [lines_of path] except each line is unescaped using
|
|
|
|
the OCaml conventions. *)
|
2017-05-30 14:40:06 +00:00
|
|
|
val strings : Path.t -> ('a, string list) t
|
|
|
|
|
2017-05-16 11:19:18 +00:00
|
|
|
(** Load an S-expression from a file *)
|
|
|
|
val read_sexp : Path.t -> (unit, Sexp.Ast.t) t
|
|
|
|
|
2017-05-12 14:05:07 +00:00
|
|
|
(** Evaluates to [true] if the file is present on the file system or is the target of a
|
|
|
|
rule. *)
|
|
|
|
val file_exists : Path.t -> ('a, bool) t
|
|
|
|
|
|
|
|
(** [if_file_exists p ~then ~else] is an arrow that behaves like [then_] if [file_exists
|
|
|
|
p] evaluates to [true], and [else_] otherwise. *)
|
|
|
|
val if_file_exists : Path.t -> then_:('a, 'b) t -> else_:('a, 'b) t -> ('a, 'b) t
|
|
|
|
|
|
|
|
(** [file_exists_opt p t] is:
|
|
|
|
|
|
|
|
{[
|
|
|
|
if_file_exists p ~then_:(t >>^ fun x -> Some x) ~else_:(arr (fun _ -> None))
|
|
|
|
]}
|
|
|
|
*)
|
|
|
|
val file_exists_opt : Path.t -> ('a, 'b) t -> ('a, 'b option) t
|
|
|
|
|
2017-01-25 15:41:22 +00:00
|
|
|
(** Always fail when executed. We pass a function rather than an exception to get a proper
|
|
|
|
backtrace *)
|
2017-05-15 13:46:23 +00:00
|
|
|
val fail : ?targets:Path.t list -> fail -> (_, _) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
2017-05-15 13:46:23 +00:00
|
|
|
(** [memoize name t] is an arrow that behaves like [t] except that its
|
2017-05-14 07:18:03 +00:00
|
|
|
result is computed only once. *)
|
2017-05-15 13:46:23 +00:00
|
|
|
val memoize : string -> (unit, 'a) t -> (unit, 'a) t
|
2017-05-14 07:18:03 +00:00
|
|
|
|
2016-12-15 11:20:46 +00:00
|
|
|
val run
|
2017-04-28 10:58:41 +00:00
|
|
|
: context:Context.t
|
2017-05-27 23:48:48 +00:00
|
|
|
-> ?dir:Path.t (* default: [context.build_dir] *)
|
2016-12-15 11:20:46 +00:00
|
|
|
-> ?stdout_to:Path.t
|
2017-05-15 13:46:23 +00:00
|
|
|
-> ?extra_targets:Path.t list
|
2017-11-07 13:42:55 +00:00
|
|
|
-> Action.Prog.t
|
2016-12-15 11:20:46 +00:00
|
|
|
-> 'a Arg_spec.t list
|
2017-03-03 11:49:40 +00:00
|
|
|
-> ('a, Action.t) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
2017-03-03 08:57:20 +00:00
|
|
|
val action
|
2017-05-27 23:48:48 +00:00
|
|
|
: ?dir:Path.t
|
2017-05-15 13:46:23 +00:00
|
|
|
-> targets:Path.t list
|
2017-05-27 23:48:48 +00:00
|
|
|
-> Action.t
|
|
|
|
-> (_, Action.t) t
|
2017-04-28 10:58:41 +00:00
|
|
|
|
2017-05-05 11:26:56 +00:00
|
|
|
val action_dyn
|
2017-05-27 23:48:48 +00:00
|
|
|
: ?dir:Path.t
|
2017-05-15 13:46:23 +00:00
|
|
|
-> targets:Path.t list
|
2017-05-05 11:26:56 +00:00
|
|
|
-> unit
|
2017-05-27 23:48:48 +00:00
|
|
|
-> (Action.t, Action.t) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
2017-08-17 13:03:11 +00:00
|
|
|
(** Create a file with the given contents. *)
|
|
|
|
val write_file : Path.t -> string -> (unit, Action.t) t
|
|
|
|
val write_file_dyn : Path.t -> (string, Action.t) t
|
2017-03-03 11:49:40 +00:00
|
|
|
|
|
|
|
val copy : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
2017-05-17 07:33:09 +00:00
|
|
|
val copy_and_add_line_directive : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
2017-03-03 11:49:40 +00:00
|
|
|
val symlink : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
2016-12-15 11:20:46 +00:00
|
|
|
|
2017-05-25 15:57:29 +00:00
|
|
|
val create_file : Path.t -> (_, Action.t) t
|
2017-05-26 17:08:07 +00:00
|
|
|
val remove_tree : Path.t -> (_, Action.t) t
|
2017-05-29 13:51:46 +00:00
|
|
|
val mkdir : Path.t -> (_, Action.t) t
|
2017-03-01 11:04:32 +00:00
|
|
|
|
2017-05-25 15:36:22 +00:00
|
|
|
(** Merge a list of actions *)
|
|
|
|
val progn : ('a, Action.t) t list -> ('a, Action.t) t
|
2017-02-21 17:13:30 +00:00
|
|
|
|
2016-12-15 13:00:30 +00:00
|
|
|
type lib_dep_kind =
|
|
|
|
| Optional
|
|
|
|
| Required
|
|
|
|
|
2017-01-25 15:41:22 +00:00
|
|
|
val record_lib_deps
|
|
|
|
: dir:Path.t
|
|
|
|
-> kind:lib_dep_kind
|
2017-06-02 13:32:05 +00:00
|
|
|
-> Jbuild.Lib_dep.t list
|
2017-01-25 15:41:22 +00:00
|
|
|
-> ('a, 'a) t
|
2016-12-15 13:00:30 +00:00
|
|
|
|
|
|
|
type lib_deps = lib_dep_kind String_map.t
|
|
|
|
|
2017-04-17 11:48:54 +00:00
|
|
|
val record_lib_deps_simple : dir:Path.t -> lib_deps -> ('a, 'a) t
|
|
|
|
|
2016-12-15 13:00:30 +00:00
|
|
|
(**/**)
|
|
|
|
|
2016-12-15 11:20:46 +00:00
|
|
|
|
|
|
|
module Repr : sig
|
|
|
|
type ('a, 'b) t =
|
|
|
|
| Arr : ('a -> 'b) -> ('a, 'b) t
|
2017-05-15 13:46:23 +00:00
|
|
|
| Targets : Path.t list -> ('a, 'a) t
|
|
|
|
| Store_vfile : 'a Vspec.t -> ('a, Action.t) t
|
2016-12-15 11:20:46 +00:00
|
|
|
| Compose : ('a, 'b) t * ('b, 'c) t -> ('a, 'c) t
|
|
|
|
| First : ('a, 'b) t -> ('a * 'c, 'b * 'c) t
|
|
|
|
| Second : ('a, 'b) t -> ('c * 'a, 'c * 'b) t
|
|
|
|
| Split : ('a, 'b) t * ('c, 'd) t -> ('a * 'c, 'b * 'd) t
|
|
|
|
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
|
|
|
| Paths : Path.Set.t -> ('a, 'a) t
|
2017-05-29 17:53:54 +00:00
|
|
|
| Paths_glob : glob_state ref -> ('a, Path.t list) t
|
2017-05-12 14:05:07 +00:00
|
|
|
| If_file_exists : Path.t * ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
2017-03-05 12:04:19 +00:00
|
|
|
| Contents : Path.t -> ('a, string) t
|
|
|
|
| Lines_of : Path.t -> ('a, string list) t
|
2017-05-15 13:46:23 +00:00
|
|
|
| Vpath : 'a Vspec.t -> (unit, 'a) t
|
2016-12-15 11:20:46 +00:00
|
|
|
| Dyn_paths : ('a, Path.t list) t -> ('a, 'a) t
|
2016-12-15 13:00:30 +00:00
|
|
|
| Record_lib_deps : Path.t * lib_deps -> ('a, 'a) t
|
2017-03-06 12:22:44 +00:00
|
|
|
| Fail : fail -> (_, _) t
|
2017-05-14 07:18:03 +00:00
|
|
|
| Memo : 'a memo -> (unit, 'a) t
|
|
|
|
|
|
|
|
and 'a memo =
|
|
|
|
{ name : string
|
|
|
|
; t : (unit, 'a) t
|
|
|
|
; mutable state : 'a memo_state
|
|
|
|
}
|
|
|
|
|
|
|
|
and 'a memo_state =
|
|
|
|
| Unevaluated
|
|
|
|
| Evaluating
|
2017-05-15 14:09:56 +00:00
|
|
|
| Evaluated of 'a * Path.Set.t (* dynamic dependencies *)
|
2017-05-12 14:05:07 +00:00
|
|
|
|
|
|
|
and ('a, 'b) if_file_exists_state =
|
|
|
|
| Undecided of ('a, 'b) t * ('a, 'b) t
|
|
|
|
| Decided of bool * ('a, 'b) t
|
|
|
|
|
2017-05-29 17:53:54 +00:00
|
|
|
and glob_state =
|
2018-01-15 13:28:32 +00:00
|
|
|
| G_unevaluated of Loc.t * Path.t * Re.re
|
2017-05-29 17:53:54 +00:00
|
|
|
| G_evaluated of Path.t list
|
|
|
|
|
2017-05-12 14:05:07 +00:00
|
|
|
val get_if_file_exists_exn : ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
2017-05-29 17:53:54 +00:00
|
|
|
val get_glob_result_exn : glob_state ref -> Path.t list
|
2016-12-15 11:20:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
val repr : ('a, 'b) t -> ('a, 'b) Repr.t
|
2016-12-15 13:00:30 +00:00
|
|
|
|
|
|
|
val merge_lib_deps : lib_deps -> lib_deps -> lib_deps
|