Move Value.t list functions to Value.L
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
c96df4dc15
commit
6ebff9d388
|
@ -274,9 +274,9 @@ end
|
|||
let prog_and_args_of_values p ~dir =
|
||||
match p with
|
||||
| [] -> (Unresolved.Program.Search "", [])
|
||||
| Value.Path p :: xs -> (This p, Value.to_strings ~dir xs)
|
||||
| Value.Path p :: xs -> (This p, Value.L.to_strings ~dir xs)
|
||||
| String s :: xs ->
|
||||
(Unresolved.Program.of_string ~dir s, Value.to_strings ~dir xs)
|
||||
(Unresolved.Program.of_string ~dir s, Value.L.to_strings ~dir xs)
|
||||
|
||||
module SW = String_with_vars
|
||||
|
||||
|
@ -327,7 +327,7 @@ module Unexpanded = struct
|
|||
let strings =
|
||||
expand ~mode:Many
|
||||
~l:(fun x -> [x])
|
||||
~r:Value.to_strings
|
||||
~r:Value.L.to_strings
|
||||
|
||||
let path e =
|
||||
let error_loc =
|
||||
|
@ -410,8 +410,8 @@ module Unexpanded = struct
|
|||
| Unexpanded x -> Right x
|
||||
|
||||
let string = expand ~mode:Single ~map:Value.to_string
|
||||
let strings = expand ~mode:Many ~map:Value.to_strings
|
||||
let cat_strings = expand ~mode:Many ~map:Value.concat
|
||||
let strings = expand ~mode:Many ~map:Value.L.to_strings
|
||||
let cat_strings = expand ~mode:Many ~map:Value.L.concat
|
||||
let path x =
|
||||
let error_loc = String_with_vars.loc x in
|
||||
expand ~mode:Single ~map:(Value.to_path ~error_loc) x
|
||||
|
|
|
@ -209,7 +209,7 @@ include Sub_system.Register_end_point(
|
|||
let target = Path.relative inline_test_dir main_module_filename in
|
||||
let source_modules = Module.Name.Map.values source_modules in
|
||||
let files ml_kind =
|
||||
Value.paths (
|
||||
Value.L.paths (
|
||||
List.filter_map source_modules ~f:(fun m ->
|
||||
Module.file m ~dir ml_kind))
|
||||
in
|
||||
|
|
|
@ -160,7 +160,7 @@ let partial_expand t ~mode ~dir ~f =
|
|||
| Some ([] | _::_::_ as e) when not t.quoted ->
|
||||
invalid_multivalue syntax ~var t e
|
||||
| Some t ->
|
||||
loop (List.rev_append (Value.to_strings ~dir t) acc_text) acc items
|
||||
loop (List.rev_append (Value.L.to_strings ~dir t) acc_text) acc items
|
||||
| None -> loop [] (it :: commit_text acc_text acc) items
|
||||
end
|
||||
in
|
||||
|
|
|
@ -287,7 +287,7 @@ let create
|
|||
| Some p -> path p
|
||||
in
|
||||
let cflags = context.ocamlc_cflags in
|
||||
let strings = Value.strings in
|
||||
let strings = Value.L.strings in
|
||||
let vars =
|
||||
[ "-verbose" , []
|
||||
; "CPP" , strings (context.c_compiler :: cflags @ ["-E"])
|
||||
|
@ -707,7 +707,7 @@ module Action = struct
|
|||
let path = Path.relative dir s in
|
||||
let data =
|
||||
Build.lines_of path
|
||||
>>^ Value.strings
|
||||
>>^ Value.L.strings
|
||||
in
|
||||
add_ddep acc ~key data
|
||||
end
|
||||
|
@ -715,7 +715,7 @@ module Action = struct
|
|||
let path = Path.relative dir s in
|
||||
let data =
|
||||
Build.strings path
|
||||
>>^ Value.strings
|
||||
>>^ Value.L.strings
|
||||
in
|
||||
add_ddep acc ~key data
|
||||
end
|
||||
|
@ -737,7 +737,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 (Value.paths l)
|
||||
| Static l -> Some (Value.L.paths l)
|
||||
end
|
||||
| _ ->
|
||||
match String.lsplit2 var ~on:':' with
|
||||
|
@ -746,8 +746,8 @@ module Action = struct
|
|||
| x ->
|
||||
let exp = expand loc key var x in
|
||||
Option.iter exp ~f:(fun vs ->
|
||||
acc.sdeps <-
|
||||
Path.Set.union (Path.Set.of_list (Value.paths_only vs)) acc.sdeps;
|
||||
acc.sdeps <- Path.Set.union (Path.Set.of_list
|
||||
(Value.L.paths_only vs)) acc.sdeps;
|
||||
);
|
||||
exp)
|
||||
in
|
||||
|
@ -769,7 +769,7 @@ module Action = struct
|
|||
[Value.String ""]
|
||||
| dep :: _ ->
|
||||
[Path dep])
|
||||
| "^" -> Some (Value.paths deps_written_by_user)
|
||||
| "^" -> Some (Value.L.paths deps_written_by_user)
|
||||
| _ -> None)
|
||||
|
||||
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
||||
|
|
11
src/value.ml
11
src/value.ml
|
@ -11,15 +11,13 @@ let to_string t ~dir =
|
|||
| String s -> s
|
||||
| Path p -> string_of_path ~dir p
|
||||
|
||||
let to_strings t ~dir = List.map t ~f:(to_string ~dir)
|
||||
|
||||
let to_path ?error_loc t ~dir =
|
||||
match t with
|
||||
| String s -> Path.relative ?error_loc dir s
|
||||
| Path p -> p
|
||||
|
||||
let strings = List.map ~f:(fun x -> String x)
|
||||
let paths = List.map ~f:(fun x -> Path x)
|
||||
module L = struct
|
||||
let to_strings t ~dir = List.map t ~f:(to_string ~dir)
|
||||
|
||||
let concat ts ~dir =
|
||||
List.map ~f:(to_string ~dir) ts
|
||||
|
@ -29,3 +27,8 @@ let paths_only =
|
|||
List.filter_map ~f:(function
|
||||
| String _ -> None
|
||||
| Path p -> Some p)
|
||||
|
||||
let strings = List.map ~f:(fun x -> String x)
|
||||
|
||||
let paths = List.map ~f:(fun x -> Path x)
|
||||
end
|
||||
|
|
|
@ -6,10 +6,9 @@ type t =
|
|||
|
||||
val to_string : t -> dir:Path.t -> string
|
||||
|
||||
val to_strings : t list -> dir:Path.t -> string list
|
||||
|
||||
val to_path : ?error_loc:Loc.t -> t -> dir:Path.t -> Path.t
|
||||
|
||||
module L : sig
|
||||
val strings : string list -> t list
|
||||
|
||||
val paths : Path.t list -> t list
|
||||
|
@ -17,3 +16,6 @@ val paths : Path.t list -> t list
|
|||
val paths_only : t list -> Path.t list
|
||||
|
||||
val concat : t list -> dir:Path.t -> string
|
||||
|
||||
val to_strings : t list -> dir:Path.t -> string list
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue