summaryrefslogtreecommitdiff
path: root/src/rebar_erlc_compiler.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_erlc_compiler.erl')
-rw-r--r--src/rebar_erlc_compiler.erl25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 8fe03b7..c7a3474 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -143,7 +143,8 @@ doterl_compile(Config, Dir, OutDir, MoreSources, ErlOpts) ->
%% Support the src_dirs option allowing multiple directories to
%% contain erlang source. This might be used, for example, should
%% eunit tests be separated from the core application source.
- SrcDirs = [filename:join(Dir, X) || X <- proplists:get_value(src_dirs, ErlOpts, ["src"])],
+ SrcDirs = [filename:join(Dir, X) || X <- proplists:get_value(src_dirs, ErlOpts, ["src"]) ++
+ proplists:get_value(extra_src_dirs, ErlOpts, [])],
AllErlFiles = gather_src(SrcDirs, []) ++ MoreSources,
%% Make sure that ebin/ exists and is on the path
@@ -227,14 +228,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) ->