summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Rascão <luis.rascao@gmail.com>2016-08-31 15:24:16 +0100
committerGitHub <noreply@github.com>2016-08-31 15:24:16 +0100
commit5904aef1532b501c01ced1071e78779b2daa928f (patch)
treee0e74f8147f4ba41ac2fa25eb5a2a11defafef10
parentb709625adf7ca098ad87dad4af2d5f9fb024ac19 (diff)
parente4144e9f9d783557860ab599c3b5a0fbf879e88d (diff)
downloadrebar-5904aef1532b501c01ced1071e78779b2daa928f.tar.gz
Merge pull request #619 from tuncer/fix-cdb
Fix cdb processing when a file is skipped
-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.