Change Paths_glob to return a set of paths
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
1860438605
commit
85e4b13780
|
@ -26,7 +26,7 @@ module Repr = struct
|
||||||
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
||||||
| Paths : Path.Set.t -> ('a, 'a) t
|
| Paths : Path.Set.t -> ('a, 'a) t
|
||||||
| Paths_for_rule : Path.Set.t -> ('a, 'a) t
|
| Paths_for_rule : Path.Set.t -> ('a, 'a) t
|
||||||
| Paths_glob : glob_state ref -> ('a, Path.t list) t
|
| Paths_glob : glob_state ref -> ('a, Path.Set.t) t
|
||||||
(* The reference gets decided in Build_interpret.deps *)
|
(* The reference gets decided in Build_interpret.deps *)
|
||||||
| If_file_exists : Path.t * ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
| If_file_exists : Path.t * ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
||||||
| Contents : Path.t -> ('a, string) t
|
| Contents : Path.t -> ('a, string) t
|
||||||
|
@ -55,7 +55,7 @@ module Repr = struct
|
||||||
|
|
||||||
and glob_state =
|
and glob_state =
|
||||||
| G_unevaluated of Loc.t * Path.t * Re.re
|
| G_unevaluated of Loc.t * Path.t * Re.re
|
||||||
| G_evaluated of Path.t list
|
| G_evaluated of Path.Set.t
|
||||||
|
|
||||||
let get_if_file_exists_exn state =
|
let get_if_file_exists_exn state =
|
||||||
match !state with
|
match !state with
|
||||||
|
|
|
@ -59,7 +59,7 @@ val path_set : Path.Set.t -> ('a, 'a) t
|
||||||
|
|
||||||
(** Evaluate a glob and record all the matched files as dependencies
|
(** Evaluate a glob and record all the matched files as dependencies
|
||||||
of the action produced by the build arrow. *)
|
of the action produced by the build arrow. *)
|
||||||
val paths_glob : loc:Loc.t -> dir:Path.t -> Re.re -> ('a, Path.t list) t
|
val paths_glob : loc:Loc.t -> dir:Path.t -> Re.re -> ('a, Path.Set.t) t
|
||||||
|
|
||||||
(* CR-someday diml: rename to [source_files_recursively_in] *)
|
(* CR-someday diml: rename to [source_files_recursively_in] *)
|
||||||
(** Compute the set of source of all files present in the sub-tree
|
(** Compute the set of source of all files present in the sub-tree
|
||||||
|
@ -193,7 +193,7 @@ module Repr : sig
|
||||||
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
||||||
| Paths : Path.Set.t -> ('a, 'a) t
|
| Paths : Path.Set.t -> ('a, 'a) t
|
||||||
| Paths_for_rule : Path.Set.t -> ('a, 'a) t
|
| Paths_for_rule : Path.Set.t -> ('a, 'a) t
|
||||||
| Paths_glob : glob_state ref -> ('a, Path.t list) t
|
| Paths_glob : glob_state ref -> ('a, Path.Set.t) t
|
||||||
| If_file_exists : Path.t * ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
| If_file_exists : Path.t * ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
||||||
| Contents : Path.t -> ('a, string) t
|
| Contents : Path.t -> ('a, string) t
|
||||||
| Lines_of : Path.t -> ('a, string list) t
|
| Lines_of : Path.t -> ('a, string list) t
|
||||||
|
@ -221,10 +221,10 @@ module Repr : sig
|
||||||
|
|
||||||
and glob_state =
|
and glob_state =
|
||||||
| G_unevaluated of Loc.t * Path.t * Re.re
|
| G_unevaluated of Loc.t * Path.t * Re.re
|
||||||
| G_evaluated of Path.t list
|
| G_evaluated of Path.Set.t
|
||||||
|
|
||||||
val get_if_file_exists_exn : ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
val get_if_file_exists_exn : ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
||||||
val get_glob_result_exn : glob_state ref -> Path.t list
|
val get_glob_result_exn : glob_state ref -> Path.Set.t
|
||||||
end
|
end
|
||||||
|
|
||||||
val repr : ('a, 'b) t -> ('a, 'b) Repr.t
|
val repr : ('a, 'b) t -> ('a, 'b) Repr.t
|
||||||
|
|
|
@ -66,7 +66,7 @@ let static_deps t ~all_targets ~file_tree =
|
||||||
| Paths_glob state -> begin
|
| Paths_glob state -> begin
|
||||||
match !state with
|
match !state with
|
||||||
| G_evaluated l ->
|
| G_evaluated l ->
|
||||||
{ acc with action_deps = Path.Set.union acc.action_deps (Path.Set.of_list l) }
|
{ acc with action_deps = Path.Set.union acc.action_deps l }
|
||||||
| G_unevaluated (loc, dir, re) ->
|
| G_unevaluated (loc, dir, re) ->
|
||||||
let targets = all_targets ~dir in
|
let targets = all_targets ~dir in
|
||||||
let result =
|
let result =
|
||||||
|
@ -87,7 +87,7 @@ let static_deps t ~all_targets ~file_tree =
|
||||||
(* diml: we should probably warn in this case as well *)
|
(* diml: we should probably warn in this case as well *)
|
||||||
()
|
()
|
||||||
end;
|
end;
|
||||||
state := G_evaluated (Path.Set.to_list result);
|
state := G_evaluated result;
|
||||||
let action_deps = Path.Set.union result acc.action_deps in
|
let action_deps = Path.Set.union result acc.action_deps in
|
||||||
{ acc with action_deps }
|
{ acc with action_deps }
|
||||||
end
|
end
|
||||||
|
|
|
@ -484,6 +484,7 @@ module Deps = struct
|
||||||
| Ok re ->
|
| Ok re ->
|
||||||
let dir = Path.parent_exn path in
|
let dir = Path.parent_exn path in
|
||||||
Build.paths_glob ~loc ~dir (Re.compile re)
|
Build.paths_glob ~loc ~dir (Re.compile re)
|
||||||
|
>>^ Path.Set.to_list
|
||||||
| Error (_pos, msg) ->
|
| Error (_pos, msg) ->
|
||||||
Loc.fail loc "invalid glob: %s" msg
|
Loc.fail loc "invalid glob: %s" msg
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue