25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Make processing of if_* clauses in rebar.config recursive

This commit is contained in:
Paweł Chmielowski 2016-07-20 10:11:08 +02:00
parent 0c0c6465ba
commit 7748dd4e5d

View File

@ -19,7 +19,7 @@ ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg] [{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
end end
end, end,
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end. ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end,
Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of
{ok, Terms} -> {ok, Terms} ->
@ -28,6 +28,13 @@ Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config"))
[] []
end, end,
ProcessSingleVar = fun(F, Var, Tail) ->
case F(F, [Var], []) of
[] -> Tail;
[Val] -> [Val | Tail]
end
end,
ProcessVars = fun(_F, [], Acc) -> ProcessVars = fun(_F, [], Acc) ->
lists:reverse(Acc); lists:reverse(Acc);
(F, [{Type, Ver, Value} | Tail], Acc) when (F, [{Type, Ver, Value} | Tail], Acc) when
@ -40,7 +47,7 @@ ProcessVars = fun(_F, [], Acc) ->
SysVer < Ver SysVer < Ver
end, end,
if Include -> if Include ->
F(F, Tail, [Value | Acc]); F(F, Tail, ProcessSingleVar(F, Value, Acc));
true -> true ->
F(F, Tail, Acc) F(F, Tail, Acc)
end; end;
@ -50,7 +57,7 @@ ProcessVars = fun(_F, [], Acc) ->
Flag = Type == if_var_true, Flag = Type == if_var_true,
case proplists:get_bool(Var, Cfg) of case proplists:get_bool(Var, Cfg) of
V when V == Flag -> V when V == Flag ->
F(F, Tail, [Value | Acc]); F(F, Tail, ProcessSingleVar(F, Value, Acc));
_ -> _ ->
F(F, Tail, Acc) F(F, Tail, Acc)
end; end;
@ -59,7 +66,7 @@ ProcessVars = fun(_F, [], Acc) ->
Type == if_var_no_match -> Type == if_var_no_match ->
case proplists:get_value(Var, Cfg) of case proplists:get_value(Var, Cfg) of
V when V == Match -> V when V == Match ->
F(F, Tail, [Value | Acc]); F(F, Tail, ProcessSingleVar(F, Value, Acc));
_ -> _ ->
F(F, Tail, Acc) F(F, Tail, Acc)
end; end;