Rename the expand family of functions
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
73cc3b1e7c
commit
2f86a4d857
|
@ -201,7 +201,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let copy_files_rules (def: Copy_files.t) ~src_dir ~dir ~scope =
|
let copy_files_rules (def: Copy_files.t) ~src_dir ~dir ~scope =
|
||||||
let loc = String_with_vars.loc def.glob in
|
let loc = String_with_vars.loc def.glob in
|
||||||
let glob_in_src =
|
let glob_in_src =
|
||||||
let src_glob = SC.expand_vars sctx ~dir def.glob ~scope in
|
let src_glob = SC.expand_vars_string sctx ~dir def.glob ~scope in
|
||||||
Path.relative src_dir src_glob ~error_loc:loc
|
Path.relative src_dir src_glob ~error_loc:loc
|
||||||
in
|
in
|
||||||
(* The following condition is required for merlin to work.
|
(* The following condition is required for merlin to work.
|
||||||
|
@ -1042,7 +1042,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
| Copy_files { glob; _ } ->
|
| Copy_files { glob; _ } ->
|
||||||
let src_dir =
|
let src_dir =
|
||||||
let loc = String_with_vars.loc glob in
|
let loc = String_with_vars.loc glob in
|
||||||
let src_glob = SC.expand_vars sctx ~dir glob ~scope in
|
let src_glob = SC.expand_vars_string sctx ~dir glob ~scope in
|
||||||
Path.parent_exn (Path.relative src_dir src_glob ~error_loc:loc)
|
Path.parent_exn (Path.relative src_dir src_glob ~error_loc:loc)
|
||||||
in
|
in
|
||||||
Some
|
Some
|
||||||
|
|
|
@ -274,11 +274,11 @@ let installed_libs t = t.installed_libs
|
||||||
let find_scope_by_dir t dir = Scope.DB.find_by_dir t.scopes dir
|
let find_scope_by_dir t dir = Scope.DB.find_by_dir t.scopes dir
|
||||||
let find_scope_by_name t name = Scope.DB.find_by_name t.scopes name
|
let find_scope_by_name t name = Scope.DB.find_by_name t.scopes name
|
||||||
|
|
||||||
let expand_var_no_root t ~syntax_version ~var : Var.Kind.t option =
|
let expand_vars t ~syntax_version ~var : Var.Kind.t option =
|
||||||
begin match String_with_vars.Var.destruct var with
|
begin match String_with_vars.Var.destruct var with
|
||||||
| Single _ -> ()
|
| Single _ -> ()
|
||||||
| Pair (_, _) ->
|
| Pair (_, _) ->
|
||||||
Exn.code_error "expand_var_no_root can't expand forms"
|
Exn.code_error "expand_vars can't expand forms"
|
||||||
[ "var", String_with_vars.Var.sexp_of_t var
|
[ "var", String_with_vars.Var.sexp_of_t var
|
||||||
]
|
]
|
||||||
end;
|
end;
|
||||||
|
@ -288,16 +288,16 @@ let expand_form t ~syntax_version ~var =
|
||||||
begin match String_with_vars.Var.destruct var with
|
begin match String_with_vars.Var.destruct var with
|
||||||
| Pair (_, _) -> ()
|
| Pair (_, _) -> ()
|
||||||
| Single _ ->
|
| Single _ ->
|
||||||
Exn.code_error "expand_var_no_root can't expand single variables"
|
Exn.code_error "expand_vars can't expand single variables"
|
||||||
[ "var", String_with_vars.Var.sexp_of_t var
|
[ "var", String_with_vars.Var.sexp_of_t var
|
||||||
]
|
]
|
||||||
end;
|
end;
|
||||||
Var.Map.expand t.forms ~syntax_version ~var
|
Var.Map.expand t.forms ~syntax_version ~var
|
||||||
|
|
||||||
let (expand_vars, expand_vars_path) =
|
let (expand_vars_string, expand_vars_path) =
|
||||||
let expand t ~scope ~dir ?(extra_vars=String.Map.empty) s =
|
let expand t ~scope ~dir ?(extra_vars=String.Map.empty) s =
|
||||||
String_with_vars.expand ~mode:Single ~dir s ~f:(fun var syntax_version ->
|
String_with_vars.expand ~mode:Single ~dir s ~f:(fun var syntax_version ->
|
||||||
match expand_var_no_root t ~syntax_version ~var with
|
match expand_vars t ~syntax_version ~var with
|
||||||
| None ->
|
| None ->
|
||||||
String.Map.find extra_vars (String_with_vars.Var.full_name var)
|
String.Map.find extra_vars (String_with_vars.Var.full_name var)
|
||||||
| Some v ->
|
| Some v ->
|
||||||
|
@ -320,7 +320,7 @@ let (expand_vars, expand_vars_path) =
|
||||||
|
|
||||||
let expand_and_eval_set t ~scope ~dir ?extra_vars set ~standard =
|
let expand_and_eval_set t ~scope ~dir ?extra_vars set ~standard =
|
||||||
let open Build.O in
|
let open Build.O in
|
||||||
let f = expand_vars t ~scope ~dir ?extra_vars in
|
let f = expand_vars_string t ~scope ~dir ?extra_vars in
|
||||||
let parse ~loc:_ s = s in
|
let parse ~loc:_ s = s in
|
||||||
let (syntax, files) = Ordered_set_lang.Unexpanded.files set ~f in
|
let (syntax, files) = Ordered_set_lang.Unexpanded.files set ~f in
|
||||||
match String.Set.to_list files with
|
match String.Set.to_list files with
|
||||||
|
@ -648,7 +648,7 @@ module Deps = struct
|
||||||
|
|
||||||
let make_alias t ~scope ~dir s =
|
let make_alias t ~scope ~dir s =
|
||||||
let loc = String_with_vars.loc s in
|
let loc = String_with_vars.loc s in
|
||||||
Alias.of_user_written_path ~loc ((expand_vars_path t ~scope ~dir s))
|
Alias.of_user_written_path ~loc (expand_vars_path t ~scope ~dir s)
|
||||||
|
|
||||||
let dep t ~scope ~dir = function
|
let dep t ~scope ~dir = function
|
||||||
| File s ->
|
| File s ->
|
||||||
|
@ -678,7 +678,7 @@ module Deps = struct
|
||||||
Build.source_tree ~dir:path ~file_tree:t.file_tree
|
Build.source_tree ~dir:path ~file_tree:t.file_tree
|
||||||
>>^ Path.Set.to_list
|
>>^ Path.Set.to_list
|
||||||
| Package p ->
|
| Package p ->
|
||||||
let pkg = Package.Name.of_string (expand_vars t ~scope ~dir p) in
|
let pkg = Package.Name.of_string (expand_vars_string t ~scope ~dir p) in
|
||||||
Alias.dep (Alias.package_install ~context:t.context ~pkg)
|
Alias.dep (Alias.package_install ~context:t.context ~pkg)
|
||||||
>>^ fun () -> []
|
>>^ fun () -> []
|
||||||
| Universe ->
|
| Universe ->
|
||||||
|
@ -897,7 +897,7 @@ module Action = struct
|
||||||
let res =
|
let res =
|
||||||
match String_with_vars.Var.destruct var with
|
match String_with_vars.Var.destruct var with
|
||||||
| Single var_name ->
|
| Single var_name ->
|
||||||
begin match expand_var_no_root sctx ~syntax_version ~var with
|
begin match expand_vars sctx ~syntax_version ~var with
|
||||||
| None -> String.Map.find extra_vars key
|
| None -> String.Map.find extra_vars key
|
||||||
| Some Targets -> targets loc var_name
|
| Some Targets -> targets loc var_name
|
||||||
| Some v -> Var.Kind.to_value_no_deps_or_targets v ~scope
|
| Some v -> Var.Kind.to_value_no_deps_or_targets v ~scope
|
||||||
|
|
|
@ -78,7 +78,7 @@ val dump_env : t -> dir:Path.t -> (unit, Sexp.t list) Build.t
|
||||||
val find_scope_by_dir : t -> Path.t -> Scope.t
|
val find_scope_by_dir : t -> Path.t -> Scope.t
|
||||||
val find_scope_by_name : t -> Dune_project.Name.t -> Scope.t
|
val find_scope_by_name : t -> Dune_project.Name.t -> Scope.t
|
||||||
|
|
||||||
val expand_vars
|
val expand_vars_string
|
||||||
: t
|
: t
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
|
|
Loading…
Reference in New Issue