summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_otp_app.erl33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index f705657..952271b 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -164,17 +164,32 @@ validate_name(AppName, File) ->
ebin_modules(AppInfo, Dir) ->
Beams = lists:sort(rebar_utils:beams(filename:join(Dir, "ebin"))),
- SrcDirs = rebar_dir:src_dirs(rebar_app_info:opts(AppInfo), ["src"]),
- FindSourceRules = [{".beam", ".erl",
- [{"ebin", filename:join(SrcDir, "**")} || SrcDir <- SrcDirs]}],
- Filtered = lists:filter(fun(Beam) ->
- rebar_utils:find_source(filename:basename(Beam),
- filename:dirname(Beam),
- FindSourceRules)
- =/= {error, not_found}
- end, Beams),
+ ExtraDirs = extra_dirs(AppInfo),
+ F = fun(Beam) -> not in_extra_dir(AppInfo, Beam, ExtraDirs) end,
+ Filtered = lists:filter(F, Beams),
[rebar_utils:beam_to_mod(N) || N <- Filtered].
+extra_dirs(State) ->
+ Extras = rebar_dir:extra_src_dirs(rebar_app_info:opts(State)),
+ SrcDirs = rebar_dir:src_dirs(rebar_app_info:opts(State), ["src"]),
+ %% remove any dirs that are defined in `src_dirs` from `extra_src_dirs`
+ Extras -- SrcDirs.
+
+in_extra_dir(AppInfo, Beam, Dirs) ->
+ lists:any(fun(Dir) -> lists:prefix(filename:join([rebar_app_info:out_dir(AppInfo), Dir]),
+ beam_src(Beam)) end,
+ Dirs).
+
+beam_src(Beam) ->
+ case beam_lib:chunks(Beam, [compile_info]) of
+ {ok, {_mod, Chunks}} ->
+ CompileInfo = proplists:get_value(compile_info, Chunks, []),
+ proplists:get_value(source, CompileInfo, []);
+ {error, beam_lib, Reason} ->
+ ?WARN("Couldn't read debug info from ~p for reason: ~p", [Beam, Reason]),
+ []
+ end.
+
ensure_registered(AppData) ->
case lists:keyfind(registered, 1, AppData) of
false ->