summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-03-10 14:16:16 -0500
committerTristan Sloughter <t@crashfast.com>2015-03-11 20:45:51 -0500
commit15b5426cfac681e92b09c70ca1e1d011df03a7c6 (patch)
tree6656aa68dc01a50bdb5804ab3b7ba5a4e12fe0fe /src
parent400140a4c449076ee91a9cd67716b523b8abf64d (diff)
merge rebar config opts for parent like done for profiles
Diffstat (limited to 'src')
-rw-r--r--src/rebar_state.erl49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index e77a259..008f202 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -97,9 +97,8 @@ new(ParentState, Config, Dir) ->
dict:from_list([{{deps, default}, D} | Config])
end,
- NewOpts = dict:merge(fun(_Key, Value1, _Value2) ->
- Value1
- end, LocalOpts, Opts),
+ NewOpts = merge_opts(LocalOpts, Opts),
+
ParentState#state_t{dir=Dir
,opts=NewOpts
,default=NewOpts}.
@@ -213,23 +212,8 @@ apply_profiles(State=#state_t{opts=Opts, current_profiles=CurrentProfiles}, Prof
State#state_t{current_profiles=CurrentProfiles++Profiles1, opts=NewOpts}.
merge_opts(Profile, NewOpts, OldOpts) ->
- Opts = dict:merge(fun(_Key, NewValue, OldValue) when is_list(NewValue) ->
- case io_lib:printable_list(NewValue) of
- true when NewValue =:= [] ->
- case io_lib:printable_list(OldValue) of
- true ->
- NewValue;
- false ->
- OldValue
- end;
- true ->
- NewValue;
- false ->
- OldValue ++ NewValue
- end;
- (_Key, NewValue, _OldValue) ->
- NewValue
- end, NewOpts, OldOpts),
+ Opts = merge_opts(NewOpts, OldOpts),
+
case dict:find(deps, NewOpts) of
{ok, Value} ->
dict:store({deps, Profile}, Value, Opts);
@@ -237,6 +221,31 @@ merge_opts(Profile, NewOpts, OldOpts) ->
Opts
end.
+merge_opts(NewOpts, OldOpts) ->
+ dict:merge(fun(deps, NewValue, _OldValue) ->
+ NewValue;
+ ({deps, _}, NewValue, _OldValue) ->
+ NewValue;
+ (profiles, NewValue, OldValue) ->
+ dict:to_list(merge_opts(dict:from_list(NewValue), dict:from_list(OldValue)));
+ (_Key, NewValue, OldValue) when is_list(NewValue) ->
+ case io_lib:printable_list(NewValue) of
+ true when NewValue =:= [] ->
+ case io_lib:printable_list(OldValue) of
+ true ->
+ NewValue;
+ false ->
+ OldValue
+ end;
+ true ->
+ NewValue;
+ false ->
+ lists:umerge(lists:sort(NewValue), lists:sort(OldValue))
+ end;
+ (_Key, NewValue, _OldValue) ->
+ NewValue
+ end, NewOpts, OldOpts).
+
dir(#state_t{dir=Dir}) ->
Dir.