diff options
author | Tristan Sloughter <tristan.sloughter@gmail.com> | 2015-05-17 09:58:55 -0500 |
---|---|---|
committer | Tristan Sloughter <tristan.sloughter@gmail.com> | 2015-05-17 09:58:55 -0500 |
commit | 9ad3025c85148cc2bb0b79a66636071db960729d (patch) | |
tree | 40bfa6ecee586c46b397585e1265e8a29c14c0b3 | |
parent | 162f0f8f63c99c6a9800ef1911060fad8b257b8b (diff) | |
parent | 04f63ff53c554afbd42714038a6c8b727266c2f0 (diff) |
Merge pull request #440 from talentdeficit/unescessary_load
remove use of `code:load_abs/1` in favor of `beam_lib:chunks/2`
-rw-r--r-- | src/rebar_erlc_compiler.erl | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 8fe03b7..684fedb 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -227,14 +227,20 @@ maybe_rm_beam_and_edge(G, OutDir, Source) -> digraph:del_vertex(G, Source) 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. erlcinfo_file(Dir) -> |