summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar3.erl6
-rw-r--r--src/rebar_core.erl44
-rw-r--r--src/rebar_prv_release.erl2
-rw-r--r--src/rebar_prv_tar.erl2
-rw-r--r--src/rebar_state.erl8
5 files changed, 51 insertions, 11 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index b325dc8..d4307f7 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -71,10 +71,10 @@ main(Args) ->
end.
%% Erlang-API entry point
-run(BaseState, Command) ->
+run(BaseState, Commands) ->
_ = application:load(rebar),
- BaseState1 = rebar_state:set(BaseState, task, Command),
- run_aux(BaseState1, [], [Command]).
+ BaseState1 = rebar_state:set(BaseState, task, Commands),
+ run_aux(BaseState1, [], Commands).
%% ====================================================================
%% Internal functions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index eaa546a..c3a8951 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -35,14 +35,46 @@
process_command(State, Command) ->
%% ? rebar_prv_install_deps:setup_env(State),
Providers = rebar_state:providers(State),
- TargetProviders = providers:get_target_providers(Command, Providers),
- case providers:get_provider(Command, Providers) of
+ Namespace = rebar_state:namespace(State),
+ {TargetProviders, CommandProvider} =
+ case Namespace of
+ undefined ->
+ %% undefined namespace means 'default', but on the first run;
+ %% it is used as an implicit counter for the first vs. subsequent
+ %% runs.
+ {providers:get_target_providers(Command, Providers, default),
+ providers:get_provider(Command, Providers, default)};
+ _ ->
+ {providers:get_target_providers(Command, Providers, Namespace),
+ providers:get_provider(Command, Providers, Namespace)}
+ end,
+ case CommandProvider of
not_found ->
- {error, io_lib:format("Command ~p not found", [Command])};
+ case Namespace of
+ undefined ->
+ %% On the first run (Namespace = undefined), we use the
+ %% unfound command name to be a namespace.
+ case providers:get_providers_by_namespace(Command, Providers) of
+ [] ->
+ {error, io_lib:format("Command ~p not found", [Command])};
+ _ ->
+ do([{default, do} | TargetProviders],
+ rebar_state:namespace(State, Command))
+ end;
+ default ->
+ {error, io_lib:format("Command ~p not found", [Command])};
+ _ ->
+ {error, io_lib:format("Command ~p not found in namespace ~p",
+ [Command, Namespace])}
+ end;
CommandProvider ->
case Command of
- Command when Command =:= do
- ; Command =:= as ->
+ Command when Command =:= do, Namespace =:= undefined ->
+ %% We're definitely in the default namespace. 'do' doesn't
+ %% properly exist for non-default namespaces outside of
+ %% dynamic dispatch calls for namespaces.
+ do(TargetProviders, rebar_state:namespace(State, default));
+ Command when Command =:= do; Command =:= as ->
do(TargetProviders, State);
_ ->
Profile = providers:profile(CommandProvider),
@@ -62,7 +94,7 @@ process_command(State, Command) ->
-spec do([{atom(), atom()}], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do([], State) ->
{ok, State};
-do([{ProviderName, _} | Rest], State) ->
+do([ProviderName | Rest], State) ->
Provider = providers:get_provider(ProviderName
,rebar_state:providers(State)),
case providers:do(Provider, State) of
diff --git a/src/rebar_prv_release.erl b/src/rebar_prv_release.erl
index 295d5b4..d82b428 100644
--- a/src/rebar_prv_release.erl
+++ b/src/rebar_prv_release.erl
@@ -12,7 +12,7 @@
-include("rebar.hrl").
-define(PROVIDER, release).
--define(DEPS, [{compile, default}, compile]).
+-define(DEPS, [compile]).
%% ===================================================================
%% Public API
diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl
index f9c261f..01fa1ba 100644
--- a/src/rebar_prv_tar.erl
+++ b/src/rebar_prv_tar.erl
@@ -12,7 +12,7 @@
-include("rebar.hrl").
-define(PROVIDER, tar).
--define(DEPS, [{compile, default}, compile]).
+-define(DEPS, [compile]).
%% ===================================================================
%% Public API
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 09becca..657c7d2 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -23,6 +23,7 @@
project_apps/1, project_apps/2,
deps_to_build/1, deps_to_build/2,
all_deps/1, all_deps/2,
+ namespace/1, namespace/2,
deps_names/1,
@@ -39,6 +40,7 @@
lock = [],
current_profiles = [default] :: [atom()],
+ namespace = undefined :: [atom()],
command_args = [],
command_parsed_args = [],
@@ -220,6 +222,12 @@ all_deps(#state_t{all_deps=Apps}) ->
all_deps(State=#state_t{}, NewApps) ->
State#state_t{all_deps=NewApps}.
+namespace(#state_t{namespace=Namespace}) ->
+ Namespace.
+
+namespace(State=#state_t{}, Namespace) ->
+ State#state_t{namespace=Namespace}.
+
providers(#state_t{providers=Providers}) ->
Providers.