Use the variable for dynamic expansions as well
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
3f7ad78512
commit
3a7b62a57d
|
@ -203,6 +203,7 @@ module Var = struct
|
||||||
|> List.concat
|
|> List.concat
|
||||||
|> String.Map.of_list_exn
|
|> String.Map.of_list_exn
|
||||||
|
|
||||||
|
let static_vars = String.Map.of_list_exn static_vars
|
||||||
|
|
||||||
let rec expand t ~syntax_version ~var =
|
let rec expand t ~syntax_version ~var =
|
||||||
let name =
|
let name =
|
||||||
|
@ -945,32 +946,20 @@ module Action = struct
|
||||||
match String.Map.find dynamic_expansions key with
|
match String.Map.find dynamic_expansions key with
|
||||||
| Some _ as opt -> opt
|
| Some _ as opt -> opt
|
||||||
| None ->
|
| None ->
|
||||||
let first_dep () =
|
Var.Map.expand Var.Map.static_vars ~syntax_version ~var
|
||||||
Some (
|
|> Option.map ~f:(function
|
||||||
match deps_written_by_user with
|
| Var.Kind.Deps -> (Value.L.paths deps_written_by_user)
|
||||||
|
| First_dep ->
|
||||||
|
begin match deps_written_by_user with
|
||||||
| [] ->
|
| [] ->
|
||||||
Loc.warn loc "Variable '%s' used with no explicit \
|
Loc.warn loc "Variable '%s' used with no explicit \
|
||||||
dependencies@." key;
|
dependencies@." key;
|
||||||
[Value.String ""]
|
[Value.String ""]
|
||||||
| v :: _ -> [Path v]
|
| v :: _ -> [Path v]
|
||||||
)
|
end
|
||||||
in
|
| _ ->
|
||||||
match key with
|
Exn.code_error "Unexpected variable in step2"
|
||||||
| "<" ->
|
["var", String_with_vars.Var.sexp_of_t var]))
|
||||||
if syntax_version < (1, 0) then
|
|
||||||
first_dep ()
|
|
||||||
else
|
|
||||||
Loc.fail loc "Variable '<' is renamed to 'first-dep' in dune files"
|
|
||||||
| "first-dep" when syntax_version >= (1, 0) -> first_dep ()
|
|
||||||
| "^" ->
|
|
||||||
if syntax_version < (1, 0) then
|
|
||||||
Some (Value.L.paths deps_written_by_user)
|
|
||||||
else
|
|
||||||
Loc.fail loc
|
|
||||||
"Variable %%{^} has been renamed to %%{deps} in dune files"
|
|
||||||
| "deps" when syntax_version >= (1, 0) ->
|
|
||||||
Some (Value.L.paths deps_written_by_user)
|
|
||||||
| _ -> None)
|
|
||||||
|
|
||||||
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
||||||
t ~dir ~dep_kind ~targets:targets_written_by_user ~scope
|
t ~dir ~dep_kind ~targets:targets_written_by_user ~scope
|
||||||
|
|
Loading…
Reference in New Issue