summaryrefslogtreecommitdiff
path: root/src/rebar_prv_compile.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_prv_compile.erl')
-rw-r--r--src/rebar_prv_compile.erl44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 073394c..c4cca16 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -6,7 +6,7 @@
do/1,
format_error/1]).
--export([build/2]).
+-export([compile/2]).
-include("rebar.hrl").
@@ -55,34 +55,36 @@ do(State) ->
%% Use the project State for building project apps
%% 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),
+ ProjectApps1 = build_apps(State2, ProjectApps),
rebar_hooks:run_compile_hooks(Cwd, post_hooks, compile, State1),
- {ok, State1}.
+ {ok, rebar_state:project_apps(State1, ProjectApps1)}.
-spec format_error(any()) -> iolist().
format_error(Reason) ->
io_lib:format("~p", [Reason]).
build_apps(State, 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,
-
- %% Legacy hook support
- rebar_hooks:run_compile_hooks(AppDir, pre_hooks, compile, S),
- build(S, AppInfo),
- rebar_hooks:run_compile_hooks(AppDir, post_hooks, compile, S),
- true = code:add_patha(filename:join(AppDir, "ebin"))
- end, Apps).
-
-build(State, AppInfo) ->
+ [build_app(State, AppInfo) || AppInfo <- Apps].
+
+build_app(State, 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,
+
+ %% Legacy hook support
+ rebar_hooks:run_compile_hooks(AppDir, pre_hooks, compile, S),
+ AppInfo1 = compile(S, AppInfo),
+ rebar_hooks:run_compile_hooks(AppDir, post_hooks, compile, S),
+ true = code:add_patha(filename:join(AppDir, "ebin")),
+ AppInfo1.
+
+compile(State, AppInfo) ->
?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]),
rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo))),
case rebar_otp_app:compile(State, AppInfo) of