diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl index b4308e5..220cbd5 100644 --- a/src/rebar_base_compiler.erl +++ b/src/rebar_base_compiler.erl @@ -116,23 +116,29 @@ compile(Source, Config, CompileFn) -> ok -> ok; skipped -> - skipped + skipped; + Error -> + Error end. - compile_each([], _Config, _CompileFn) -> ok; compile_each([Source | Rest], Config, CompileFn) -> case compile(Source, Config, CompileFn) of ok -> ?CONSOLE("Compiled ~s\n", [Source]); + {ok, Warnings} -> + report(Warnings), + ?CONSOLE("Compiled ~s\n", [Source]); skipped -> - ?INFO("Skipped ~s\n", [Source]) + ?INFO("Skipped ~s\n", [Source]); + Error -> + maybe_report(Error), + ?DEBUG("Compilation failed: ~p\n", [Error]), + ?ABORT end, compile_each(Rest, Config, CompileFn). - - compile_queue([], []) -> ok; compile_queue(Pids, Targets) -> @@ -148,9 +154,15 @@ compile_queue(Pids, Targets) -> end; {fail, Error} -> + maybe_report(Error), ?DEBUG("Worker compilation failed: ~p\n", [Error]), ?ABORT; + {compiled, Source, Warnings} -> + report(Warnings), + ?CONSOLE("Compiled ~s\n", [Source]), + compile_queue(Pids, Targets); + {compiled, Source} -> ?CONSOLE("Compiled ~s\n", [Source]), compile_queue(Pids, Targets); @@ -174,6 +186,9 @@ compile_worker(QueuePid, Config, CompileFn) -> receive {compile, Source} -> case catch(compile(Source, Config, CompileFn)) of + {ok, Ws} -> + QueuePid ! {compiled, Source, Ws}, + compile_worker(QueuePid, Config, CompileFn); ok -> QueuePid ! {compiled, Source}, compile_worker(QueuePid, Config, CompileFn); @@ -189,3 +204,14 @@ compile_worker(QueuePid, Config, CompileFn) -> empty -> ok end. + +maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) -> + maybe_report(ErrorsAndWarnings); +maybe_report({error, Es, Ws}) -> + report(Es), + report(Ws); +maybe_report(_) -> + ok. + +report(Messages) -> + lists:foreach(fun(Msg) -> io:format("~s~n", [Msg]) end, Messages). diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 9abd233..99d3c38 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -119,17 +119,6 @@ process_dir(Dir, ParentConfig, Command, DirSet) -> DirSet; true -> - AbsDir = filename:absname(Dir), - ShouldPrintDir = not (is_skip_dir(Dir) - orelse processing_base_dir(Dir)), - - case ShouldPrintDir of - true -> - ?CONSOLE("==> Entering directory `~s'\n", [AbsDir]); - _ -> - ok - end, - ok = file:set_cwd(Dir), Config = maybe_load_local_config(Dir, ParentConfig), @@ -144,17 +133,8 @@ process_dir(Dir, ParentConfig, Command, DirSet) -> %% to process this dir. {ok, AvailModuleSets} = application:get_env(rebar, modules), ModuleSet = choose_module_set(AvailModuleSets, Dir), - Res = maybe_process_dir(ModuleSet, Config, CurrentCodePath, - Dir, Command, DirSet), - - case ShouldPrintDir of - true -> - ?CONSOLE("==> Leaving directory `~s'\n", [AbsDir]); - false -> - ok - end, - - Res + maybe_process_dir(ModuleSet, Config, CurrentCodePath, + Dir, Command, DirSet) end. maybe_process_dir({[], undefined}=ModuleSet, Config, CurrentCodePath, diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 30db023..acb8491 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -257,17 +257,32 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) -> case needs_compile(Source, Target, Hrls) of true -> Opts = [{outdir, filename:dirname(Target)}] ++ - ErlOpts ++ [{i, "include"}, report], + ErlOpts ++ [{i, "include"}, return], case compile:file(Source, Opts) of - {ok, _} -> + {ok, _Mod} -> ok; - _ -> - ?ABORT + {ok, _Mod, Ws} -> + {ok, format_errors(Source, "Warning: ", Ws)}; + {error, Es, Ws} -> + {error, format_errors(Source, Es), + format_errors(Source, "Warning: ", Ws)} end; false -> skipped 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(), Config::rebar_config:config()) -> 'ok'. compile_mib(Source, Target, Config) ->