diff options
author | feng19 <feng_19@foxmail.com> | 2018-07-11 15:19:30 +0800 |
---|---|---|
committer | feng19 <feng_19@foxmail.com> | 2018-07-11 15:19:30 +0800 |
commit | 6c7e2e3826ae9f444c2c2243d7a451f53d86edd8 (patch) | |
tree | a7ebe66f9c1e34bc826837c5a61a2be761756108 | |
parent | 482718b8bf31024d919aabad1da2e9116411f2aa (diff) |
remove some refresh_paths's options(no_deps and no_test) & use beam_lib:md5/1 to get the module's vsn
-rw-r--r-- | src/rebar_agent.erl | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/rebar_agent.erl b/src/rebar_agent.erl index 69e9b8e..445ae54 100644 --- a/src/rebar_agent.erl +++ b/src/rebar_agent.erl @@ -131,10 +131,8 @@ maybe_show_warning(State) -> %% that makes sense. -spec refresh_paths(rebar_state:t()) -> ok. refresh_paths(RState) -> - RefreshPaths = lists:usort( - application:get_env(rebar, refresh_paths, []) - ++ [all_deps, test]), - ToRefresh = parse_refresh_paths(RefreshPaths, RState), + RefreshPaths = application:get_env(rebar, refresh_paths, [all_deps, test]), + ToRefresh = parse_refresh_paths(RefreshPaths, RState, []), %% Modules from apps we can't reload without breaking functionality Blacklist = lists:usort( application:get_env(rebar, refresh_paths_blacklist, []) @@ -180,22 +178,6 @@ refresh_path_do(Path, App) -> %% no_deps means only project_apps's ebin path %% no_test means no test path %% OtherPath. -parse_refresh_paths(RefreshPaths0, RState) -> - RefreshPaths1 = - case lists:member(no_deps, RefreshPaths0) of - true -> - lists:usort([project_apps | lists:delete(all_deps, RefreshPaths0)]); - false -> - RefreshPaths0 - end, - RefreshPaths = - case lists:member(no_test, RefreshPaths1) of - true -> - lists:delete(test, RefreshPaths1); - false -> - RefreshPaths1 - end, - parse_refresh_paths(RefreshPaths, RState, []). parse_refresh_paths([all_deps | RefreshPaths], RState, Acc) -> Paths = rebar_state:code_paths(RState, all_deps), parse_refresh_paths(RefreshPaths, RState, Paths ++ Acc); @@ -246,16 +228,18 @@ reload_modules(Modules0) -> %% and does not match the on-disk beam file, returns false otherwise. is_changed(M) -> try - module_vsn(M:module_info()) =/= module_vsn(code:get_object_code(M)) + module_vsn(M:module_info(attributes)) =/= module_vsn(code:get_object_code(M)) catch _:_ -> false end. module_vsn({M, Beam, _Fn}) -> - {ok, {M, Vsn}} = beam_lib:version(Beam), + % Because the vsn can set by -vsn(X) in module. + % So didn't use beam_lib:version/1 to get the vsn. + % So if set -vsn(X) in module, it will always reload the module. + {ok, {M, <<Vsn:128>>}} = beam_lib:md5(Beam), Vsn; -module_vsn(L) when is_list(L) -> - {_, Attrs} = lists:keyfind(attributes, 1, L), +module_vsn(Attrs) when is_list(Attrs) -> {_, Vsn} = lists:keyfind(vsn, 1, Attrs), Vsn. |