Browse Source

Merge pull request #440 from talentdeficit/unescessary_load

remove use of `code:load_abs/1` in favor of `beam_lib:chunks/2`
pull/435/merge
Tristan Sloughter 10 years ago
parent
commit
9ad3025c85
1 changed files with 14 additions and 8 deletions
  1. +14
    -8
      src/rebar_erlc_compiler.erl

+ 14
- 8
src/rebar_erlc_compiler.erl View File

@ -227,14 +227,20 @@ maybe_rm_beam_and_edge(G, OutDir, Source) ->
digraph:del_vertex(G, Source) digraph:del_vertex(G, Source)
end. end.
opts_changed(Opts, ObjectFile) ->
case code:load_abs(ObjectFile) of
{module, Mod} ->
Compile = Mod:module_info(compile),
lists:sort(Opts) =/= lists:sort(proplists:get_value(options,
Compile,
[]));
{error, _} -> true
opts_changed(NewOpts, Target) ->
case compile_info(Target) of
{ok, Opts} -> lists:sort(Opts) =/= lists:sort(NewOpts);
_ -> true
end.
compile_info(Target) ->
case beam_lib:chunks(Target, [compile_info]) of
{ok, {_mod, Chunks}} ->
CompileInfo = proplists:get_value(compile_info, Chunks, []),
{ok, proplists:get_value(options, CompileInfo, [])};
{error, beam_lib, Reason} ->
?WARN("Couldn't read debug info from ~p for reason: ~p", [Target, Reason]),
{error, Reason}
end. end.
erlcinfo_file(Dir) -> erlcinfo_file(Dir) ->

Loading…
Cancel
Save