summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-09-20 09:01:03 -0500
committerTristan Sloughter <t@crashfast.com>2014-09-20 09:01:03 -0500
commit51f1cf4aae5a22fe8974edcdf10da4e8a7b05255 (patch)
tree5fc180a8bd15eb9c121fba6600bfd6b67996c7c1 /src
parent989a1bfe8d991846f81331a94eb65ffc10883cf5 (diff)
install plugins to plugins/
Diffstat (limited to 'src')
-rw-r--r--src/rebar3.erl10
-rw-r--r--src/rebar_core.erl20
-rw-r--r--src/rebar_plugins.erl24
-rw-r--r--src/rebar_prv_install_deps.erl27
4 files changed, 43 insertions, 38 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index 39babeb..44d7d98 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -141,10 +141,12 @@ run_aux(State, Args) ->
State2 = rebar_state:set(State1, base_dir, filename:absname(rebar_state:dir(State1))),
{ok, Providers} = application:get_env(rebar, providers),
- rebar_plugins:install(State2),
- State3 = rebar_state:create_logic_providers(Providers, State2),
- Task = rebar_state:get(State3, task, "help"),
- rebar_core:process_command(rebar_state:command_args(State3, Args), list_to_atom(Task)),
+ {ok, PluginProviders, State3} = rebar_plugins:install(State2),
+ rebar_core:update_code_path(State),
+
+ State4 = rebar_state:create_logic_providers(Providers++PluginProviders, State3),
+ Task = rebar_state:get(State4, task, "help"),
+ rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)),
ok.
%%
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index ce3816d..24b376f 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -26,16 +26,12 @@
%% -------------------------------------------------------------------
-module(rebar_core).
--export([process_command/2]).
+-export([process_command/2
+ ,update_code_path/1]).
-include("rebar.hrl").
process_command(State, Command) ->
- true = rebar_utils:expand_code_path(),
- LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
- DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIRS),
- _UpdatedCodePaths = update_code_path([DepsDir | LibDirs]),
-
%% ? rebar_prv_install_deps:setup_env(State),
TargetProviders = rebar_provider:get_target_providers(Command, State),
@@ -47,13 +43,21 @@ process_command(State, Command) ->
Conf1
end, State, TargetProviders).
+update_code_path(State) ->
+ true = rebar_utils:expand_code_path(),
+ LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
+ DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR),
+ PluginsDir = rebar_state:get(State, plugins_dir, ?DEFAULT_PLUGINS_DIR),
+ _UpdatedCodePaths = update_code_path_([DepsDir, PluginsDir | LibDirs]).
+
+
%% ===================================================================
%% Internal functions
%% ===================================================================
-update_code_path([]) ->
+update_code_path_([]) ->
no_change;
-update_code_path(Paths) ->
+update_code_path_(Paths) ->
LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []),
ok = code:add_pathsa(LibPaths),
%% track just the paths we added, so we can remove them without
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
index e9ab0b2..3e51f7f 100644
--- a/src/rebar_plugins.erl
+++ b/src/rebar_plugins.erl
@@ -12,8 +12,26 @@
%% ===================================================================
install(State) ->
- BaseDir = rebar_state:get(State, base_dir, ""),
- State1 = rebar_state:set(State, base_dir, "plugins"),
+ State1 = rebar_state:set(State, deps_dir, "plugins"),
+
Plugins = rebar_state:get(State1, plugins, []),
{ok, State2} = rebar_prv_install_deps:handle_deps(State1, Plugins),
- {ok, rebar_state:set(State2, base_dir, BaseDir)}.
+
+ Apps = rebar_state:get(State2, all_deps),
+ lists:foreach(fun(AppInfo) ->
+ C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
+ S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(AppInfo)),
+ rebar_prv_compile:build(S, AppInfo)
+ end, Apps),
+
+ PluginProviders = plugin_providers(Plugins),
+ {ok, PluginProviders, rebar_state:set(State2, deps_dir, ?DEFAULT_DEPS_DIR)}.
+
+plugin_providers(Plugins) ->
+ lists:map(fun({Plugin, _, _}) when is_atom(Plugin) ->
+ Plugin;
+ ({Plugin, _}) when is_atom(Plugin) ->
+ Plugin;
+ (Plugin) when is_atom(Plugin) ->
+ Plugin
+ end, Plugins).
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 0752f0a..81acf22 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -33,8 +33,7 @@
-include("rebar.hrl").
--export([setup_env/1,
- handle_deps/2]).
+-export([handle_deps/2]).
%% for internal use only
-export([get_deps_dir/1]).
@@ -78,29 +77,11 @@ do(State) ->
{ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)),
{ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}.
-
-%% set REBAR_DEPS_DIR and ERL_LIBS environment variables
-setup_env(State) ->
- DepsDir = get_deps_dir(State),
- %% include rebar's DepsDir in ERL_LIBS
- Separator = case os:type() of
- {win32, nt} ->
- ";";
- _ ->
- ":"
- end,
- ERL_LIBS = case os:getenv("ERL_LIBS") of
- false ->
- {"ERL_LIBS", DepsDir};
- PrevValue ->
- {"ERL_LIBS", DepsDir ++ Separator ++ PrevValue}
- end,
- [{"REBAR_DEPS_DIR", DepsDir}, ERL_LIBS].
-
-spec get_deps_dir(rebar_state:t()) -> file:filename_all().
get_deps_dir(State) ->
BaseDir = rebar_state:get(State, base_dir, ""),
- get_deps_dir(BaseDir, "deps").
+ DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR),
+ get_deps_dir(BaseDir, DepsDir).
-spec get_deps_dir(file:filename_all(), rebar_state:t()) -> file:filename_all().
get_deps_dir(DepsDir, App) ->
@@ -113,7 +94,7 @@ handle_deps(State, Deps) ->
%% Read in package index and dep graph
{Packages, Graph} = rebar_packages:get_packages(State),
- %% Split source deps form binary deps, needed to keep backwards compatibility
+ %% Split source deps from binary deps, needed to keep backwards compatibility
DepsDir = get_deps_dir(State),
{SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps),
State1 = rebar_state:src_deps(rebar_state:binary_deps(State, BinaryDeps),