mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 19:19:53 +00:00
rebar_core: fix consistency issues caused by 252b31f
- refactor plugin dirs code to be simpler and easier to read - use erlang-mode's default (%%) comments for portability/consistency - make sure erlang-mode's indenter is used so that a future whole buffer indent doesn't get messed up
This commit is contained in:
parent
edd835510b
commit
bdf957b201
1 changed files with 22 additions and 16 deletions
|
@ -533,21 +533,7 @@ plugin_modules(Config, PredirsAssoc, FoundModules, MissingModules) ->
|
||||||
|
|
||||||
load_plugin_modules(Config, PredirsAssoc, Modules) ->
|
load_plugin_modules(Config, PredirsAssoc, Modules) ->
|
||||||
Cwd = rebar_utils:get_cwd(),
|
Cwd = rebar_utils:get_cwd(),
|
||||||
PluginDirs = case rebar_config:get_local(Config, plugin_dir, undefined) of
|
PluginDirs = get_all_plugin_dirs(Config, Cwd, PredirsAssoc),
|
||||||
undefined ->
|
|
||||||
% Plugin can be in the project's "plugins" folder
|
|
||||||
[filename:join(Cwd, "plugins")];
|
|
||||||
Dir ->
|
|
||||||
[Dir]
|
|
||||||
end ++
|
|
||||||
% We also want to include this case:
|
|
||||||
% Plugin can be in "plugins" directory of the plugin base directory. For
|
|
||||||
% example, Cwd depends on Plugin, and deps/Plugin/plugins/Plugin.erl is the
|
|
||||||
% plugin.
|
|
||||||
[
|
|
||||||
filename:join(Dir, "plugins") ||
|
|
||||||
Dir <- get_plugin_base_dirs(Cwd, PredirsAssoc)
|
|
||||||
],
|
|
||||||
|
|
||||||
%% Find relevant sources in base_dir and plugin_dir
|
%% Find relevant sources in base_dir and plugin_dir
|
||||||
Erls = string:join([atom_to_list(M)++"\\.erl" || M <- Modules], "|"),
|
Erls = string:join([atom_to_list(M)++"\\.erl" || M <- Modules], "|"),
|
||||||
|
@ -562,12 +548,32 @@ load_plugin_modules(Config, PredirsAssoc, Modules) ->
|
||||||
NotLoaded = [V || V <- Modules, FilterMissing(V)],
|
NotLoaded = [V || V <- Modules, FilterMissing(V)],
|
||||||
{Loaded, NotLoaded}.
|
{Loaded, NotLoaded}.
|
||||||
|
|
||||||
|
get_all_plugin_dirs(Config, Cwd, PredirsAssoc) ->
|
||||||
|
get_plugin_dir(Config, Cwd) ++ get_base_plugin_dirs(Cwd, PredirsAssoc).
|
||||||
|
|
||||||
|
get_plugin_dir(Config, Cwd) ->
|
||||||
|
case rebar_config:get_local(Config, plugin_dir, undefined) of
|
||||||
|
undefined ->
|
||||||
|
%% Plugin can be in the project's "plugins" folder
|
||||||
|
[filename:join(Cwd, "plugins")];
|
||||||
|
Dir ->
|
||||||
|
[Dir]
|
||||||
|
end.
|
||||||
|
|
||||||
|
%% We also want to include this case:
|
||||||
|
%% Plugin can be in "plugins" directory of the plugin base directory.
|
||||||
|
%% For example, Cwd depends on Plugin, and deps/Plugin/plugins/Plugin.erl
|
||||||
|
%% is the plugin.
|
||||||
|
get_base_plugin_dirs(Cwd, PredirsAssoc) ->
|
||||||
|
[filename:join(Dir, "plugins") ||
|
||||||
|
Dir <- get_plugin_base_dirs(Cwd, PredirsAssoc)].
|
||||||
|
|
||||||
%% @doc PredirsAssoc is a dictionary of plugindir -> 'parent' pairs
|
%% @doc PredirsAssoc is a dictionary of plugindir -> 'parent' pairs
|
||||||
%% 'parent' in this case depends on plugin; therefore we have to give
|
%% 'parent' in this case depends on plugin; therefore we have to give
|
||||||
%% all plugins that Cwd ('parent' in this case) depends on.
|
%% all plugins that Cwd ('parent' in this case) depends on.
|
||||||
get_plugin_base_dirs(Cwd, PredirsAssoc) ->
|
get_plugin_base_dirs(Cwd, PredirsAssoc) ->
|
||||||
[PluginDir || {PluginDir, Master} <- dict:to_list(PredirsAssoc),
|
[PluginDir || {PluginDir, Master} <- dict:to_list(PredirsAssoc),
|
||||||
Master =:= Cwd].
|
Master =:= Cwd].
|
||||||
|
|
||||||
is_missing_plugin(Loaded) ->
|
is_missing_plugin(Loaded) ->
|
||||||
fun(Mod) -> not lists:member(Mod, Loaded) end.
|
fun(Mod) -> not lists:member(Mod, Loaded) end.
|
||||||
|
|
Loading…
Reference in a new issue