summaryrefslogtreecommitdiff
path: root/src/rebar_port_compiler.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_port_compiler.erl')
-rw-r--r--src/rebar_port_compiler.erl23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 1f935de..0ccabc8 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -214,16 +214,30 @@ compile_each([Source | Rest], Type, Env, NewBins) ->
Bin = replace_extension(Source, Ext, ".o"),
case needs_compile(Source, Bin) of
true ->
- ?CONSOLE("Compiling ~s\n", [Source]),
Template = select_compile_template(Type, compiler(Ext)),
- rebar_utils:sh(expand_command(Template, Env, Source, Bin),
- [{env, Env}]),
+ Cmd = expand_command(Template, Env, Source, Bin),
+ ShOpts = [{env, Env}, return_on_error, {use_stdout, false}],
+ exec_compiler(Source, Cmd, ShOpts),
compile_each(Rest, Type, Env, [Bin | NewBins]);
false ->
?INFO("Skipping ~s\n", [Source]),
compile_each(Rest, Type, Env, NewBins)
end.
+exec_compiler(Source, Cmd, ShOpts) ->
+ case rebar_utils:sh(Cmd, ShOpts) of
+ {error, {_RC, RawError}} ->
+ AbsSource = filename:absname(Source),
+ ?CONSOLE("Compiling ~s\n", [AbsSource]),
+ Error = re:replace(RawError, Source, AbsSource,
+ [{return, list}, global]),
+ ?CONSOLE("~s", [Error]),
+ ?ABORT;
+ {ok, Output} ->
+ ?CONSOLE("Compiling ~s\n", [Source]),
+ ?CONSOLE("~s", [Output])
+ end.
+
needs_compile(Source, Bin) ->
%% TODO: Generate depends using gcc -MM so we can also
%% check for include changes
@@ -473,8 +487,7 @@ expand_keys_in_value([Key | Rest], Value, Vars) ->
expand_command(TmplName, Env, InFiles, OutFile) ->
Cmd0 = proplists:get_value(TmplName, Env),
Cmd1 = rebar_utils:expand_env_variable(Cmd0, "PORT_IN_FILES", InFiles),
- Cmd2 = rebar_utils:expand_env_variable(Cmd1, "PORT_OUT_FILE", OutFile),
- re:replace(Cmd2, "\\\$\\w+|\\\${\\w+}", "", [global, {return, list}]).
+ rebar_utils:expand_env_variable(Cmd1, "PORT_OUT_FILE", OutFile).
%%
%% Given a string, determine if it is expandable