summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2009-12-14 09:27:47 -0500
committerDave Smith <dizzyd@dizzyd.com>2009-12-14 09:27:47 -0500
commit417ff3ad7688723297ae210b50c111be8200242c (patch)
treec71e6b2b1efc1c11cd1cf5166c4a62c0e40d49ce
parentd6600ab506276f3a5aa65b0aaafc62bc7826c213 (diff)
Adding fail_on_warning support
-rw-r--r--src/rebar_erlc_compiler.erl34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 12e20e9..80371ad 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -111,11 +111,19 @@ compile_opts(Config, Key) ->
rebar_config:get_list(Config, Key, []).
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
- {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
end.
@@ -141,6 +149,10 @@ compile_queue(Pids, Targets, Config, CompileFn) ->
Worker ! {compile, Src, Target, Config, CompileFn},
compile_queue(Pids, Rest, Config, CompileFn)
end;
+
+ {fail, Error} ->
+ ?DEBUG("Worker compilation failed: ~p\n", [Error]),
+ ?FAIL;
{compiled, Source} ->
?CONSOLE("Compiled ~s\n", [Source]),
@@ -162,13 +174,19 @@ compile_worker(QueuePid) ->
{compile, Src, Target, Config, CompileFn} ->
case needs_compile(Src, Target) of
true ->
- CompileFn(Src, Config),
- QueuePid ! {compiled, Src};
+ case catch(CompileFn(Src, Config)) of
+ ok ->
+ QueuePid ! {compiled, Src},
+ compile_worker(QueuePid);
+ Error ->
+ QueuePid ! {fail, Error},
+ ok
+ end;
false ->
?INFO("Skipping ~s\n", [Src]),
- ok
- end,
- compile_worker(QueuePid);
+ compile_worker(QueuePid)
+ end;
+
empty ->
ok
end.