port_compiler: fix handling of multiple specs

Project: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/commit/e4144e9f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/tree/e4144e9f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/diff/e4144e9f

Branch: refs/heads/master
Commit: e4144e9f9d783557860ab599c3b5a0fbf879e88d
Parents: 31297b0
Author: Tuncer Ayaz <[email protected]>
Authored: Tue Aug 30 15:31:27 2016 +0200
Committer: Tuncer Ayaz <[email protected]>
Committed: Tue Aug 30 15:31:27 2016 +0200

----------------------------------------------------------------------
 src/rebar_port_compiler.erl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-rebar/blob/e4144e9f/src/rebar_port_compiler.erl
----------------------------------------------------------------------
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 7aa04ec..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)};

Reply via email to