summaryrefslogtreecommitdiff
path: root/src/rebar_state.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_state.erl')
-rw-r--r--src/rebar_state.erl42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 657c7d2..50bcfdb 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -27,6 +27,9 @@
deps_names/1,
+ overrides/1, overrides/2,
+ apply_overrides/2,
+
prepend_hook/3, append_hook/3, hooks/2,
providers/1, providers/2, add_provider/2]).
@@ -49,6 +52,7 @@
deps_to_build = [] :: [rebar_app_into:t()],
all_deps = [] :: [rebar_app_into:t()],
+ overrides = [],
providers = []}).
-export_type([t/0]).
@@ -86,7 +90,8 @@ new(ParentState, Config, Dir) ->
Opts = ParentState#state_t.opts,
LocalOpts = case rebar_config:consult_file(filename:join(Dir, ?LOCK_FILE)) of
[D] ->
- dict:from_list([{locks, D}, {{deps, default}, D} | Config]);
+ LockedDeps = [X || X <- D, element(3, X) =:= 0],
+ dict:from_list([{{locks, default}, LockedDeps}, {{deps, default}, D} | Config]);
_ ->
D = proplists:get_value(deps, Config, []),
dict:from_list([{{deps, default}, D} | Config])
@@ -150,6 +155,35 @@ command_parsed_args(#state_t{command_parsed_args=CmdArgs}) ->
command_parsed_args(State, CmdArgs) ->
State#state_t{command_parsed_args=CmdArgs}.
+apply_overrides(State=#state_t{overrides=Overrides}, AppName) ->
+ Name = binary_to_atom(AppName, utf8),
+
+ %% Inefficient. We want the order we get here though.
+ State1 = lists:foldl(fun({override, O}, StateAcc) ->
+ lists:foldl(fun({Key, Value}, StateAcc1) ->
+ rebar_state:set(StateAcc1, Key, Value)
+ end, StateAcc, O);
+ (_, StateAcc) ->
+ StateAcc
+ end, State, Overrides),
+
+ State2 = lists:foldl(fun({override, N, O}, StateAcc) when N =:= Name ->
+ lists:foldl(fun({Key, Value}, StateAcc1) ->
+ rebar_state:set(StateAcc1, Key, Value)
+ end, StateAcc, O);
+ (_, StateAcc) ->
+ StateAcc
+ end, State1, Overrides),
+
+ lists:foldl(fun({add, N, O}, StateAcc) when N =:= Name ->
+ lists:foldl(fun({Key, Value}, StateAcc1) ->
+ OldValue = rebar_state:get(StateAcc1, Key, []),
+ rebar_state:set(StateAcc1, Key, Value++OldValue)
+ end, StateAcc, O);
+ (_, StateAcc) ->
+ StateAcc
+ end, State2, Overrides).
+
apply_profiles(State, Profile) when not is_list(Profile) ->
apply_profiles(State, [Profile]);
apply_profiles(State, [default]) ->
@@ -200,6 +234,12 @@ deps_names(State) ->
Deps = rebar_state:get(State, deps, []),
deps_names(Deps).
+overrides(#state_t{overrides=Overrides}) ->
+ Overrides.
+
+overrides(State=#state_t{}, Overrides) ->
+ State#state_t{overrides=Overrides}.
+
project_apps(#state_t{project_apps=Apps}) ->
Apps.