diff --git a/src/action.ml b/src/action.ml index e21fcb30..b6021fff 100644 --- a/src/action.ml +++ b/src/action.ml @@ -271,21 +271,14 @@ module Unresolved = struct end module Var_expansion = struct - module Concat_or_split = struct - type t = - | Concat (* default *) - | Split (* the variable is a "split" list of items *) - end - - open Concat_or_split - type t = - | Paths of Path.t list * Concat_or_split.t - | Strings of string list * Concat_or_split.t + | Paths of Path.t list + | Strings of string list let is_multivalued = function - | Paths (_, Split) | Strings (_, Split) -> true - | Paths (_, Concat) | Strings (_, Concat) -> false + | Paths [_] -> false + | Strings [_] -> false + | _ -> false type context = Path.t (* For String_with_vars.Expand_to *) @@ -297,38 +290,25 @@ module Var_expansion = struct let path_of_string dir s = Path.relative dir s let to_strings dir = function - | Strings (l, Split ) -> l - | Strings (l, Concat) -> [concat l] - | Paths (l, Split ) -> List.map l ~f:(string_of_path ~dir) - | Paths (l, Concat) -> [concat (List.map l ~f:(string_of_path ~dir))] + | Strings l -> l + | Paths l -> List.map l ~f:(string_of_path ~dir) let to_string (dir: context) = function - | Strings (l, _) -> concat l - | Paths (l, _) -> concat (List.map l ~f:(string_of_path ~dir)) + | Strings l -> concat l + | Paths l -> concat (List.map l ~f:(string_of_path ~dir)) let to_path dir = function - | Strings (l, _) -> path_of_string dir (concat l) - | Paths ([p], _) -> p - | Paths (l, _) -> + | Strings l -> path_of_string dir (concat l) + | Paths [p] -> p + | Paths l -> path_of_string dir (concat (List.map l ~f:(string_of_path ~dir))) let to_prog_and_args dir exp : Unresolved.Program.t * string list = let module P = Unresolved.Program in match exp with - | Paths ([p], _) -> (This p, []) - | Strings ([s], _) -> (P.of_string ~dir s, []) - | Paths ([], _) | Strings ([], _) -> (Search "", []) - | Paths (l, Concat) -> - (This - (path_of_string dir - (concat (List.map l ~f:(string_of_path ~dir)))), - []) - | Strings (l, Concat) -> - (P.of_string ~dir (concat l), l) - | Paths (p :: l, Split) -> - (This p, List.map l ~f:(string_of_path ~dir)) - | Strings (s :: l, Split) -> - (P.of_string ~dir s, l) + | Paths (x::xs) -> (This x, to_strings dir (Paths xs)) + | Strings (s::xs) -> (P.of_string ~dir s, to_strings dir (Strings xs)) + | Paths [] | Strings [] -> (Search "", []) end module VE = Var_expansion diff --git a/src/action.mli b/src/action.mli index 484debf3..89e0a91f 100644 --- a/src/action.mli +++ b/src/action.mli @@ -1,15 +1,9 @@ open! Import module Var_expansion : sig - module Concat_or_split : sig - type t = - | Concat (** default *) - | Split (** the variable is a "split" list of items *) - end - type t = - | Paths of Path.t list * Concat_or_split.t - | Strings of string list * Concat_or_split.t + | Paths of Path.t list + | Strings of string list val to_string : Path.t -> t -> string (** [to_string dir v] convert the variable expansion to a string. diff --git a/src/inline_tests.ml b/src/inline_tests.ml index df47cb84..120823a8 100644 --- a/src/inline_tests.ml +++ b/src/inline_tests.ml @@ -188,7 +188,7 @@ include Sub_system.Register_end_point( let extra_vars = String.Map.singleton "library-name" - (Action.Var_expansion.Strings ([lib.name], Concat)) + (Action.Var_expansion.Strings [lib.name]) in let runner_libs = @@ -212,8 +212,7 @@ include Sub_system.Register_end_point( let files ml_kind = Action.Var_expansion.Paths ( List.filter_map source_modules ~f:(fun m -> - Module.file m ~dir ml_kind), - Split) + Module.file m ~dir ml_kind)) in let extra_vars = List.fold_left diff --git a/src/super_context.ml b/src/super_context.ml index b9978d1a..68f26e31 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -273,15 +273,15 @@ let create let open Action.Var_expansion in let make = match Bin.make with - | None -> Strings (["make"], Split) - | Some p -> Paths ([p], Split) + | None -> Strings ["make"] + | Some p -> Paths [p] in let cflags = context.ocamlc_cflags in - let strings l = Strings (l , Split) in - let string s = Strings ([s], Concat) in - let path p = Paths ([p], Split) in + let strings l = Strings l in + let string s = Strings [s] in + let path p = Paths [p] in let vars = - [ "-verbose" , Strings ([] (*"-verbose";*), Concat) + [ "-verbose" , Strings ([] (*"-verbose";*)) ; "CPP" , strings (context.c_compiler :: cflags @ ["-E"]) ; "PA_CPP" , strings (context.c_compiler :: cflags @ ["-undef"; "-traditional"; @@ -602,8 +602,8 @@ module Action = struct acc.ddeps <- String.Map.add acc.ddeps key dep; None - let path_exp path = Action.Var_expansion.Paths ([path], Concat) - let str_exp path = Action.Var_expansion.Strings ([path], Concat) + let path_exp path = Action.Var_expansion.Paths [path] + let str_exp path = Action.Var_expansion.Strings [path] let map_exe sctx = match sctx.host with @@ -683,8 +683,8 @@ module Action = struct | Some p -> let x = Pkg_version.read sctx p >>^ function - | None -> Strings ([""], Concat) - | Some s -> Strings ([s], Concat) + | None -> Strings [""] + | Some s -> Strings [s] in add_ddep acc ~key x | None -> @@ -696,7 +696,7 @@ module Action = struct let path = Path.relative dir s in let data = Build.contents path - >>^ fun s -> Strings ([s], Concat) + >>^ fun s -> Strings [s] in add_ddep acc ~key data end @@ -704,7 +704,7 @@ module Action = struct let path = Path.relative dir s in let data = Build.lines_of path - >>^ fun l -> Strings (l, Split) + >>^ fun l -> Strings l in add_ddep acc ~key data end @@ -712,7 +712,7 @@ module Action = struct let path = Path.relative dir s in let data = Build.strings path - >>^ fun l -> Strings (l, Split) + >>^ fun l -> Strings l in add_ddep acc ~key data end @@ -734,7 +734,7 @@ module Action = struct match targets_written_by_user with | Infer -> Loc.fail loc "You cannot use ${@} with inferred rules." | Alias -> Loc.fail loc "You cannot use ${@} in aliases." - | Static l -> Some (Paths (l, Split)) + | Static l -> Some (Paths l) end | _ -> match String.lsplit2 var ~on:':' with @@ -743,7 +743,7 @@ module Action = struct | x -> let exp = expand loc key var x in (match exp with - | Some (Paths (ps, _)) -> + | Some (Paths ps) -> acc.sdeps <- Path.Set.union (Path.Set.of_list ps) acc.sdeps | _ -> ()); exp) @@ -764,10 +764,10 @@ module Action = struct | [] -> Loc.warn loc "Variable '<' used with no explicit \ dependencies@."; - Strings ([""], Concat) + Strings [""] | dep :: _ -> - Paths ([dep], Concat)) - | "^" -> Some (Paths (deps_written_by_user, Split)) + Paths [dep]) + | "^" -> Some (Paths deps_written_by_user) | _ -> None) let run sctx ~loc ?(extra_vars=String.Map.empty)