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:
Rudi Grinberg 2018-07-06 21:47:54 +07:00
parent 1a37977f62
commit a0a92d9adb
4 changed files with 11 additions and 3 deletions

View File

@ -337,6 +337,9 @@ end
let prog_and_args_of_values p ~dir =
match p with
| [] -> (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)
| String s :: xs ->
(Unresolved.Program.of_string ~dir s, Value.L.to_strings ~dir xs)

View File

@ -817,7 +817,7 @@ module Action = struct
let exp = expand var syntax_version in
Option.iter exp ~f:(fun vs ->
acc.sdeps <- Path.Set.union (Path.Set.of_list
(Value.L.paths_only vs)) acc.sdeps;
(Value.L.deps_only vs)) acc.sdeps;
);
exp)
in

View File

@ -2,6 +2,7 @@ open Stdune
type t =
| String of string
| Dir of Path.t
| Path of Path.t
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 =
match t with
| String s -> s
| Dir p
| Path p -> string_of_path ~dir p
let to_path ?error_loc t ~dir =
match t with
| String s -> Path.relative ?error_loc dir s
| Dir p
| Path p -> p
module L = struct
@ -23,8 +26,9 @@ module L = struct
List.map ~f:(to_string ~dir) ts
|> String.concat ~sep:" "
let paths_only =
let deps_only =
List.filter_map ~f:(function
| Dir _
| String _ -> None
| Path p -> Some p)

View File

@ -2,6 +2,7 @@ open Stdune
type t =
| String of string
| Dir of Path.t
| Path of Path.t
val to_string : t -> dir:Path.t -> string
@ -13,7 +14,7 @@ module L : sig
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