Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 12, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/rebar_port_compiler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
_ ->
Expand All @@ -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)};
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/rebar_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down