Pass extra params to with_expander

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-07-13 12:07:16 +02:00
parent 62e7684f3b
commit 2ec21d7b94
3 changed files with 14 additions and 26 deletions

View File

@ -158,7 +158,7 @@ let concat_rev = function
| l -> String.concat (List.rev l) ~sep:"" | l -> String.concat (List.rev l) ~sep:""
module Mode = struct module Mode = struct
type 'a t = type _ t =
| Single : Value.t t | Single : Value.t t
| Many : Value.t list t | Many : Value.t list t

View File

@ -35,7 +35,7 @@ val is_var : t -> name:string -> bool
val text_only : t -> string option val text_only : t -> string option
module Mode : sig module Mode : sig
type 'a t = type _ t =
| Single : Value.t t | Single : Value.t t
| Many : Value.t list t | Many : Value.t list t
end end

View File

@ -583,17 +583,16 @@ module Expander : sig
type sctx = t type sctx = t
type expander val with_expander
= sctx : sctx
-> dir:Path.t -> dir:Path.t
-> dep_kind:Build.lib_dep_kind -> dep_kind:Build.lib_dep_kind
-> scope:Scope.t -> scope:Scope.t
-> targets_written_by_user:targets -> targets_written_by_user:targets
-> map_exe:(Path.t -> Path.t) -> map_exe:(Path.t -> Path.t)
-> bindings:Pform.Map.t -> bindings:Pform.Map.t
-> Value.t list option String_with_vars.expander -> f:(Value.t list option String_with_vars.expander -> 'a)
-> 'a * Resolved_forms.t
val with_expander : (expander -> 'a) -> 'a * Resolved_forms.t
end = struct end = struct
module Resolved_forms = struct module Resolved_forms = struct
type t = type t =
@ -633,16 +632,6 @@ end = struct
type sctx = t type sctx = t
type expander
= sctx
-> dir:Path.t
-> dep_kind:Build.lib_dep_kind
-> scope:Scope.t
-> targets_written_by_user:targets
-> map_exe:(Path.t -> Path.t)
-> bindings:Pform.Map.t
-> Value.t list option String_with_vars.expander
let path_exp path = [Value.Path path] let path_exp path = [Value.Path path]
let str_exp str = [Value.String str] let str_exp str = [Value.String str]
@ -772,11 +761,12 @@ end = struct
); );
res res
let with_expander let with_expander sctx ~dir ~dep_kind ~scope ~targets_written_by_user
: 'a. (expander -> 'a) -> 'a * Resolved_forms.t ~map_exe ~bindings ~f =
= fun f -> let acc = Resolved_forms.empty () in
let acc = Resolved_forms.empty () in ( f (expander ~acc sctx ~dir ~dep_kind ~scope ~targets_written_by_user ~map_exe ~bindings)
(f (expander ~acc), acc) , acc
)
end end
module Action = struct module Action = struct
@ -801,10 +791,8 @@ module Action = struct
let expand_step1 sctx ~dir ~dep_kind ~scope ~targets_written_by_user let expand_step1 sctx ~dir ~dep_kind ~scope ~targets_written_by_user
~map_exe ~bindings t = ~map_exe ~bindings t =
Expander.with_expander (fun expander -> Expander.with_expander sctx ~dir ~dep_kind ~scope ~targets_written_by_user ~map_exe ~bindings
let f = expander sctx ~dir ~dep_kind ~scope ~targets_written_by_user ~f:(fun f -> U.partial_expand t ~dir ~map_exe ~f)
~map_exe ~bindings in
U.partial_expand t ~dir ~map_exe ~f)
let expand_step2 ~dir ~dynamic_expansions ~bindings let expand_step2 ~dir ~dynamic_expansions ~bindings
~(deps_written_by_user : Path.t Jbuild.Bindings.t) ~(deps_written_by_user : Path.t Jbuild.Bindings.t)