Ver a proveniência

Merge pull request #472 from tsloughter/refactor_hooks

move handling of undefined app state to function
pull/461/head
Tristan Sloughter há 10 anos
ascendente
cometimento
d9bad34506
4 ficheiros alterados com 12 adições e 25 eliminações
  1. +9
    -0
      src/rebar_app_info.erl
  2. +1
    -8
      src/rebar_prv_clean.erl
  3. +1
    -9
      src/rebar_prv_compile.erl
  4. +1
    -8
      src/rebar_prv_eunit.erl

+ 9
- 0
src/rebar_app_info.erl Ver ficheiro

@ -34,6 +34,7 @@
source/2,
state/1,
state/2,
state_or_new/2,
is_lock/1,
is_lock/2,
is_checkout/1,
@ -260,6 +261,14 @@ state(AppInfo=#app_info_t{}, State) ->
state(#app_info_t{state=State}) ->
State.
-spec state_or_new(rebar_state:t(), t()) -> rebar_state:t().
state_or_new(State, AppInfo=#app_info_t{state=undefined}) ->
AppDir = dir(AppInfo),
C = rebar_config:consult(AppDir),
rebar_state:new(State, C, AppDir);
state_or_new(_State, #app_info_t{state=State}) ->
State.
-spec is_lock(t(), boolean()) -> t().
is_lock(AppInfo=#app_info_t{}, IsLock) ->
AppInfo#app_info_t{is_lock=IsLock}.

+ 1
- 8
src/rebar_prv_clean.erl Ver ficheiro

@ -67,16 +67,9 @@ format_error(Reason) ->
clean_apps(State, Providers, Apps) ->
lists:foreach(fun(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
S = case rebar_app_info:state(AppInfo) of
undefined ->
C = rebar_config:consult(AppDir),
rebar_state:new(State, C, AppDir);
AppState ->
AppState
end,
S = rebar_app_info:state_or_new(State, AppInfo),
?INFO("Cleaning out ~s...", [rebar_app_info:name(AppInfo)]),
%% Legacy hook support
rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, S),
rebar_erlc_compiler:clean(State, rebar_app_info:out_dir(AppInfo)),
rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, S)

+ 1
- 9
src/rebar_prv_compile.erl Ver ficheiro

@ -71,17 +71,9 @@ build_apps(State, Providers, Apps) ->
build_app(State, Providers, AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
OutDir = rebar_app_info:out_dir(AppInfo),
copy_app_dirs(State, AppDir, OutDir),
S = case rebar_app_info:state(AppInfo) of
undefined ->
C = rebar_config:consult(AppDir),
rebar_state:new(State, C, AppDir);
AppState ->
AppState
end,
S = rebar_app_info:state_or_new(State, AppInfo),
compile(S, Providers, AppInfo).
compile(State, Providers, AppInfo) ->

+ 1
- 8
src/rebar_prv_eunit.erl Ver ficheiro

@ -134,14 +134,7 @@ resolve_suites(State, Apps, RawOpts) ->
compile_tests(State, TestApps, Suites, RawOpts) ->
F = fun(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
S = case rebar_app_info:state(AppInfo) of
undefined ->
C = rebar_config:consult(AppDir),
rebar_state:new(State, C, AppDir);
AppState ->
AppState
end,
S = rebar_app_info:state_or_new(State, AppInfo),
ok = rebar_erlc_compiler:compile(replace_src_dirs(S),
ec_cnv:to_list(rebar_app_info:out_dir(AppInfo)))
end,

Carregando…
Cancelar
Guardar