Просмотр исходного кода

Apply profiles properly & load all paths

The old run didn't necessarily apply all profiles well, and would only
reload modules in the app file. However, since adding extra_src_dirs,
modules can be compiled without ending up in the app file; this lets
the rebar3 shell agent handle that case.
pull/577/head
Fred Hebert 10 лет назад
Родитель
Сommit
35f2a479b1
1 измененных файлов: 9 добавлений и 3 удалений
  1. +9
    -3
      src/rebar_agent.erl

+ 9
- 3
src/rebar_agent.erl Просмотреть файл

@ -87,16 +87,22 @@ refresh_paths(RState) ->
%% make sure to never reload self; halt()s the VM %% make sure to never reload self; halt()s the VM
) -- [filename:dirname(code:which(?MODULE))], ) -- [filename:dirname(code:which(?MODULE))],
%% Similar to rebar_utils:update_code/1, but also forces a reload %% Similar to rebar_utils:update_code/1, but also forces a reload
%% of used modules.
%% of used modules. Also forces to reload all of ebin/ instead
%% of just the modules in the .app file, because 'extra_src_dirs'
%% allows to load and compile files that are not to be kept
%% in the app file.
lists:foreach(fun(Path) -> lists:foreach(fun(Path) ->
Name = filename:basename(Path, "/ebin"), Name = filename:basename(Path, "/ebin"),
Files = filelib:wildcard(filename:join([Path, "*.beam"])),
Modules = [list_to_atom(filename:basename(F, ".beam"))
|| F <- Files],
App = list_to_atom(Name), App = list_to_atom(Name),
application:load(App), application:load(App),
case application:get_key(App, modules) of case application:get_key(App, modules) of
undefined -> undefined ->
code:add_patha(Path), code:add_patha(Path),
ok; ok;
{ok, Modules} ->
{ok, _} ->
?DEBUG("reloading ~p from ~s", [Modules, Path]), ?DEBUG("reloading ~p from ~s", [Modules, Path]),
code:replace_path(Name, Path), code:replace_path(Name, Path),
[begin code:purge(M), code:delete(M), code:load_file(M) end [begin code:purge(M), code:delete(M), code:load_file(M) end
@ -108,5 +114,5 @@ refresh_state(RState, _Dir) ->
lists:foldl( lists:foldl(
fun(F, State) -> F(State) end, fun(F, State) -> F(State) end,
rebar3:init_config(), rebar3:init_config(),
[fun(S) -> rebar_state:current_profiles(S, rebar_state:current_profiles(RState)) end]
[fun(S) -> rebar_state:apply_profiles(S, rebar_state:current_profiles(RState)) end]
). ).

Загрузка…
Отмена
Сохранить