summaryrefslogtreecommitdiff
path: root/src/rebar_core.erl
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2011-12-12 19:08:40 +0100
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-12-12 21:20:34 +0100
commit8c89a388bf39b34430dae76ca51ec9869e938f7f (patch)
treea970fde2840f85be0a9fe5a383d729315563582a /src/rebar_core.erl
parenta5e39c2c545e2a9dd33dc08d5161234a681d7aa6 (diff)
Universally support apps=/skip_apps=
Diffstat (limited to 'src/rebar_core.erl')
-rw-r--r--src/rebar_core.erl155
1 files changed, 94 insertions, 61 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 56f0aca..44ad355 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -114,81 +114,111 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
%% CWD to see if it's a fit -- if it is, use that set of modules
%% to process this dir.
{ok, AvailModuleSets} = application:get_env(rebar, modules),
- {DirModules, ModuleSetFile} = choose_module_set(AvailModuleSets,
- Dir),
+ ModuleSet = choose_module_set(AvailModuleSets, Dir),
+ {_DirModules, ModuleSetFile} = ModuleSet,
+
+ case lists:reverse(ModuleSetFile) of
+ "ppa." ++ _ ->
+ %% .app file
+ maybe_process_dir0(ModuleSetFile, ModuleSet, Config,
+ CurrentCodePath, Dir,
+ Command, DirSet);
+ "crs.ppa." ++ _ ->
+ %% .app.src file
+ maybe_process_dir0(ModuleSetFile, ModuleSet, Config,
+ CurrentCodePath, Dir,
+ Command, DirSet);
+ _ ->
+ process_dir0(Dir, Command, DirSet, Config,
+ CurrentCodePath, ModuleSet)
+ end
+ end.
- %% 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
- %% FIRST.
- {ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
+maybe_process_dir0(AppFile, ModuleSet, Config, CurrentCodePath,
+ Dir, Command, DirSet) ->
+ case rebar_app_utils:is_skipped_app(AppFile) of
+ {true, SkippedApp} ->
+ ?DEBUG("Skipping app: ~p~n", [SkippedApp]),
+ increment_operations(),
+ DirSet;
+ false ->
+ process_dir0(Dir, Command, DirSet, Config,
+ CurrentCodePath, ModuleSet)
+ end.
- Modules = AnyDirModules ++ DirModules,
+process_dir0(Dir, Command, DirSet, Config, CurrentCodePath,
+ {DirModules, ModuleSetFile}) ->
+ %% 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
+ %% FIRST.
+ {ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
- %% Invoke 'preprocess' on the modules -- this yields a list of other
- %% directories that should be processed _before_ the current one.
- Predirs = acc_modules(Modules, preprocess, Config, ModuleSetFile),
+ Modules = AnyDirModules ++ DirModules,
- %% Get the list of plug-in modules from rebar.config. These
- %% modules may participate in preprocess and postprocess.
- {ok, PluginModules} = plugin_modules(Config),
+ %% Invoke 'preprocess' on the modules -- this yields a list of other
+ %% directories that should be processed _before_ the current one.
+ Predirs = acc_modules(Modules, preprocess, Config, ModuleSetFile),
- PluginPredirs = acc_modules(PluginModules, preprocess,
- Config, ModuleSetFile),
+ %% Get the list of plug-in modules from rebar.config. These
+ %% modules may participate in preprocess and postprocess.
+ {ok, PluginModules} = plugin_modules(Config),
- AllPredirs = Predirs ++ PluginPredirs,
+ PluginPredirs = acc_modules(PluginModules, preprocess,
+ Config, ModuleSetFile),
- ?DEBUG("Predirs: ~p\n", [AllPredirs]),
- DirSet2 = process_each(AllPredirs, Command, Config,
- ModuleSetFile, DirSet),
+ AllPredirs = Predirs ++ PluginPredirs,
- %% Make sure the CWD is reset properly; processing the dirs may have
- %% caused it to change
- ok = file:set_cwd(Dir),
+ ?DEBUG("Predirs: ~p\n", [AllPredirs]),
+ DirSet2 = process_each(AllPredirs, Command, Config,
+ ModuleSetFile, DirSet),
- %% 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]);
+ %% Make sure the CWD is reset properly; processing the dirs may have
+ %% caused it to change
+ ok = file:set_cwd(Dir),
- false ->
- %% Execute any before_command plugins on this directory
- execute_pre(Command, PluginModules,
- Config, ModuleSetFile),
+ %% 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 ->
+ %% Execute any before_command plugins on this directory
+ execute_pre(Command, PluginModules,
+ Config, ModuleSetFile),
- %% Execute the current command on this directory
- execute(Command, Modules ++ PluginModules,
- Config, ModuleSetFile),
+ %% Execute the current command on this directory
+ execute(Command, Modules ++ PluginModules,
+ Config, ModuleSetFile),
- %% Execute any after_command plugins on this directory
- execute_post(Command, PluginModules,
- Config, ModuleSetFile)
- end,
+ %% Execute any after_command plugins on this directory
+ execute_post(Command, PluginModules,
+ Config, ModuleSetFile)
+ end,
- %% Mark the current directory as processed
- DirSet3 = sets:add_element(Dir, DirSet2),
+ %% Mark the current directory as processed
+ DirSet3 = sets:add_element(Dir, DirSet2),
- %% Invoke 'postprocess' on the modules. This yields a list of other
- %% directories that should be processed _after_ the current one.
- Postdirs = acc_modules(Modules ++ PluginModules, postprocess,
- Config, ModuleSetFile),
- ?DEBUG("Postdirs: ~p\n", [Postdirs]),
- DirSet4 = process_each(Postdirs, Command, Config,
- ModuleSetFile, DirSet3),
+ %% Invoke 'postprocess' on the modules. This yields a list of other
+ %% directories that should be processed _after_ the current one.
+ Postdirs = acc_modules(Modules ++ PluginModules, postprocess,
+ Config, ModuleSetFile),
+ ?DEBUG("Postdirs: ~p\n", [Postdirs]),
+ DirSet4 = process_each(Postdirs, Command, Config,
+ ModuleSetFile, DirSet3),
- %% Make sure the CWD is reset properly; processing the dirs may have
- %% caused it to change
- ok = file:set_cwd(Dir),
+ %% Make sure the CWD is reset properly; processing the dirs may have
+ %% caused it to change
+ ok = file:set_cwd(Dir),
- %% Once we're all done processing, reset the code path to whatever
- %% the parent initialized it to
- restore_code_path(CurrentCodePath),
+ %% Once we're all done processing, reset the code path to whatever
+ %% the parent initialized it to
+ restore_code_path(CurrentCodePath),
- %% Return the updated dirset as our result
- DirSet4
- end.
+ %% Return the updated dirset as our result
+ DirSet4.
maybe_load_local_config(Dir, ParentConfig) ->
%% We need to ensure we don't overwrite custom
@@ -274,9 +304,7 @@ execute(Command, Modules, Config, ModuleFile) ->
Dir = rebar_utils:get_cwd(),
?CONSOLE("==> ~s (~s)\n", [filename:basename(Dir), Command]),
- %% Increment the count of operations, since some module
- %% responds to this command
- erlang:put(operations, erlang:get(operations) + 1),
+ increment_operations(),
%% Check for and get command specific environments
Env = setup_envs(Config, Modules),
@@ -300,6 +328,11 @@ execute(Command, Modules, Config, ModuleFile) ->
end
end.
+%% Increment the count of operations, since some module
+%% responds to this command
+increment_operations() ->
+ erlang:put(operations, erlang:get(operations) + 1).
+
update_code_path(Config) ->
case rebar_config:get_local(Config, lib_dirs, []) of