Bladeren bron

refactoring build loop

pull/3/head
Tristan Sloughter 10 jaren geleden
bovenliggende
commit
044cd78b44
1 gewijzigde bestanden met toevoegingen van 15 en 20 verwijderingen
  1. +15
    -20
      src/rebar_prv_compile.erl

+ 15
- 20
src/rebar_prv_compile.erl Bestand weergeven

@ -45,40 +45,35 @@ do(State) ->
%% Need to allow global config vars used on deps
%% Right now no way to differeniate and just give deps a new state
lists:foreach(fun(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
C = rebar_config:consult(AppDir),
S = rebar_state:new(rebar_state:new(), C, AppDir),
S1 = rebar_state:set(S, jobs, Jobs),
%% Legacy hook support
run_compile_hooks(AppDir, pre_hooks, S1),
build(S1, AppInfo),
run_compile_hooks(AppDir, post_hooks, S1)
end, Deps),
EmptyState = rebar_state:new(),
EmptyState1 = rebar_state:set(EmptyState, jobs, Jobs),
build_apps(EmptyState1, Deps),
%% Use the project State for building project apps
Cwd = rebar_utils:get_cwd(),
run_compile_hooks(Cwd, pre_hooks, State1),
%% Set hooks to empty so top-level hooks aren't run for each project app
State2 = rebar_state:set(rebar_state:set(State1, post_hooks, []), pre_hooks, []),
build_apps(State2, ProjectApps),
run_compile_hooks(Cwd, post_hooks, State1),
{ok, State1}.
-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
format_error(Reason, State) ->
{io_lib:format("~p", [Reason]), State}.
build_apps(State, Apps) ->
lists:foreach(fun(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
C = rebar_config:consult(AppDir),
S = rebar_state:new(State2, C, AppDir),
S = rebar_state:new(State, C, AppDir),
%% Legacy hook support
run_compile_hooks(AppDir, pre_hooks, S),
build(S, AppInfo),
run_compile_hooks(AppDir, post_hooks, S)
end, ProjectApps),
run_compile_hooks(Cwd, post_hooks, State1),
{ok, State1}.
-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
format_error(Reason, State) ->
{io_lib:format("~p", [Reason]), State}.
end, Apps).
build(State, AppInfo) ->
?INFO("Compiling ~s~n", [rebar_app_info:name(AppInfo)]),

Laden…
Annuleren
Opslaan