summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_port_compiler.erl20
-rw-r--r--src/rebar_utils.erl1
2 files changed, 12 insertions, 9 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 1119e4e..9679c80 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -216,15 +216,15 @@ replace_extension(File, OldExt, NewExt) ->
%%
compile_sources(Config, Specs, SharedEnv) ->
- {Res, Db} =
+ {NewBins, Db} =
lists:foldl(
- fun(#spec{sources=Sources, type=Type, opts=Opts}, NewBins) ->
+ fun(#spec{sources=Sources, type=Type, opts=Opts}, Acc) ->
Env = proplists:get_value(env, Opts, SharedEnv),
- compile_each(Config, Sources, Type, Env, {NewBins, []})
- end, [], Specs),
+ compile_each(Config, Sources, Type, Env, Acc)
+ end, {[], []}, Specs),
%% Rewrite clang compile commands database file only if something
%% was compiled.
- case Res of
+ case NewBins of
[] ->
ok;
_ ->
@@ -234,7 +234,7 @@ compile_sources(Config, Specs, SharedEnv) ->
ok = io:fwrite(ClangDbFile, "]~n", []),
ok = file:close(ClangDbFile)
end,
- Res.
+ NewBins.
compile_each(_Config, [], _Type, _Env, {NewBins, CDB}) ->
{lists:reverse(NewBins), lists:reverse(CDB)};
@@ -244,15 +244,16 @@ compile_each(Config, [Source | Rest], Type, Env, {NewBins, CDB}) ->
Template = select_compile_template(Type, compiler(Ext)),
Cmd = expand_command(Template, Env, Source, Bin),
CDBEnt = cdb_entry(Source, Cmd, Rest),
+ NewCDB = [CDBEnt | CDB],
case needs_compile(Source, Bin) of
true ->
ShOpts = [{env, Env}, return_on_error, {use_stdout, false}],
exec_compiler(Config, Source, Cmd, ShOpts),
compile_each(Config, Rest, Type, Env,
- {[Bin | NewBins], [CDBEnt | CDB]});
+ {[Bin | NewBins], NewCDB});
false ->
?INFO("Skipping ~s\n", [Source]),
- compile_each(Config, Rest, Type, Env, {NewBins, [CDBEnt, CDB]})
+ compile_each(Config, Rest, Type, Env, {NewBins, NewCDB})
end.
%% Generate a clang compilation db entry for Src and Cmd
@@ -394,7 +395,8 @@ get_port_spec(Config, OsType, {_Arch, Target, Sources, Opts}) ->
LinkLang =
case lists:any(
fun(Src) -> compiler(filename:extension(Src)) == "$CXX" end,
- SourceFiles) of
+ SourceFiles)
+ of
true -> cxx;
false -> cc
end,
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index c3ebfe5..a5cc0ff 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -94,6 +94,7 @@ is_arch(ArchRegex) ->
nomatch ->
false
end.
+
%%
%% REBAR_TARGET_ARCH, if used, should be set to the "standard"
%% target string. That is a prefix for binutils tools.