mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Adding fail_on_warning support
This commit is contained in:
parent
d6600ab506
commit
417ff3ad76
1 changed files with 26 additions and 8 deletions
|
@ -111,11 +111,19 @@ compile_opts(Config, Key) ->
|
||||||
rebar_config:get_list(Config, Key, []).
|
rebar_config:get_list(Config, Key, []).
|
||||||
|
|
||||||
compile_erl(Source, Config) ->
|
compile_erl(Source, Config) ->
|
||||||
Opts = [{i, "include"}, {outdir, "ebin"}, report] ++ compile_opts(Config, erl_opts),
|
Opts = [{i, "include"}, {outdir, "ebin"}, report, return] ++ compile_opts(Config, erl_opts),
|
||||||
case compile:file(Source, Opts) of
|
case compile:file(Source, Opts) of
|
||||||
{ok, _} ->
|
{ok, _, []} ->
|
||||||
ok;
|
ok;
|
||||||
error ->
|
{ok, _, _Warnings} ->
|
||||||
|
%% We got at least one warning -- if fail_on_warning is in options, fail
|
||||||
|
case lists:member(fail_on_warning, Opts) of
|
||||||
|
true ->
|
||||||
|
?FAIL;
|
||||||
|
false ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
?FAIL
|
?FAIL
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -141,6 +149,10 @@ compile_queue(Pids, Targets, Config, CompileFn) ->
|
||||||
Worker ! {compile, Src, Target, Config, CompileFn},
|
Worker ! {compile, Src, Target, Config, CompileFn},
|
||||||
compile_queue(Pids, Rest, Config, CompileFn)
|
compile_queue(Pids, Rest, Config, CompileFn)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{fail, Error} ->
|
||||||
|
?DEBUG("Worker compilation failed: ~p\n", [Error]),
|
||||||
|
?FAIL;
|
||||||
|
|
||||||
{compiled, Source} ->
|
{compiled, Source} ->
|
||||||
?CONSOLE("Compiled ~s\n", [Source]),
|
?CONSOLE("Compiled ~s\n", [Source]),
|
||||||
|
@ -162,13 +174,19 @@ compile_worker(QueuePid) ->
|
||||||
{compile, Src, Target, Config, CompileFn} ->
|
{compile, Src, Target, Config, CompileFn} ->
|
||||||
case needs_compile(Src, Target) of
|
case needs_compile(Src, Target) of
|
||||||
true ->
|
true ->
|
||||||
CompileFn(Src, Config),
|
case catch(CompileFn(Src, Config)) of
|
||||||
QueuePid ! {compiled, Src};
|
ok ->
|
||||||
|
QueuePid ! {compiled, Src},
|
||||||
|
compile_worker(QueuePid);
|
||||||
|
Error ->
|
||||||
|
QueuePid ! {fail, Error},
|
||||||
|
ok
|
||||||
|
end;
|
||||||
false ->
|
false ->
|
||||||
?INFO("Skipping ~s\n", [Src]),
|
?INFO("Skipping ~s\n", [Src]),
|
||||||
ok
|
compile_worker(QueuePid)
|
||||||
end,
|
end;
|
||||||
compile_worker(QueuePid);
|
|
||||||
empty ->
|
empty ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in a new issue