mirror of
https://github.com/correl/rebar.git
synced 2024-11-24 03:00:14 +00:00
Change semantics of skip_deps=true such that deps still get pre/post processed, just not actually run
This commit is contained in:
parent
2974110982
commit
ad7a494bde
2 changed files with 59 additions and 16 deletions
|
@ -26,7 +26,10 @@
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
-module(rebar_core).
|
-module(rebar_core).
|
||||||
|
|
||||||
-export([run/1]).
|
-export([run/1,
|
||||||
|
skip_dir/1,
|
||||||
|
is_skip_dir/1,
|
||||||
|
skip_dirs/0]).
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
|
||||||
|
@ -72,11 +75,28 @@ run(RawArgs) ->
|
||||||
%% Note the top-level directory for reference
|
%% Note the top-level directory for reference
|
||||||
rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())),
|
rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())),
|
||||||
|
|
||||||
%% Load rebar.config, if it exists
|
%% Process each command, resetting any state between each one
|
||||||
[process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new())
|
process_commands(CommandAtoms).
|
||||||
|| Command <- CommandAtoms],
|
|
||||||
ok.
|
|
||||||
|
|
||||||
|
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
|
%% Internal functions
|
||||||
|
@ -250,6 +270,15 @@ filter_flags([Item | Rest], Commands) ->
|
||||||
filter_flags(Rest, Commands)
|
filter_flags(Rest, Commands)
|
||||||
end.
|
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) ->
|
process_dir(Dir, ParentConfig, Command, DirSet) ->
|
||||||
case filelib:is_dir(Dir) of
|
case filelib:is_dir(Dir) of
|
||||||
|
@ -292,12 +321,21 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
|
||||||
%% caused it to change
|
%% caused it to change
|
||||||
ok = file:set_cwd(Dir),
|
ok = file:set_cwd(Dir),
|
||||||
|
|
||||||
|
%% 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]);
|
||||||
|
|
||||||
|
false ->
|
||||||
%% Get the list of plug-in modules from rebar.config. These modules are
|
%% Get the list of plug-in modules from rebar.config. These modules are
|
||||||
%% processed LAST and do not participate in preprocess.
|
%% processed LAST and do not participate in preprocess.
|
||||||
{ok, PluginModules} = plugin_modules(Config),
|
{ok, PluginModules} = plugin_modules(Config),
|
||||||
|
|
||||||
%% Execute the current command on this directory
|
%% Execute the current command on this directory
|
||||||
execute(Command, Modules ++ PluginModules, Config, ModuleSetFile),
|
execute(Command, Modules ++ PluginModules, Config, ModuleSetFile)
|
||||||
|
end,
|
||||||
|
|
||||||
%% Mark the current directory as processed
|
%% Mark the current directory as processed
|
||||||
DirSet3 = sets:add_element(Dir, DirSet2),
|
DirSet3 = sets:add_element(Dir, DirSet2),
|
||||||
|
|
|
@ -62,14 +62,19 @@ preprocess(Config, _) ->
|
||||||
%% Add available deps to code path
|
%% Add available deps to code path
|
||||||
update_deps_code_path(AvailableDeps),
|
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
|
case rebar_config:get_global(skip_deps, false) of
|
||||||
false ->
|
"true" ->
|
||||||
%% Return all the available dep directories for process
|
[rebar_core:skip_dir(D#dep.dir) || D <- AvailableDeps];
|
||||||
{ok, [D#dep.dir || D <- AvailableDeps]};
|
|
||||||
_ ->
|
_ ->
|
||||||
{ok, []}
|
ok
|
||||||
end.
|
end,
|
||||||
|
|
||||||
|
%% Return all the available dep directories for process
|
||||||
|
{ok, [D#dep.dir || D <- AvailableDeps]}.
|
||||||
|
|
||||||
|
|
||||||
postprocess(_Config, _) ->
|
postprocess(_Config, _) ->
|
||||||
case erlang:get(?MODULE) of
|
case erlang:get(?MODULE) of
|
||||||
|
|
Loading…
Reference in a new issue