summaryrefslogtreecommitdiff
path: root/src/rebar_otp_app.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_otp_app.erl')
-rw-r--r--src/rebar_otp_app.erl38
1 files changed, 12 insertions, 26 deletions
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index 1d854da..e14975f 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -60,7 +60,8 @@ compile(State, App) ->
format_error({missing_app_file, Filename}) ->
io_lib:format("App file is missing: ~ts", [Filename]);
format_error({file_read, AppName, File, Reason}) ->
- io_lib:format("Failed to read required ~ts file for processing the application '~ts': ~ts", [File, AppName, file:format_error(Reason)]);
+ io_lib:format("Failed to read required ~ts file for processing the application '~ts': ~ts",
+ [File, AppName, file:format_error(Reason)]);
format_error({invalid_name, File, AppName}) ->
io_lib:format("Invalid ~ts: name of application (~p) must match filename.", [File, AppName]).
@@ -125,7 +126,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
%% Setup file .app filename and write new contents
EbinDir = rebar_app_info:ebin_dir(AppInfo),
- filelib:ensure_dir(filename:join(EbinDir, "dummy.beam")),
+ rebar_file_utils:ensure_dir(EbinDir),
AppFile = rebar_app_utils:app_src_to_app(OutDir, AppSrcFile),
ok = rebar_file_utils:write_file_if_contents_differ(AppFile, Spec, utf8),
@@ -163,32 +164,17 @@ validate_name(AppName, File) ->
ebin_modules(AppInfo, Dir) ->
Beams = lists:sort(rebar_utils:beams(filename:join(Dir, "ebin"))),
- ExtraDirs = extra_dirs(AppInfo),
- F = fun(Beam) -> not in_extra_dir(AppInfo, Beam, ExtraDirs) end,
- Filtered = lists:filter(F, Beams),
+ SrcDirs = rebar_dir:src_dirs(rebar_app_info:opts(AppInfo), ["src"]),
+ FindSourceRules = [{".beam", ".erl",
+ [{"ebin", SrcDir} || SrcDir <- SrcDirs]}],
+ Filtered = lists:filter(fun(Beam) ->
+ rebar_utils:find_source(filename:basename(Beam),
+ filename:dirname(Beam),
+ FindSourceRules)
+ =/= {error, not_found}
+ end, 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 ->