mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Share format_errors/format_warnings functions
This commit is contained in:
parent
4e64e0c675
commit
dff60918cb
2 changed files with 22 additions and 19 deletions
|
@ -28,7 +28,8 @@
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
|
||||||
-export([run/4, run/7, run/8]).
|
-export([run/4, run/7, run/8,
|
||||||
|
format_errors/2, format_warnings/2]).
|
||||||
|
|
||||||
|
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
@ -79,6 +80,11 @@ run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
|
||||||
simple_compile_wrapper(S, Target, Compile3Fn, C, CheckLastMod)
|
simple_compile_wrapper(S, Target, Compile3Fn, C, CheckLastMod)
|
||||||
end).
|
end).
|
||||||
|
|
||||||
|
format_errors(Source, Errors) ->
|
||||||
|
format_errors(Source, "", Errors).
|
||||||
|
|
||||||
|
format_warnings(Source, Warnings) ->
|
||||||
|
format_errors(Source, "Warning: ", Warnings).
|
||||||
|
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
|
@ -215,3 +221,12 @@ maybe_report(_) ->
|
||||||
|
|
||||||
report(Messages) ->
|
report(Messages) ->
|
||||||
lists:foreach(fun(Msg) -> io:format("~s~n", [Msg]) end, Messages).
|
lists:foreach(fun(Msg) -> io:format("~s~n", [Msg]) end, Messages).
|
||||||
|
|
||||||
|
format_errors(Source, Extra, Errors) ->
|
||||||
|
AbsSource = filename:absname(Source),
|
||||||
|
[lists:append([format_error(AbsSource, Extra, Desc) || Desc <- Descs])
|
||||||
|
|| {_, Descs} <- Errors].
|
||||||
|
|
||||||
|
format_error(AbsSource, Extra, {Line, Mod, Desc}) ->
|
||||||
|
ErrorDesc = Mod:format_error(Desc),
|
||||||
|
?FMT("~s:~b: ~s~s", [AbsSource, Line, Extra, ErrorDesc]).
|
||||||
|
|
|
@ -262,27 +262,15 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
|
||||||
{ok, _Mod} ->
|
{ok, _Mod} ->
|
||||||
ok;
|
ok;
|
||||||
{ok, _Mod, Ws} ->
|
{ok, _Mod, Ws} ->
|
||||||
{ok, format_errors(Source, "Warning: ", Ws)};
|
{ok, rebar_base_compiler:format_warnings(Source, Ws)};
|
||||||
{error, Es, Ws} ->
|
{error, Es, Ws} ->
|
||||||
{error, format_errors(Source, Es),
|
{error, rebar_base_compiler:format_errors(Source, Es),
|
||||||
format_errors(Source, "Warning: ", Ws)}
|
rebar_base_compiler:format_warnings(Source, Ws)}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
skipped
|
skipped
|
||||||
end.
|
end.
|
||||||
|
|
||||||
format_errors(Source, Errors) ->
|
|
||||||
format_errors(Source, "", Errors).
|
|
||||||
|
|
||||||
format_errors(Source, Extra, Errors) ->
|
|
||||||
AbsSource = filename:absname(Source),
|
|
||||||
[lists:append([format_error(AbsSource, Extra, Desc) || Desc <- Descs])
|
|
||||||
|| {_, Descs} <- Errors].
|
|
||||||
|
|
||||||
format_error(AbsSource, Extra, {Line, Mod, Desc}) ->
|
|
||||||
ErrorDesc = Mod:format_error(Desc),
|
|
||||||
?FMT("~s:~b: ~s~s", [AbsSource, Line, Extra, ErrorDesc]).
|
|
||||||
|
|
||||||
-spec compile_mib(Source::file:filename(), Target::file:filename(),
|
-spec compile_mib(Source::file:filename(), Target::file:filename(),
|
||||||
Config::rebar_config:config()) -> 'ok'.
|
Config::rebar_config:config()) -> 'ok'.
|
||||||
compile_mib(Source, Target, Config) ->
|
compile_mib(Source, Target, Config) ->
|
||||||
|
@ -322,10 +310,10 @@ compile_xrl_yrl(Source, Target, Opts, Mod) ->
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
ok;
|
ok;
|
||||||
{ok, _Mod, Ws} ->
|
{ok, _Mod, Ws} ->
|
||||||
{ok, format_errors(Source, "Warning: ", Ws)};
|
{ok, rebar_base_compiler:format_warnings(Source, Ws)};
|
||||||
{error, Es, Ws} ->
|
{error, Es, Ws} ->
|
||||||
{error, format_errors(Source, Es),
|
{error, rebar_base_compiler:format_errors(Source, Es),
|
||||||
format_errors(Source, "Warning: ", Ws)}
|
rebar_base_compiler:format_warnings(Source, Ws)}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
skipped
|
skipped
|
||||||
|
|
Loading…
Reference in a new issue