summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-03 02:15:50 -0800
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-03 02:22:43 -0800
commit6c421e543373aaf41a6ed10719f5da19b0cafd93 (patch)
tree0ceb00c9c6ba65fc6128018adc3e804e5454601f /src
parent9d41b756386c228b19e19b94558c486e01c5a93b (diff)
change from post-purging modules after checking their module info to
pre-purging before checking to facilitate long do chains
Diffstat (limited to 'src')
-rw-r--r--src/rebar_erlc_compiler.erl6
-rw-r--r--src/rebar_otp_app.erl12
2 files changed, 10 insertions, 8 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 9157e2a..c757511 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -260,10 +260,10 @@ opts_changed(Opts, Target) ->
Basename = filename:basename(Target, ".beam"),
Dirname = filename:dirname(Target),
ObjectFile = filename:join([Dirname, Basename]),
+ _ = purge(list_to_atom(Basename)),
case code:load_abs(ObjectFile) of
{module, Mod} ->
Compile = Mod:module_info(compile),
- _ = purge(Mod),
lists:sort(Opts) =/= lists:sort(proplists:get_value(options,
Compile));
{error, nofile} -> false
@@ -273,9 +273,7 @@ purge(Mod) ->
%% remove old code if necessary
_ = code:purge(Mod),
%% move current code to old
- true = code:delete(Mod),
- %% remove new old code
- _ = code:purge(Mod).
+ _ = code:delete(Mod).
check_erlcinfo(_Config, #erlcinfo{vsn=?ERLCINFO_VSN}) ->
ok;
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index 36af4cd..e850e58 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -167,18 +167,22 @@ ebin_modules(App, Dir) ->
beam_src(Beam) ->
try
+ Mod = list_to_atom(filename:basename(Beam, ".beam")),
+ _ = purge(Mod),
{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.
+purge(Mod) ->
+ %% remove old code if necessary
+ _ = code:purge(Mod),
+ %% move current code to old
+ _ = code:delete(Mod).
+
ensure_registered(AppData) ->
case lists:keyfind(registered, 1, AppData) of
false ->