Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup: rich compiler output in warnings #2795

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/rebar/src/rebar_base_compiler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
run/7,
run/8,
ok_tuple/2,
ok_tuple/4,
error_tuple/4,
error_tuple/5,
report/1,
Expand Down Expand Up @@ -133,6 +134,12 @@ run(Config, FirstFiles, SourceDir, SourceExt0, TargetDir, TargetExt,
ok_tuple(Source, Ws) ->
{ok, format_warnings(Source, Ws)}.

%% @doc Format good compiler results with warnings to work with
%% module internals. Assumes that warnings are not treated as errors.
-spec ok_tuple(file:filename(), [string()], rebar_dict(), [{_,_}]) -> {ok, [string()]}.
ok_tuple(Source, Ws, Config, Opts) ->
{ok, format_warnings(Source, Ws, Config, Opts)}.

%% @doc format error and warning strings for a given source file
%% according to user preferences.
-spec error_tuple(file:filename(), [Err], [Warn], rebar_dict() | [{_,_}]) ->
Expand Down
4 changes: 4 additions & 0 deletions apps/rebar/src/rebar_compiler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

needs_compile/3,
ok_tuple/2,
ok_tuple/4,
error_tuple/4,
error_tuple/5,
maybe_report/1,
Expand Down Expand Up @@ -128,6 +129,9 @@ needs_compile(Source, OutExt, Mappings) ->
ok_tuple(Source, Ws) ->
rebar_base_compiler:ok_tuple(Source, Ws).

ok_tuple(Source, Ws, Config, Opts) ->
rebar_base_compiler:ok_tuple(Source, Ws, Config, Opts).

error_tuple(Source, Es, Ws, Opts) ->
rebar_base_compiler:error_tuple(Source, Es, Ws, Opts).

Expand Down
4 changes: 2 additions & 2 deletions apps/rebar/src/rebar_compiler_erl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ compile(Source, [{_, OutDir}], Config, ErlOpts) ->
ok;
{ok, _Mod, Ws} ->
FormattedWs = format_error_sources(Ws, Config),
rebar_compiler:ok_tuple(Source, FormattedWs);
rebar_compiler:ok_tuple(Source, FormattedWs, Config, ErlOpts);
{error, Es, Ws} ->
error_tuple(Source, Es, Ws, Config, ErlOpts);
error ->
Expand All @@ -161,7 +161,7 @@ compile_and_track(Source, [{Ext, OutDir}], Config, ErlOpts) ->
{ok, [{Source, Target, AllOpts}]};
{ok, _Mod, Ws} ->
FormattedWs = format_error_sources(Ws, Config),
{ok, Warns} = rebar_compiler:ok_tuple(Source, FormattedWs),
{ok, Warns} = rebar_compiler:ok_tuple(Source, FormattedWs, Config, ErlOpts),
{ok, [{Source, Target, AllOpts}], Warns};
{error, Es, Ws} ->
error_tuple(Source, Es, Ws, Config, ErlOpts);
Expand Down
2 changes: 1 addition & 1 deletion apps/rebar/src/rebar_compiler_xrl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ compile(Source, [{_, _}], Config, Opts) ->
{ok, _} ->
ok;
{ok, _Mod, Ws} ->
rebar_compiler:ok_tuple(Source, Ws);
rebar_compiler:ok_tuple(Source, Ws, Config, Opts);
{error, Es, Ws} ->
rebar_compiler:error_tuple(Source, Es, Ws, Config, Opts)
end.
Expand Down
2 changes: 1 addition & 1 deletion apps/rebar/src/rebar_compiler_yrl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ compile(Source, [{_, OutDir}], Config, Opts0) ->
{ok, _} ->
ok;
{ok, _Mod, Ws} ->
rebar_compiler:ok_tuple(Source, Ws);
rebar_compiler:ok_tuple(Source, Ws, Config, AllOpts);
{error, Es, Ws} ->
rebar_compiler:error_tuple(Source, Es, Ws, Config, AllOpts)
end.
Expand Down