Browse Source

only apply profiles to default

pull/31/head
Tristan Sloughter 10 years ago
parent
commit
3abb122b35
2 changed files with 15 additions and 9 deletions
  1. +1
    -2
      src/rebar.app.src
  2. +14
    -7
      src/rebar_state.erl

+ 1
- 2
src/rebar.app.src View File

@ -41,7 +41,6 @@
rebar_prv_release, rebar_prv_release,
rebar_prv_version, rebar_prv_version,
rebar_prv_common_test, rebar_prv_common_test,
rebar_prv_help,
rebar_prv_test_deps]}
rebar_prv_help]}
]} ]}
]}. ]}.

+ 14
- 7
src/rebar_state.erl View File

@ -29,6 +29,7 @@
-record(state_t, {dir :: file:name(), -record(state_t, {dir :: file:name(),
opts = dict:new() :: rebar_dict(), opts = dict:new() :: rebar_dict(),
default = dict:new() :: rebar_dict(),
lock = [], lock = [],
current_profile = default :: atom(), current_profile = default :: atom(),
@ -51,15 +52,19 @@ new() ->
-spec new(list()) -> t(). -spec new(list()) -> t().
new(Config) when is_list(Config) -> new(Config) when is_list(Config) ->
Opts = dict:from_list(Config),
#state_t { dir = rebar_utils:get_cwd(), #state_t { dir = rebar_utils:get_cwd(),
opts = dict:from_list(Config) }.
default = Opts,
opts = Opts }.
-spec new(t() | atom(), list()) -> t(). -spec new(t() | atom(), list()) -> t().
new(Profile, Config) when is_atom(Profile) new(Profile, Config) when is_atom(Profile)
, is_list(Config) -> , is_list(Config) ->
Opts = dict:from_list(Config),
#state_t { dir = rebar_utils:get_cwd(), #state_t { dir = rebar_utils:get_cwd(),
current_profile = Profile, current_profile = Profile,
opts = dict:from_list(Config) };
default = Opts,
opts = Opts };
new(ParentState=#state_t{}, Config) -> new(ParentState=#state_t{}, Config) ->
%% Load terms from rebar.config, if it exists %% Load terms from rebar.config, if it exists
Dir = rebar_utils:get_cwd(), Dir = rebar_utils:get_cwd(),
@ -74,13 +79,14 @@ new(ParentState, Config, Dir) ->
_ -> _ ->
dict:from_list(Config) dict:from_list(Config)
end, end,
NewOpts = dict:merge(fun(_Key, Value1, _Value2) ->
Value1
end, LocalOpts, Opts),
ProviderModules = [], ProviderModules = [],
create_logic_providers(ProviderModules create_logic_providers(ProviderModules
,ParentState#state_t{dir=Dir ,ParentState#state_t{dir=Dir
,opts=dict:merge(fun(_Key, Value1, _Value2) ->
Value1
end, LocalOpts, Opts)}).
,opts=NewOpts
,default=NewOpts}).
get(State, Key) -> get(State, Key) ->
{ok, Value} = dict:find(Key, State#state_t.opts), {ok, Value} = dict:find(Key, State#state_t.opts),
@ -122,7 +128,8 @@ command_parsed_args(#state_t{command_parsed_args=CmdArgs}) ->
command_parsed_args(State, CmdArgs) -> command_parsed_args(State, CmdArgs) ->
State#state_t{command_parsed_args=CmdArgs}. State#state_t{command_parsed_args=CmdArgs}.
apply_profile(State=#state_t{opts=Opts}, Profile) ->
%% Only apply profiles to the default profile
apply_profile(State=#state_t{default=Opts}, Profile) ->
ConfigProfiles = rebar_state:get(State, profiles, []), ConfigProfiles = rebar_state:get(State, profiles, []),
Deps = rebar_state:get(State, deps, []), Deps = rebar_state:get(State, deps, []),
Opts1 = dict:store({deps, default}, Deps, dict:erase(deps, Opts)), Opts1 = dict:store({deps, default}, Deps, dict:erase(deps, Opts)),

Loading…
Cancel
Save