summaryrefslogtreecommitdiff
path: root/src/rebar_utils.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r--src/rebar_utils.erl152
1 files changed, 2 insertions, 150 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 7260f6d..564b384 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -26,10 +26,7 @@
%% -------------------------------------------------------------------
-module(rebar_utils).
--export([get/2,
- get/3,
- set/3,
- sort_deps/1,
+-export([sort_deps/1,
droplast/1,
filtermap/2,
is_arch/1,
@@ -48,7 +45,6 @@
vcs_vsn/3,
deprecated/3,
deprecated/4,
- erl_opts/1,
indent/1,
update_code/1,
remove_from_code_path/1,
@@ -69,11 +65,7 @@
escape_double_quotes_weak/1,
check_min_otp_version/1,
check_blacklisted_otp_versions/1,
- info_useless/2,
- apply_overrides/3,
- add_to_profile/3,
- merge_opts/2,
- merge_opts/3]).
+ info_useless/2]).
%% for internal use only
-export([otp_release/0]).
@@ -87,21 +79,6 @@
%% Public API
%% ====================================================================
-get(Opts, Key) ->
- {ok, Value} = dict:find(Key, Opts),
- Value.
-
-get(Opts, Key, Default) ->
- case dict:find(Key, Opts) of
- {ok, Value} ->
- Value;
- error ->
- Default
- end.
-
-set(Opts, Key, Value) ->
- dict:store(Key, Value, Opts).
-
sort_deps(Deps) ->
%% We need a sort stable, based on the name. So that for multiple deps on
%% the same level with the same name, we keep the order the parents had.
@@ -240,20 +217,6 @@ deprecated(Old, New, When) ->
"'~p' will be removed ~s.~n">>,
[Old, Old, New, Old, When]).
-%% @doc Return list of erl_opts
--spec erl_opts(rebar_dict()) -> list().
-erl_opts(Opts) ->
- RawErlOpts = filter_defines(rebar_utils:get(Opts, erl_opts, []), []),
- Defines = [{d, list_to_atom(D)} ||
- D <- rebar_utils:get(Opts, defines, [])],
- AllOpts = Defines ++ RawErlOpts,
- case proplists:is_defined(no_debug_info, AllOpts) of
- true ->
- [O || O <- AllOpts, O =/= no_debug_info];
- false ->
- [debug_info|AllOpts]
- end.
-
%% for use by `do` task
%% note: this does not handle the case where you have an argument that
@@ -407,94 +370,6 @@ abort_if_blacklisted(BlacklistedRegex, OtpRelease) ->
[OtpRelease, BlacklistedRegex])
end.
-apply_overrides(Opts, Name, Overrides) ->
- %% Inefficient. We want the order we get here though.
- Opts1 = lists:foldl(fun({override, O}, OptsAcc) ->
- lists:foldl(fun({deps, Value}, OptsAcc1) ->
- rebar_utils:set(OptsAcc1, {deps,default}, Value);
- ({Key, Value}, OptsAcc1) ->
- rebar_utils:set(OptsAcc1, Key, Value)
- end, OptsAcc, O);
- (_, OptsAcc) ->
- OptsAcc
- end, Opts, Overrides),
-
- Opts2 = lists:foldl(fun({override, N, O}, OptsAcc) when N =:= Name ->
- lists:foldl(fun({deps, Value}, OptsAcc1) ->
- rebar_utils:set(OptsAcc1, {deps,default}, Value);
- ({Key, Value}, OptsAcc1) ->
- rebar_utils:set(OptsAcc1, Key, Value)
- end, OptsAcc, O);
- (_, OptsAcc) ->
- OptsAcc
- end, Opts1, Overrides),
-
- lists:foldl(fun({add, N, O}, OptsAcc) when N =:= Name ->
- lists:foldl(fun({deps, Value}, OptsAcc1) ->
- OldValue = rebar_utils:get(OptsAcc1, {deps,default}, []),
- rebar_utils:set(OptsAcc1, {deps,default}, Value++OldValue);
- ({Key, Value}, OptsAcc1) ->
- OldValue = rebar_utils:get(OptsAcc1, Key, []),
- rebar_utils:set(OptsAcc1, Key, Value++OldValue)
- end, OptsAcc, O);
- (_, OptsAcc) ->
- OptsAcc
- end, Opts2, Overrides).
-
-add_to_profile(Opts, Profile, KVs) when is_atom(Profile), is_list(KVs) ->
- Profiles = rebar_utils:get(Opts, profiles, []),
- ProfileOpts = dict:from_list(proplists:get_value(Profile, Profiles, [])),
- NewOpts = rebar_utils:merge_opts(Profile, dict:from_list(KVs), ProfileOpts),
- NewProfiles = [{Profile, dict:to_list(NewOpts)}|lists:keydelete(Profile, 1, Profiles)],
- rebar_utils:set(Opts, profiles, NewProfiles).
-
-merge_opts(Profile, NewOpts, OldOpts) ->
- Opts = merge_opts(NewOpts, OldOpts),
-
- Opts2 = case dict:find(plugins, NewOpts) of
- {ok, Value} ->
- dict:store({plugins, Profile}, Value, Opts);
- error ->
- Opts
- end,
-
- case dict:find(deps, NewOpts) of
- {ok, Value2} ->
- dict:store({deps, Profile}, Value2, Opts2);
- error ->
- Opts2
- end.
-
-merge_opts(NewOpts, OldOpts) ->
- dict:merge(fun(deps, _NewValue, OldValue) ->
- OldValue;
- ({deps, _}, NewValue, _OldValue) ->
- NewValue;
- (plugins, NewValue, _OldValue) ->
- NewValue;
- ({plugins, _}, 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 ->
- rebar_utils:tup_umerge(rebar_utils:tup_sort(NewValue)
- ,rebar_utils:tup_sort(OldValue))
- end;
- (_Key, NewValue, _OldValue) ->
- NewValue
- end, NewOpts, OldOpts).
-
%% ====================================================================
%% Internal functions
%% ====================================================================
@@ -759,29 +634,6 @@ find_resource_module(Type, Resources) ->
{ok, Module}
end.
-%%
-%% Filter a list of erl_opts platform_define options such that only
-%% those which match the provided architecture regex are returned.
-%%
-filter_defines([], Acc) ->
- lists:reverse(Acc);
-filter_defines([{platform_define, ArchRegex, Key} | Rest], Acc) ->
- case rebar_utils:is_arch(ArchRegex) of
- true ->
- filter_defines(Rest, [{d, Key} | Acc]);
- false ->
- filter_defines(Rest, Acc)
- end;
-filter_defines([{platform_define, ArchRegex, Key, Value} | Rest], Acc) ->
- case rebar_utils:is_arch(ArchRegex) of
- true ->
- filter_defines(Rest, [{d, Key, Value} | Acc]);
- false ->
- filter_defines(Rest, Acc)
- end;
-filter_defines([Opt | Rest], Acc) ->
- filter_defines(Rest, [Opt | Acc]).
-
%% @doc ident to the level specified
-spec indent(non_neg_integer()) -> iolist().
indent(Amount) when erlang:is_integer(Amount) ->