summaryrefslogtreecommitdiff
path: root/src/rebar_base_compiler.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_base_compiler.erl')
-rw-r--r--src/rebar_base_compiler.erl36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl
index b4308e5..220cbd5 100644
--- a/src/rebar_base_compiler.erl
+++ b/src/rebar_base_compiler.erl
@@ -116,23 +116,29 @@ compile(Source, Config, CompileFn) ->
ok ->
ok;
skipped ->
- skipped
+ skipped;
+ Error ->
+ Error
end.
-
compile_each([], _Config, _CompileFn) ->
ok;
compile_each([Source | Rest], Config, CompileFn) ->
case compile(Source, Config, CompileFn) of
ok ->
?CONSOLE("Compiled ~s\n", [Source]);
+ {ok, Warnings} ->
+ report(Warnings),
+ ?CONSOLE("Compiled ~s\n", [Source]);
skipped ->
- ?INFO("Skipped ~s\n", [Source])
+ ?INFO("Skipped ~s\n", [Source]);
+ Error ->
+ maybe_report(Error),
+ ?DEBUG("Compilation failed: ~p\n", [Error]),
+ ?ABORT
end,
compile_each(Rest, Config, CompileFn).
-
-
compile_queue([], []) ->
ok;
compile_queue(Pids, Targets) ->
@@ -148,9 +154,15 @@ compile_queue(Pids, Targets) ->
end;
{fail, Error} ->
+ maybe_report(Error),
?DEBUG("Worker compilation failed: ~p\n", [Error]),
?ABORT;
+ {compiled, Source, Warnings} ->
+ report(Warnings),
+ ?CONSOLE("Compiled ~s\n", [Source]),
+ compile_queue(Pids, Targets);
+
{compiled, Source} ->
?CONSOLE("Compiled ~s\n", [Source]),
compile_queue(Pids, Targets);
@@ -174,6 +186,9 @@ compile_worker(QueuePid, Config, CompileFn) ->
receive
{compile, Source} ->
case catch(compile(Source, Config, CompileFn)) of
+ {ok, Ws} ->
+ QueuePid ! {compiled, Source, Ws},
+ compile_worker(QueuePid, Config, CompileFn);
ok ->
QueuePid ! {compiled, Source},
compile_worker(QueuePid, Config, CompileFn);
@@ -189,3 +204,14 @@ compile_worker(QueuePid, Config, CompileFn) ->
empty ->
ok
end.
+
+maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) ->
+ maybe_report(ErrorsAndWarnings);
+maybe_report({error, Es, Ws}) ->
+ report(Es),
+ report(Ws);
+maybe_report(_) ->
+ ok.
+
+report(Messages) ->
+ lists:foreach(fun(Msg) -> io:format("~s~n", [Msg]) end, Messages).