diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 58 | ||||
-rw-r--r-- | src/rebar_deps.erl | 17 |
2 files changed, 59 insertions, 16 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 465496e..ec568f9 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -26,7 +26,10 @@ %% ------------------------------------------------------------------- -module(rebar_core). --export([run/1]). +-export([run/1, + skip_dir/1, + is_skip_dir/1, + skip_dirs/0]). -include("rebar.hrl"). @@ -72,11 +75,28 @@ run(RawArgs) -> %% Note the top-level directory for reference rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())), - %% Load rebar.config, if it exists - [process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new()) - || Command <- CommandAtoms], - ok. + %% Process each command, resetting any state between each one + process_commands(CommandAtoms). + +skip_dir(Dir) -> + case erlang:get({skip_dir, Dir}) of + undefined -> + ?DEBUG("Adding skip dir: ~s\n", [Dir]), + erlang:put({skip_dir, Dir}, true); + true -> + ok + end. + +is_skip_dir(Dir) -> + case erlang:get({skip_dir, Dir}) of + undefined -> + false; + true -> + true + end. +skip_dirs() -> + [Dir || {{skip_dir, Dir}, true} <- erlang:get()]. %% =================================================================== %% Internal functions @@ -250,6 +270,15 @@ filter_flags([Item | Rest], Commands) -> filter_flags(Rest, Commands) end. +process_commands([]) -> + ok; +process_commands([Command | Rest]) -> + %% Reset skip dirs + [erlang:erase({skip_dir, D}) || D <- skip_dirs()], + + process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new()), + process_commands(Rest). + process_dir(Dir, ParentConfig, Command, DirSet) -> case filelib:is_dir(Dir) of @@ -292,12 +321,21 @@ process_dir(Dir, ParentConfig, Command, DirSet) -> %% caused it to change ok = file:set_cwd(Dir), - %% Get the list of plug-in modules from rebar.config. These modules are - %% processed LAST and do not participate in preprocess. - {ok, PluginModules} = plugin_modules(Config), + %% Check that this directory is not on the skip list + case is_skip_dir(Dir) of + true -> + %% Do not execute the command on the directory, as some module + %% as requested a skip on it. + ?INFO("Skipping ~s in ~s\n", [Command, Dir]); - %% Execute the current command on this directory - execute(Command, Modules ++ PluginModules, Config, ModuleSetFile), + false -> + %% Get the list of plug-in modules from rebar.config. These modules are + %% processed LAST and do not participate in preprocess. + {ok, PluginModules} = plugin_modules(Config), + + %% Execute the current command on this directory + execute(Command, Modules ++ PluginModules, Config, ModuleSetFile) + end, %% Mark the current directory as processed DirSet3 = sets:add_element(Dir, DirSet2), diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index 89f6ffc..5d6a890 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -62,14 +62,19 @@ preprocess(Config, _) -> %% Add available deps to code path update_deps_code_path(AvailableDeps), - %% If skip_deps=true, don't worry about processing deps at all. + %% If skip_deps=true, mark each dep dir as a skip_dir w/ the core so that + %% the current command doesn't run on the dep dir. However, pre/postprocess + %% WILL run (and we want it to) for transitivity purposes. case rebar_config:get_global(skip_deps, false) of - false -> - %% Return all the available dep directories for process - {ok, [D#dep.dir || D <- AvailableDeps]}; + "true" -> + [rebar_core:skip_dir(D#dep.dir) || D <- AvailableDeps]; _ -> - {ok, []} - end. + ok + end, + + %% Return all the available dep directories for process + {ok, [D#dep.dir || D <- AvailableDeps]}. + postprocess(_Config, _) -> case erlang:get(?MODULE) of |