Introduce a Dir primitive to Value
This is like Path but users will know not to infer dependencies from it Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
1a37977f62
commit
a0a92d9adb
|
@ -337,6 +337,9 @@ end
|
||||||
let prog_and_args_of_values p ~dir =
|
let prog_and_args_of_values p ~dir =
|
||||||
match p with
|
match p with
|
||||||
| [] -> (Unresolved.Program.Search "", [])
|
| [] -> (Unresolved.Program.Search "", [])
|
||||||
|
| Value.Dir p :: _ ->
|
||||||
|
die "%s is a directory and cannot be used as an executable"
|
||||||
|
(Path.to_string_maybe_quoted p)
|
||||||
| Value.Path p :: xs -> (This p, Value.L.to_strings ~dir xs)
|
| Value.Path p :: xs -> (This p, Value.L.to_strings ~dir xs)
|
||||||
| String s :: xs ->
|
| String s :: xs ->
|
||||||
(Unresolved.Program.of_string ~dir s, Value.L.to_strings ~dir xs)
|
(Unresolved.Program.of_string ~dir s, Value.L.to_strings ~dir xs)
|
||||||
|
|
|
@ -817,7 +817,7 @@ module Action = struct
|
||||||
let exp = expand var syntax_version in
|
let exp = expand var syntax_version in
|
||||||
Option.iter exp ~f:(fun vs ->
|
Option.iter exp ~f:(fun vs ->
|
||||||
acc.sdeps <- Path.Set.union (Path.Set.of_list
|
acc.sdeps <- Path.Set.union (Path.Set.of_list
|
||||||
(Value.L.paths_only vs)) acc.sdeps;
|
(Value.L.deps_only vs)) acc.sdeps;
|
||||||
);
|
);
|
||||||
exp)
|
exp)
|
||||||
in
|
in
|
||||||
|
|
|
@ -2,6 +2,7 @@ open Stdune
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
| String of string
|
| String of string
|
||||||
|
| Dir of Path.t
|
||||||
| Path of Path.t
|
| Path of Path.t
|
||||||
|
|
||||||
let string_of_path ~dir p = Path.reach ~from:dir p
|
let string_of_path ~dir p = Path.reach ~from:dir p
|
||||||
|
@ -9,11 +10,13 @@ let string_of_path ~dir p = Path.reach ~from:dir p
|
||||||
let to_string t ~dir =
|
let to_string t ~dir =
|
||||||
match t with
|
match t with
|
||||||
| String s -> s
|
| String s -> s
|
||||||
|
| Dir p
|
||||||
| Path p -> string_of_path ~dir p
|
| Path p -> string_of_path ~dir p
|
||||||
|
|
||||||
let to_path ?error_loc t ~dir =
|
let to_path ?error_loc t ~dir =
|
||||||
match t with
|
match t with
|
||||||
| String s -> Path.relative ?error_loc dir s
|
| String s -> Path.relative ?error_loc dir s
|
||||||
|
| Dir p
|
||||||
| Path p -> p
|
| Path p -> p
|
||||||
|
|
||||||
module L = struct
|
module L = struct
|
||||||
|
@ -23,8 +26,9 @@ module L = struct
|
||||||
List.map ~f:(to_string ~dir) ts
|
List.map ~f:(to_string ~dir) ts
|
||||||
|> String.concat ~sep:" "
|
|> String.concat ~sep:" "
|
||||||
|
|
||||||
let paths_only =
|
let deps_only =
|
||||||
List.filter_map ~f:(function
|
List.filter_map ~f:(function
|
||||||
|
| Dir _
|
||||||
| String _ -> None
|
| String _ -> None
|
||||||
| Path p -> Some p)
|
| Path p -> Some p)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ open Stdune
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
| String of string
|
| String of string
|
||||||
|
| Dir of Path.t
|
||||||
| Path of Path.t
|
| Path of Path.t
|
||||||
|
|
||||||
val to_string : t -> dir:Path.t -> string
|
val to_string : t -> dir:Path.t -> string
|
||||||
|
@ -13,7 +14,7 @@ module L : sig
|
||||||
|
|
||||||
val paths : Path.t list -> t list
|
val paths : Path.t list -> t list
|
||||||
|
|
||||||
val paths_only : t list -> Path.t list
|
val deps_only : t list -> Path.t list
|
||||||
|
|
||||||
val concat : t list -> dir:Path.t -> string
|
val concat : t list -> dir:Path.t -> string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue