Remove Concat_or_split
Thie property will now be determined from the context Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
69c0ab48ce
commit
c1d6faef79
|
@ -271,21 +271,14 @@ module Unresolved = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
module Var_expansion = struct
|
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 =
|
type t =
|
||||||
| Paths of Path.t list * Concat_or_split.t
|
| Paths of Path.t list
|
||||||
| Strings of string list * Concat_or_split.t
|
| Strings of string list
|
||||||
|
|
||||||
let is_multivalued = function
|
let is_multivalued = function
|
||||||
| Paths (_, Split) | Strings (_, Split) -> true
|
| Paths [_] -> false
|
||||||
| Paths (_, Concat) | Strings (_, Concat) -> false
|
| Strings [_] -> false
|
||||||
|
| _ -> false
|
||||||
|
|
||||||
type context = Path.t (* For String_with_vars.Expand_to *)
|
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 path_of_string dir s = Path.relative dir s
|
||||||
|
|
||||||
let to_strings dir = function
|
let to_strings dir = function
|
||||||
| Strings (l, Split ) -> l
|
| Strings l -> l
|
||||||
| Strings (l, Concat) -> [concat l]
|
| Paths l -> List.map l ~f:(string_of_path ~dir)
|
||||||
| Paths (l, Split ) -> List.map l ~f:(string_of_path ~dir)
|
|
||||||
| Paths (l, Concat) -> [concat (List.map l ~f:(string_of_path ~dir))]
|
|
||||||
|
|
||||||
let to_string (dir: context) = function
|
let to_string (dir: context) = function
|
||||||
| Strings (l, _) -> concat l
|
| Strings l -> concat l
|
||||||
| Paths (l, _) -> concat (List.map l ~f:(string_of_path ~dir))
|
| Paths l -> concat (List.map l ~f:(string_of_path ~dir))
|
||||||
|
|
||||||
let to_path dir = function
|
let to_path dir = function
|
||||||
| Strings (l, _) -> path_of_string dir (concat l)
|
| Strings l -> path_of_string dir (concat l)
|
||||||
| Paths ([p], _) -> p
|
| Paths [p] -> p
|
||||||
| Paths (l, _) ->
|
| Paths l ->
|
||||||
path_of_string dir (concat (List.map l ~f:(string_of_path ~dir)))
|
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 to_prog_and_args dir exp : Unresolved.Program.t * string list =
|
||||||
let module P = Unresolved.Program in
|
let module P = Unresolved.Program in
|
||||||
match exp with
|
match exp with
|
||||||
| Paths ([p], _) -> (This p, [])
|
| Paths (x::xs) -> (This x, to_strings dir (Paths xs))
|
||||||
| Strings ([s], _) -> (P.of_string ~dir s, [])
|
| Strings (s::xs) -> (P.of_string ~dir s, to_strings dir (Strings xs))
|
||||||
| Paths ([], _) | Strings ([], _) -> (Search "", [])
|
| 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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module VE = Var_expansion
|
module VE = Var_expansion
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
open! Import
|
open! Import
|
||||||
|
|
||||||
module Var_expansion : sig
|
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 =
|
type t =
|
||||||
| Paths of Path.t list * Concat_or_split.t
|
| Paths of Path.t list
|
||||||
| Strings of string list * Concat_or_split.t
|
| Strings of string list
|
||||||
|
|
||||||
val to_string : Path.t -> t -> string
|
val to_string : Path.t -> t -> string
|
||||||
(** [to_string dir v] convert the variable expansion to a string.
|
(** [to_string dir v] convert the variable expansion to a string.
|
||||||
|
|
|
@ -188,7 +188,7 @@ include Sub_system.Register_end_point(
|
||||||
|
|
||||||
let extra_vars =
|
let extra_vars =
|
||||||
String.Map.singleton "library-name"
|
String.Map.singleton "library-name"
|
||||||
(Action.Var_expansion.Strings ([lib.name], Concat))
|
(Action.Var_expansion.Strings [lib.name])
|
||||||
in
|
in
|
||||||
|
|
||||||
let runner_libs =
|
let runner_libs =
|
||||||
|
@ -212,8 +212,7 @@ include Sub_system.Register_end_point(
|
||||||
let files ml_kind =
|
let files ml_kind =
|
||||||
Action.Var_expansion.Paths (
|
Action.Var_expansion.Paths (
|
||||||
List.filter_map source_modules ~f:(fun m ->
|
List.filter_map source_modules ~f:(fun m ->
|
||||||
Module.file m ~dir ml_kind),
|
Module.file m ~dir ml_kind))
|
||||||
Split)
|
|
||||||
in
|
in
|
||||||
let extra_vars =
|
let extra_vars =
|
||||||
List.fold_left
|
List.fold_left
|
||||||
|
|
|
@ -273,15 +273,15 @@ let create
|
||||||
let open Action.Var_expansion in
|
let open Action.Var_expansion in
|
||||||
let make =
|
let make =
|
||||||
match Bin.make with
|
match Bin.make with
|
||||||
| None -> Strings (["make"], Split)
|
| None -> Strings ["make"]
|
||||||
| Some p -> Paths ([p], Split)
|
| Some p -> Paths [p]
|
||||||
in
|
in
|
||||||
let cflags = context.ocamlc_cflags in
|
let cflags = context.ocamlc_cflags in
|
||||||
let strings l = Strings (l , Split) in
|
let strings l = Strings l in
|
||||||
let string s = Strings ([s], Concat) in
|
let string s = Strings [s] in
|
||||||
let path p = Paths ([p], Split) in
|
let path p = Paths [p] in
|
||||||
let vars =
|
let vars =
|
||||||
[ "-verbose" , Strings ([] (*"-verbose";*), Concat)
|
[ "-verbose" , Strings ([] (*"-verbose";*))
|
||||||
; "CPP" , strings (context.c_compiler :: cflags @ ["-E"])
|
; "CPP" , strings (context.c_compiler :: cflags @ ["-E"])
|
||||||
; "PA_CPP" , strings (context.c_compiler :: cflags
|
; "PA_CPP" , strings (context.c_compiler :: cflags
|
||||||
@ ["-undef"; "-traditional";
|
@ ["-undef"; "-traditional";
|
||||||
|
@ -602,8 +602,8 @@ module Action = struct
|
||||||
acc.ddeps <- String.Map.add acc.ddeps key dep;
|
acc.ddeps <- String.Map.add acc.ddeps key dep;
|
||||||
None
|
None
|
||||||
|
|
||||||
let path_exp path = Action.Var_expansion.Paths ([path], Concat)
|
let path_exp path = Action.Var_expansion.Paths [path]
|
||||||
let str_exp path = Action.Var_expansion.Strings ([path], Concat)
|
let str_exp path = Action.Var_expansion.Strings [path]
|
||||||
|
|
||||||
let map_exe sctx =
|
let map_exe sctx =
|
||||||
match sctx.host with
|
match sctx.host with
|
||||||
|
@ -683,8 +683,8 @@ module Action = struct
|
||||||
| Some p ->
|
| Some p ->
|
||||||
let x =
|
let x =
|
||||||
Pkg_version.read sctx p >>^ function
|
Pkg_version.read sctx p >>^ function
|
||||||
| None -> Strings ([""], Concat)
|
| None -> Strings [""]
|
||||||
| Some s -> Strings ([s], Concat)
|
| Some s -> Strings [s]
|
||||||
in
|
in
|
||||||
add_ddep acc ~key x
|
add_ddep acc ~key x
|
||||||
| None ->
|
| None ->
|
||||||
|
@ -696,7 +696,7 @@ module Action = struct
|
||||||
let path = Path.relative dir s in
|
let path = Path.relative dir s in
|
||||||
let data =
|
let data =
|
||||||
Build.contents path
|
Build.contents path
|
||||||
>>^ fun s -> Strings ([s], Concat)
|
>>^ fun s -> Strings [s]
|
||||||
in
|
in
|
||||||
add_ddep acc ~key data
|
add_ddep acc ~key data
|
||||||
end
|
end
|
||||||
|
@ -704,7 +704,7 @@ module Action = struct
|
||||||
let path = Path.relative dir s in
|
let path = Path.relative dir s in
|
||||||
let data =
|
let data =
|
||||||
Build.lines_of path
|
Build.lines_of path
|
||||||
>>^ fun l -> Strings (l, Split)
|
>>^ fun l -> Strings l
|
||||||
in
|
in
|
||||||
add_ddep acc ~key data
|
add_ddep acc ~key data
|
||||||
end
|
end
|
||||||
|
@ -712,7 +712,7 @@ module Action = struct
|
||||||
let path = Path.relative dir s in
|
let path = Path.relative dir s in
|
||||||
let data =
|
let data =
|
||||||
Build.strings path
|
Build.strings path
|
||||||
>>^ fun l -> Strings (l, Split)
|
>>^ fun l -> Strings l
|
||||||
in
|
in
|
||||||
add_ddep acc ~key data
|
add_ddep acc ~key data
|
||||||
end
|
end
|
||||||
|
@ -734,7 +734,7 @@ module Action = struct
|
||||||
match targets_written_by_user with
|
match targets_written_by_user with
|
||||||
| Infer -> Loc.fail loc "You cannot use ${@} with inferred rules."
|
| Infer -> Loc.fail loc "You cannot use ${@} with inferred rules."
|
||||||
| Alias -> Loc.fail loc "You cannot use ${@} in aliases."
|
| Alias -> Loc.fail loc "You cannot use ${@} in aliases."
|
||||||
| Static l -> Some (Paths (l, Split))
|
| Static l -> Some (Paths l)
|
||||||
end
|
end
|
||||||
| _ ->
|
| _ ->
|
||||||
match String.lsplit2 var ~on:':' with
|
match String.lsplit2 var ~on:':' with
|
||||||
|
@ -743,7 +743,7 @@ module Action = struct
|
||||||
| x ->
|
| x ->
|
||||||
let exp = expand loc key var x in
|
let exp = expand loc key var x in
|
||||||
(match exp with
|
(match exp with
|
||||||
| Some (Paths (ps, _)) ->
|
| Some (Paths ps) ->
|
||||||
acc.sdeps <- Path.Set.union (Path.Set.of_list ps) acc.sdeps
|
acc.sdeps <- Path.Set.union (Path.Set.of_list ps) acc.sdeps
|
||||||
| _ -> ());
|
| _ -> ());
|
||||||
exp)
|
exp)
|
||||||
|
@ -764,10 +764,10 @@ module Action = struct
|
||||||
| [] ->
|
| [] ->
|
||||||
Loc.warn loc "Variable '<' used with no explicit \
|
Loc.warn loc "Variable '<' used with no explicit \
|
||||||
dependencies@.";
|
dependencies@.";
|
||||||
Strings ([""], Concat)
|
Strings [""]
|
||||||
| dep :: _ ->
|
| dep :: _ ->
|
||||||
Paths ([dep], Concat))
|
Paths [dep])
|
||||||
| "^" -> Some (Paths (deps_written_by_user, Split))
|
| "^" -> Some (Paths deps_written_by_user)
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
|
|
||||||
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
||||||
|
|
Loading…
Reference in New Issue