Add Arg_spec.Hidden_deps

This commit is contained in:
Jeremie Dimino 2018-03-30 18:53:31 -04:00 committed by Rudi Grinberg
parent 606ad1b10f
commit 85c8fff7f5
2 changed files with 10 additions and 2 deletions

View File

@ -12,13 +12,15 @@ type 'a t =
| Target of Path.t
| Path of Path.t
| Paths of Path.t list
| Hidden_deps of Path.t list
| Dyn of ('a -> nothing t)
let rec add_deps ts set =
List.fold_left ts ~init:set ~f:(fun set t ->
match t with
| Dep fn -> Pset.add set fn
| Deps fns -> Pset.union set (Pset.of_list fns)
| Dep fn -> Pset.add set fn
| Deps fns
| Hidden_deps fns -> Pset.union set (Pset.of_list fns)
| S ts
| Concat (_, ts) -> add_deps ts set
| _ -> set)
@ -51,6 +53,9 @@ let expand ~dir ts x =
| Concat (sep, ts) -> [String.concat ~sep (loop_dyn (S ts))]
| Target _ -> die "Target not allowed under Dyn"
| Dyn _ -> assert false
| Hidden_deps l ->
dyn_deps := Pset.union !dyn_deps (Pset.of_list l);
[]
in
let rec loop = function
| A s -> [s]
@ -61,6 +66,7 @@ let expand ~dir ts x =
| Concat (sep, ts) -> [String.concat ~sep (loop (S ts))]
| Target fn -> [Path.reach fn ~from:dir]
| Dyn f -> loop_dyn (f x)
| Hidden_deps _ -> []
in
let l = List.concat_map ts ~f:loop in
(l, !dyn_deps)

View File

@ -38,6 +38,8 @@ type 'a t =
| Target of Path.t
| Path of Path.t
| Paths of Path.t list
| Hidden_deps of Path.t list
(** Register dependencies but produce no argument *)
| Dyn of ('a -> nothing t)
val add_deps : _ t list -> Path.Set.t -> Path.Set.t