From a0a92d9adb820d1d332e3b06608a69d7b208329a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 6 Jul 2018 21:47:54 +0700 Subject: [PATCH] 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 --- src/action.ml | 3 +++ src/super_context.ml | 2 +- src/value.ml | 6 +++++- src/value.mli | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/action.ml b/src/action.ml index fbf63064..6a7f86dc 100644 --- a/src/action.ml +++ b/src/action.ml @@ -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) diff --git a/src/super_context.ml b/src/super_context.ml index 126c3568..262578bd 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -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 diff --git a/src/value.ml b/src/value.ml index 9d8cf9fd..3dfe7a54 100644 --- a/src/value.ml +++ b/src/value.ml @@ -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) diff --git a/src/value.mli b/src/value.mli index d2a7b845..9f374642 100644 --- a/src/value.mli +++ b/src/value.mli @@ -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