diff options
author | Tristan Sloughter <t@crashfast.com> | 2018-11-24 12:55:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-24 12:55:55 -0700 |
commit | d50b70a44ded8d51d02b4bd414f19bfc8964a6df (patch) | |
tree | b95296daa314e6fbacb24c4e2b6226bad4448bc6 /src | |
parent | f450eb3940d49351c54a02a0c976ad98337d9c77 (diff) |
revert ebin_modules to include all beams minus extra_src (#1955)
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_otp_app.erl | 33 |
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 -> |