ソースを参照

set resources of state in state initialize functions

pull/389/head
Tristan Sloughter 10年前
コミット
bfd08c129d
2個のファイルの変更20行の追加15行の削除
  1. +5
    -7
      src/rebar3.erl
  2. +15
    -8
      src/rebar_state.erl

+ 5
- 7
src/rebar3.erl ファイルの表示

@ -127,19 +127,17 @@ run_aux(State, RawArgs) ->
filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)),
{ok, Providers} = application:get_env(rebar, providers),
{ok, Resources} = application:get_env(rebar, resources),
State4 = rebar_state:resources(State3, Resources),
State5 = rebar_plugins:install(State4),
State4 = rebar_plugins:install(State3),
%% Providers can modify profiles stored in opts, so set default after initializing providers
State6 = rebar_state:create_logic_providers(Providers, State5),
State7 = rebar_state:default(State6, rebar_state:opts(State6)),
State5 = rebar_state:create_logic_providers(Providers, State4),
State6 = rebar_state:default(State5, rebar_state:opts(State5)),
{Task, Args} = parse_args(RawArgs),
State8 = rebar_state:code_paths(State7, default, code:get_path()),
State7 = rebar_state:code_paths(State6, default, code:get_path()),
rebar_core:init_command(rebar_state:command_args(State8, Args), Task).
rebar_core:init_command(rebar_state:command_args(State7, Args), Task).
init_config() ->
%% Initialize logging system

+ 15
- 8
src/rebar_state.erl ファイルの表示

@ -69,25 +69,28 @@
-spec new() -> t().
new() ->
#state_t{dir = rebar_dir:get_cwd()}.
BaseState = base_state(),
BaseState#state_t{dir = rebar_dir:get_cwd()}.
-spec new(list()) -> t().
new(Config) when is_list(Config) ->
BaseState = base_state(),
Deps = proplists:get_value(deps, Config, []),
Opts = dict:from_list([{{deps, default}, Deps} | Config]),
#state_t { dir = rebar_dir:get_cwd(),
default = Opts,
opts = Opts }.
BaseState#state_t { dir = rebar_dir:get_cwd(),
default = Opts,
opts = Opts }.
-spec new(t() | atom(), list()) -> t().
new(Profile, Config) when is_atom(Profile)
, is_list(Config) ->
BaseState = base_state(),
Deps = proplists:get_value(deps, Config, []),
Opts = dict:from_list([{{deps, default}, Deps} | Config]),
#state_t { dir = rebar_dir:get_cwd(),
current_profiles = [Profile],
default = Opts,
opts = Opts };
BaseState#state_t { dir = rebar_dir:get_cwd(),
current_profiles = [Profile],
default = Opts,
opts = Opts };
new(ParentState=#state_t{}, Config) ->
%% Load terms from rebar.config, if it exists
Dir = rebar_dir:get_cwd(),
@ -113,6 +116,10 @@ new(ParentState, Config, Dir) ->
,opts=NewOpts
,default=NewOpts}.
base_state() ->
{ok, Resources} = application:get_env(rebar, resources),
#state_t{resources=Resources}.
get(State, Key) ->
{ok, Value} = dict:find(Key, State#state_t.opts),
Value.

読み込み中…
キャンセル
保存