Pass compile flags to protobuffs

By default protobuffs doesn't create beams with debug info.  This
causes issues when running dialyzer which requires debug info.  Read
the `erl_opts` config and pass it down to protobuffs compiler.
This commit is contained in:
Ryan Zezeski 2012-09-02 22:30:58 -04:00 committed by Tuncer Ayaz
parent 48c7f53930
commit e7be6874d7

View file

@ -35,7 +35,7 @@
%% Public API %% Public API
%% =================================================================== %% ===================================================================
compile(_Config, _AppFile) -> compile(Config, _AppFile) ->
case rebar_utils:find_files("src", ".*\\.proto$") of case rebar_utils:find_files("src", ".*\\.proto$") of
[] -> [] ->
ok; ok;
@ -49,7 +49,7 @@ compile(_Config, _AppFile) ->
Proto <- FoundFiles], Proto <- FoundFiles],
%% Compile each proto file %% Compile each proto file
compile_each(Targets); compile_each(Config, Targets);
false -> false ->
?ERROR("Protobuffs library not present in code path!\n", ?ERROR("Protobuffs library not present in code path!\n",
[]), []),
@ -95,13 +95,15 @@ needs_compile(Proto, Beam) ->
ActualBeam = filename:join(["ebin", filename:basename(Beam)]), ActualBeam = filename:join(["ebin", filename:basename(Beam)]),
filelib:last_modified(ActualBeam) < filelib:last_modified(Proto). filelib:last_modified(ActualBeam) < filelib:last_modified(Proto).
compile_each([]) -> compile_each(_, []) ->
ok; ok;
compile_each([{Proto, Beam, Hrl} | Rest]) -> compile_each(Config, [{Proto, Beam, Hrl} | Rest]) ->
case needs_compile(Proto, Beam) of case needs_compile(Proto, Beam) of
true -> true ->
?CONSOLE("Compiling ~s\n", [Proto]), ?CONSOLE("Compiling ~s\n", [Proto]),
case protobuffs_compile:scan_file(Proto) of ErlOpts = rebar_utils:erl_opts(Config),
case protobuffs_compile:scan_file(Proto,
[{compile_flags,ErlOpts}]) of
ok -> ok ->
%% Compilation worked, but we need to move the %% Compilation worked, but we need to move the
%% beam and .hrl file into the ebin/ and include/ %% beam and .hrl file into the ebin/ and include/
@ -120,7 +122,7 @@ compile_each([{Proto, Beam, Hrl} | Rest]) ->
false -> false ->
ok ok
end, end,
compile_each(Rest). compile_each(Config, Rest).
delete_each([]) -> delete_each([]) ->
ok; ok;