summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-02 18:34:20 -0800
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-02 19:30:19 -0800
commit516a4cef25f37699faa5c1bbf7f6bc5b846143f2 (patch)
treee1aa68715bfdd8dcfecaddb99febf3dd1c49d901
parentc7c00bccfdabda4c867de648f5eecdd754ef7a0d (diff)
exclude beams compiled from source in `test` from the .app file
-rw-r--r--src/rebar_otp_app.erl26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index 278d7e5..36af4cd 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -100,7 +100,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
%% substitute. Note that we include the list of modules available in
%% ebin/ and update the app data accordingly.
OutDir = rebar_app_info:out_dir(AppInfo),
- AppVars = load_app_vars(State) ++ [{modules, ebin_modules(OutDir)}],
+ AppVars = load_app_vars(State) ++ [{modules, ebin_modules(AppInfo, OutDir)}],
A1 = apply_app_vars(AppVars, AppData),
%% AppSrcFile may contain instructions for generating a vsn number
@@ -157,9 +157,27 @@ validate_name(AppName, File) ->
?PRV_ERROR({invalid_name, File, AppName})
end.
-ebin_modules(Dir) ->
- lists:sort([rebar_utils:beam_to_mod(N) ||
- N <- rebar_utils:beams(filename:join(Dir, "ebin"))]).
+ebin_modules(App, Dir) ->
+ Beams = lists:sort(rebar_utils:beams(filename:join(Dir, "ebin"))),
+ F = fun(Beam) -> not lists:prefix(filename:join([rebar_app_info:dir(App), "test"]),
+ beam_src(Beam))
+ end,
+ Filtered = lists:filter(F, Beams),
+ [rebar_utils:beam_to_mod(N) || N <- Filtered].
+
+beam_src(Beam) ->
+ try
+ {module, Mod} = code:load_abs(filename:rootname(Beam, ".beam")),
+ Compile = Mod:module_info(compile),
+ %% completely purge module so any other attempts to load it succeed
+ _ = code:purge(Mod),
+ _ = code:delete(Mod),
+ _ = code:purge(Mod),
+ proplists:get_value(source, Compile, [])
+ catch
+ error:undef -> [];
+ error:nofile -> []
+ end.
ensure_registered(AppData) ->
case lists:keyfind(registered, 1, AppData) of