Merge pull request #818 from rgrinberg/glob-optimize
Change Paths_glob to return a set of paths
This commit is contained in:
commit
0cdf57e47b
|
@ -26,7 +26,7 @@ module Repr = struct
|
|||
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
||||
| Paths : 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 *)
|
||||
| If_file_exists : Path.t * ('a, 'b) if_file_exists_state ref -> ('a, 'b) t
|
||||
| Contents : Path.t -> ('a, string) t
|
||||
|
@ -55,7 +55,7 @@ module Repr = struct
|
|||
|
||||
and glob_state =
|
||||
| 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 =
|
||||
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
|
||||
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] *)
|
||||
(** 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
|
||||
| Paths : 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
|
||||
| Contents : Path.t -> ('a, string) t
|
||||
| Lines_of : Path.t -> ('a, string list) t
|
||||
|
@ -221,10 +221,10 @@ module Repr : sig
|
|||
|
||||
and glob_state =
|
||||
| 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_glob_result_exn : glob_state ref -> Path.t list
|
||||
val get_glob_result_exn : glob_state ref -> Path.Set.t
|
||||
end
|
||||
|
||||
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
|
||||
match !state with
|
||||
| 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) ->
|
||||
let targets = all_targets ~dir in
|
||||
let result =
|
||||
|
@ -87,7 +87,7 @@ let static_deps t ~all_targets ~file_tree =
|
|||
(* diml: we should probably warn in this case as well *)
|
||||
()
|
||||
end;
|
||||
state := G_evaluated (Path.Set.to_list result);
|
||||
state := G_evaluated result;
|
||||
let action_deps = Path.Set.union result acc.action_deps in
|
||||
{ acc with action_deps }
|
||||
end
|
||||
|
|
|
@ -484,6 +484,7 @@ module Deps = struct
|
|||
| Ok re ->
|
||||
let dir = Path.parent_exn path in
|
||||
Build.paths_glob ~loc ~dir (Re.compile re)
|
||||
>>^ Path.Set.to_list
|
||||
| Error (_pos, msg) ->
|
||||
Loc.fail loc "invalid glob: %s" msg
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue