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.erl47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl
index 7d1fb22..63e408b 100644
--- a/src/rebar_base_compiler.erl
+++ b/src/rebar_base_compiler.erl
@@ -29,8 +29,7 @@
-include("rebar.hrl").
-export([run/4, run/7, run/8,
- ok_tuple/2, error_tuple/4]).
-
+ ok_tuple/3, error_tuple/5]).
%% ===================================================================
%% Public API
@@ -47,7 +46,7 @@ run(Config, FirstFiles, RestFiles, CompileFn) ->
_ ->
Self = self(),
F = fun() -> compile_worker(Self, Config, CompileFn) end,
- Jobs = rebar_config:get_jobs(),
+ Jobs = rebar:get_jobs(Config),
?DEBUG("Starting ~B compile worker(s)~n", [Jobs]),
Pids = [spawn_monitor(F) || _I <- lists:seq(1,Jobs)],
compile_queue(Pids, RestFiles)
@@ -80,11 +79,12 @@ run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
simple_compile_wrapper(S, Target, Compile3Fn, C, CheckLastMod)
end).
-ok_tuple(Source, Ws) ->
- {ok, format_warnings(Source, Ws)}.
+ok_tuple(Config, Source, Ws) ->
+ {ok, format_warnings(Config, Source, Ws)}.
-error_tuple(Source, Es, Ws, Opts) ->
- {error, format_errors(Source, Es), format_warnings(Source, Ws, Opts)}.
+error_tuple(Config, Source, Es, Ws, Opts) ->
+ {error, format_errors(Config, Source, Es),
+ format_warnings(Config, Source, Ws, Opts)}.
%% ===================================================================
%% Internal functions
@@ -141,7 +141,7 @@ compile_each([Source | Rest], Config, CompileFn) ->
Error ->
maybe_report(Error),
?DEBUG("Compilation failed: ~p\n", [Error]),
- ?ABORT
+ ?FAIL
end,
compile_each(Rest, Config, CompileFn).
@@ -162,7 +162,7 @@ compile_queue(Pids, Targets) ->
{fail, Error} ->
maybe_report(Error),
?DEBUG("Worker compilation failed: ~p\n", [Error]),
- ?ABORT;
+ ?FAIL;
{compiled, Source, Warnings} ->
report(Warnings),
@@ -184,7 +184,7 @@ compile_queue(Pids, Targets) ->
{'DOWN', _Mref, _, _Pid, Info} ->
?DEBUG("Worker failed: ~p\n", [Info]),
- ?ABORT
+ ?FAIL
end.
compile_worker(QueuePid, Config, CompileFn) ->
@@ -211,18 +211,18 @@ compile_worker(QueuePid, Config, CompileFn) ->
ok
end.
-format_errors(Source, Errors) ->
- format_errors(Source, "", Errors).
+format_errors(Config, Source, Errors) ->
+ format_errors(Config, Source, "", Errors).
-format_warnings(Source, Warnings) ->
- format_warnings(Source, Warnings, []).
+format_warnings(Config, Source, Warnings) ->
+ format_warnings(Config, Source, Warnings, []).
-format_warnings(Source, Warnings, Opts) ->
+format_warnings(Config, Source, Warnings, Opts) ->
Prefix = case lists:member(warnings_as_errors, Opts) of
true -> "";
false -> "Warning: "
end,
- format_errors(Source, Prefix, Warnings).
+ format_errors(Config, Source, Prefix, Warnings).
maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) ->
maybe_report(ErrorsAndWarnings);
@@ -235,10 +235,17 @@ maybe_report(_) ->
report(Messages) ->
lists:foreach(fun(Msg) -> io:format("~s", [Msg]) end, Messages).
-format_errors(Source, Extra, Errors) ->
- AbsSource = filename:absname(Source),
- [[format_error(AbsSource, Extra, Desc) || Desc <- Descs]
- || {_, Descs} <- Errors].
+format_errors(Config, _MainSource, Extra, Errors) ->
+ [begin
+ AbsSource = case rebar_utils:processing_base_dir(Config) of
+ true ->
+ Source;
+ false ->
+ filename:absname(Source)
+ end,
+ [format_error(AbsSource, Extra, Desc) || Desc <- Descs]
+ end
+ || {Source, Descs} <- Errors].
format_error(AbsSource, Extra, {{Line, Column}, Mod, Desc}) ->
ErrorDesc = Mod:format_error(Desc),