Browse Source

exclude beams compiled from source in `test` from the .app file

pull/201/head
alisdair sullivan 10 years ago
parent
commit
516a4cef25
1 changed files with 22 additions and 4 deletions
  1. +22
    -4
      src/rebar_otp_app.erl

+ 22
- 4
src/rebar_otp_app.erl View File

@ -100,7 +100,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
%% substitute. Note that we include the list of modules available in %% substitute. Note that we include the list of modules available in
%% ebin/ and update the app data accordingly. %% ebin/ and update the app data accordingly.
OutDir = rebar_app_info:out_dir(AppInfo), 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), A1 = apply_app_vars(AppVars, AppData),
%% AppSrcFile may contain instructions for generating a vsn number %% AppSrcFile may contain instructions for generating a vsn number
@ -157,9 +157,27 @@ validate_name(AppName, File) ->
?PRV_ERROR({invalid_name, File, AppName}) ?PRV_ERROR({invalid_name, File, AppName})
end. 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) -> ensure_registered(AppData) ->
case lists:keyfind(registered, 1, AppData) of case lists:keyfind(registered, 1, AppData) of

Loading…
Cancel
Save