mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 11:09:55 +00:00
commit
af91604053
1 changed files with 25 additions and 19 deletions
|
@ -49,7 +49,7 @@ run(Config, FirstFiles, RestFiles, CompileFn) ->
|
||||||
Jobs = rebar:get_jobs(Config),
|
Jobs = rebar:get_jobs(Config),
|
||||||
?DEBUG("Starting ~B compile worker(s)~n", [Jobs]),
|
?DEBUG("Starting ~B compile worker(s)~n", [Jobs]),
|
||||||
Pids = [spawn_monitor(F) || _I <- lists:seq(1,Jobs)],
|
Pids = [spawn_monitor(F) || _I <- lists:seq(1,Jobs)],
|
||||||
compile_queue(Pids, RestFiles)
|
compile_queue(Config, Pids, RestFiles)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
|
run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
|
||||||
|
@ -139,27 +139,31 @@ compile_each([Source | Rest], Config, CompileFn) ->
|
||||||
skipped ->
|
skipped ->
|
||||||
?INFO("Skipped ~s\n", [Source]);
|
?INFO("Skipped ~s\n", [Source]);
|
||||||
Error ->
|
Error ->
|
||||||
|
?CONSOLE("Compiling ~s failed:\n",
|
||||||
|
[maybe_absname(Config, Source)]),
|
||||||
maybe_report(Error),
|
maybe_report(Error),
|
||||||
?DEBUG("Compilation failed: ~p\n", [Error]),
|
?DEBUG("Compilation failed: ~p\n", [Error]),
|
||||||
?FAIL
|
?FAIL
|
||||||
end,
|
end,
|
||||||
compile_each(Rest, Config, CompileFn).
|
compile_each(Rest, Config, CompileFn).
|
||||||
|
|
||||||
compile_queue([], []) ->
|
compile_queue(_Config, [], []) ->
|
||||||
ok;
|
ok;
|
||||||
compile_queue(Pids, Targets) ->
|
compile_queue(Config, Pids, Targets) ->
|
||||||
receive
|
receive
|
||||||
{next, Worker} ->
|
{next, Worker} ->
|
||||||
case Targets of
|
case Targets of
|
||||||
[] ->
|
[] ->
|
||||||
Worker ! empty,
|
Worker ! empty,
|
||||||
compile_queue(Pids, Targets);
|
compile_queue(Config, Pids, Targets);
|
||||||
[Source | Rest] ->
|
[Source | Rest] ->
|
||||||
Worker ! {compile, Source},
|
Worker ! {compile, Source},
|
||||||
compile_queue(Pids, Rest)
|
compile_queue(Config, Pids, Rest)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{fail, Error} ->
|
{fail, {_, {source, Source}}=Error} ->
|
||||||
|
?CONSOLE("Compiling ~s failed:\n",
|
||||||
|
[maybe_absname(Config, Source)]),
|
||||||
maybe_report(Error),
|
maybe_report(Error),
|
||||||
?DEBUG("Worker compilation failed: ~p\n", [Error]),
|
?DEBUG("Worker compilation failed: ~p\n", [Error]),
|
||||||
?FAIL;
|
?FAIL;
|
||||||
|
@ -167,20 +171,20 @@ compile_queue(Pids, Targets) ->
|
||||||
{compiled, Source, Warnings} ->
|
{compiled, Source, Warnings} ->
|
||||||
report(Warnings),
|
report(Warnings),
|
||||||
?CONSOLE("Compiled ~s\n", [Source]),
|
?CONSOLE("Compiled ~s\n", [Source]),
|
||||||
compile_queue(Pids, Targets);
|
compile_queue(Config, Pids, Targets);
|
||||||
|
|
||||||
{compiled, Source} ->
|
{compiled, Source} ->
|
||||||
?CONSOLE("Compiled ~s\n", [Source]),
|
?CONSOLE("Compiled ~s\n", [Source]),
|
||||||
compile_queue(Pids, Targets);
|
compile_queue(Config, Pids, Targets);
|
||||||
|
|
||||||
{skipped, Source} ->
|
{skipped, Source} ->
|
||||||
?INFO("Skipped ~s\n", [Source]),
|
?INFO("Skipped ~s\n", [Source]),
|
||||||
compile_queue(Pids, Targets);
|
compile_queue(Config, Pids, Targets);
|
||||||
|
|
||||||
{'DOWN', Mref, _, Pid, normal} ->
|
{'DOWN', Mref, _, Pid, normal} ->
|
||||||
?DEBUG("Worker exited cleanly\n", []),
|
?DEBUG("Worker exited cleanly\n", []),
|
||||||
Pids2 = lists:delete({Pid, Mref}, Pids),
|
Pids2 = lists:delete({Pid, Mref}, Pids),
|
||||||
compile_queue(Pids2, Targets);
|
compile_queue(Config, Pids2, Targets);
|
||||||
|
|
||||||
{'DOWN', _Mref, _, _Pid, Info} ->
|
{'DOWN', _Mref, _, _Pid, Info} ->
|
||||||
?DEBUG("Worker failed: ~p\n", [Info]),
|
?DEBUG("Worker failed: ~p\n", [Info]),
|
||||||
|
@ -202,8 +206,7 @@ compile_worker(QueuePid, Config, CompileFn) ->
|
||||||
QueuePid ! {skipped, Source},
|
QueuePid ! {skipped, Source},
|
||||||
compile_worker(QueuePid, Config, CompileFn);
|
compile_worker(QueuePid, Config, CompileFn);
|
||||||
Error ->
|
Error ->
|
||||||
QueuePid ! {fail, [{error, Error},
|
QueuePid ! {fail, {{error, Error}, {source, Source}}},
|
||||||
{source, Source}]},
|
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -224,7 +227,7 @@ format_warnings(Config, Source, Warnings, Opts) ->
|
||||||
end,
|
end,
|
||||||
format_errors(Config, Source, Prefix, Warnings).
|
format_errors(Config, Source, Prefix, Warnings).
|
||||||
|
|
||||||
maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) ->
|
maybe_report({{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}}) ->
|
||||||
maybe_report(ErrorsAndWarnings);
|
maybe_report(ErrorsAndWarnings);
|
||||||
maybe_report([{error, E}, {source, S}]) ->
|
maybe_report([{error, E}, {source, S}]) ->
|
||||||
report(["unexpected error compiling " ++ S, io_lib:fwrite("~n~p~n", [E])]);
|
report(["unexpected error compiling " ++ S, io_lib:fwrite("~n~p~n", [E])]);
|
||||||
|
@ -239,12 +242,7 @@ report(Messages) ->
|
||||||
|
|
||||||
format_errors(Config, _MainSource, Extra, Errors) ->
|
format_errors(Config, _MainSource, Extra, Errors) ->
|
||||||
[begin
|
[begin
|
||||||
AbsSource = case rebar_utils:processing_base_dir(Config) of
|
AbsSource = maybe_absname(Config, Source),
|
||||||
true ->
|
|
||||||
Source;
|
|
||||||
false ->
|
|
||||||
filename:absname(Source)
|
|
||||||
end,
|
|
||||||
[format_error(AbsSource, Extra, Desc) || Desc <- Descs]
|
[format_error(AbsSource, Extra, Desc) || Desc <- Descs]
|
||||||
end
|
end
|
||||||
|| {Source, Descs} <- Errors].
|
|| {Source, Descs} <- Errors].
|
||||||
|
@ -258,3 +256,11 @@ format_error(AbsSource, Extra, {Line, Mod, Desc}) ->
|
||||||
format_error(AbsSource, Extra, {Mod, Desc}) ->
|
format_error(AbsSource, Extra, {Mod, Desc}) ->
|
||||||
ErrorDesc = Mod:format_error(Desc),
|
ErrorDesc = Mod:format_error(Desc),
|
||||||
?FMT("~s: ~s~s~n", [AbsSource, Extra, ErrorDesc]).
|
?FMT("~s: ~s~s~n", [AbsSource, Extra, ErrorDesc]).
|
||||||
|
|
||||||
|
maybe_absname(Config, Filename) ->
|
||||||
|
case rebar_utils:processing_base_dir(Config) of
|
||||||
|
true ->
|
||||||
|
Filename;
|
||||||
|
false ->
|
||||||
|
filename:absname(Filename)
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in a new issue