summaryrefslogtreecommitdiff
path: root/src/rebar_core.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_core.erl')
-rw-r--r--src/rebar_core.erl28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index fcfa62a..4efc978 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -163,6 +163,13 @@ skip_or_process_dir({_, ModuleSetFile}=ModuleSet, Config, CurrentCodePath,
skip_or_process_dir1(AppFile, ModuleSet, Config, CurrentCodePath,
Dir, Command, DirSet) ->
case rebar_app_utils:is_skipped_app(Config, AppFile) of
+ {Config1, {true, _SkippedApp}} when Command == 'update-deps' ->
+ %% update-deps does its own app skipping. Unfortunately there's no
+ %% way to signal this to rebar_core, so we have to explicitly do it
+ %% here... Otherwise if you use app=, it'll skip the toplevel
+ %% directory and nothing will be updated.
+ process_dir1(Dir, Command, DirSet, Config1,
+ CurrentCodePath, ModuleSet);
{Config1, {true, SkippedApp}} ->
?DEBUG("Skipping app: ~p~n", [SkippedApp]),
Config2 = increment_operations(Config1),
@@ -172,8 +179,9 @@ skip_or_process_dir1(AppFile, ModuleSet, Config, CurrentCodePath,
CurrentCodePath, ModuleSet)
end.
-process_dir1(Dir, Command, DirSet, Config0, CurrentCodePath,
+process_dir1(Dir, Command, DirSet, Config, CurrentCodePath,
{DirModules, ModuleSetFile}) ->
+ Config0 = rebar_config:set_xconf(Config, current_command, Command),
%% Get the list of modules for "any dir". This is a catch-all list
%% of modules that are processed in addition to modules associated
%% with this directory type. These any_dir modules are processed
@@ -391,18 +399,19 @@ update_code_path(Config) ->
[] ->
no_change;
Paths ->
- OldPath = code:get_path(),
LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []),
ok = code:add_pathsa(LibPaths),
- {old, OldPath}
+ %% track just the paths we added, so we can remove them without
+ %% removing other paths added by this dep
+ {added, LibPaths}
end.
restore_code_path(no_change) ->
ok;
-restore_code_path({old, Path}) ->
+restore_code_path({added, Paths}) ->
%% Verify that all of the paths still exist -- some dynamically
%% added paths can get blown away during clean.
- true = code:set_path([F || F <- Path, erl_prim_loader_is_file(F)]),
+ _ = [code:del_path(F) || F <- Paths, erl_prim_loader_is_file(F)],
ok.
erl_prim_loader_is_file(File) ->
@@ -493,6 +502,8 @@ acc_modules([Module | Rest], Command, Config, File, Acc) ->
%%
plugin_modules(Config, PredirsAssoc) ->
Modules = lists:flatten(rebar_config:get_all(Config, plugins)),
+ ?DEBUG("Plugins requested while processing ~s: ~p~n",
+ [rebar_utils:get_cwd(), Modules]),
plugin_modules(Config, PredirsAssoc, ulist(Modules)).
ulist(L) ->
@@ -534,6 +545,7 @@ plugin_modules(Config, PredirsAssoc, FoundModules, MissingModules) ->
load_plugin_modules(Config, PredirsAssoc, Modules) ->
Cwd = rebar_utils:get_cwd(),
PluginDirs = get_all_plugin_dirs(Config, Cwd, PredirsAssoc),
+ ?DEBUG("Plugin dirs for ~s:~n~p~n", [Cwd, PluginDirs]),
%% Find relevant sources in base_dir and plugin_dir
Erls = string:join([atom_to_list(M)++"\\.erl" || M <- Modules], "|"),
@@ -549,7 +561,9 @@ load_plugin_modules(Config, PredirsAssoc, Modules) ->
{Loaded, NotLoaded}.
get_all_plugin_dirs(Config, Cwd, PredirsAssoc) ->
- get_plugin_dir(Config, Cwd) ++ get_base_plugin_dirs(Cwd, PredirsAssoc).
+ [rebar_utils:get_cwd()]
+ ++ 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
@@ -568,7 +582,7 @@ 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
%% all plugins that Cwd ('parent' in this case) depends on.
get_plugin_base_dirs(Cwd, PredirsAssoc) ->