Add Arg_spec.Hidden_targets

Same as Hidden_deps: allows to declare targets than don't appear on
the command line.
This commit is contained in:
Jeremie Dimino 2018-04-18 16:42:33 +01:00 committed by Jérémie Dimino
parent d9a90b4f29
commit bd7f793792
2 changed files with 7 additions and 4 deletions

View File

@ -12,7 +12,8 @@ type 'a t =
| Target of Path.t
| Path of Path.t
| Paths of Path.t list
| Hidden_deps of Path.t list
| Hidden_deps of Path.t list
| Hidden_targets of Path.t list
| Dyn of ('a -> nothing t)
let rec add_deps ts set =
@ -29,6 +30,7 @@ let rec add_targets ts acc =
List.fold_left ts ~init:acc ~f:(fun acc t ->
match t with
| Target fn -> fn :: acc
| Hidden_targets fns -> List.rev_append fns acc
| S ts
| Concat (_, ts) -> add_targets ts acc
| _ -> acc)
@ -51,7 +53,7 @@ let expand ~dir ts x =
List.map fns ~f:(Path.reach ~from:dir)
| S ts -> List.concat_map ts ~f:loop_dyn
| Concat (sep, ts) -> [String.concat ~sep (loop_dyn (S ts))]
| Target _ -> die "Target not allowed under Dyn"
| Target _ | Hidden_targets _ -> die "Target not allowed under Dyn"
| Dyn _ -> assert false
| Hidden_deps l ->
dyn_deps := Pset.union !dyn_deps (Pset.of_list l);
@ -66,7 +68,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 _ -> []
| Hidden_deps _ | Hidden_targets _ -> []
in
let l = List.concat_map ts ~f:loop in
(l, !dyn_deps)

View File

@ -38,7 +38,8 @@ type 'a t =
| Target of Path.t
| Path of Path.t
| Paths of Path.t list
| Hidden_deps of Path.t list
| Hidden_deps of Path.t list
| Hidden_targets of Path.t list
(** Register dependencies but produce no argument *)
| Dyn of ('a -> nothing t)