From 989a1bfe8d991846f81331a94eb65ffc10883cf5 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 08:20:05 -0500 Subject: add plugin template --- src/rebar_core.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index cb021e3..ce3816d 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -35,7 +35,8 @@ process_command(State, Command) -> 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), + + %% ? rebar_prv_install_deps:setup_env(State), TargetProviders = rebar_provider:get_target_providers(Command, State), -- cgit v1.1 From 51f1cf4aae5a22fe8974edcdf10da4e8a7b05255 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 09:01:03 -0500 Subject: install plugins to plugins/ --- src/rebar_core.erl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/rebar_core.erl') 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 -- cgit v1.1 From e1b1152b219cf65c7f8cd3b77db5cf2156fcbab7 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 22:36:54 -0500 Subject: slowly widdling away at dialyzer errors --- src/rebar_core.erl | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 24b376f..ba77dd8 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -55,8 +55,6 @@ update_code_path(State) -> %% Internal functions %% =================================================================== -update_code_path_([]) -> - no_change; update_code_path_(Paths) -> LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []), ok = code:add_pathsa(LibPaths), -- cgit v1.1 From e9a3396e56679a11ac1caa3b47f1f196f0307d72 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 27 Sep 2014 14:12:11 -0500 Subject: return error messages from providers --- src/rebar_core.erl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index ba77dd8..9f2b168 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -31,17 +31,25 @@ -include("rebar.hrl"). +-spec process_command(rebar_state:t(), atom()) -> {ok, rebar_state:t()} | {error, string()}. process_command(State, Command) -> %% ? rebar_prv_install_deps:setup_env(State), TargetProviders = rebar_provider:get_target_providers(Command, State), + do(TargetProviders, State). - lists:foldl(fun(TargetProvider, Conf) -> - Provider = rebar_provider:get_provider(TargetProvider - ,rebar_state:providers(Conf)), - {ok, Conf1} = rebar_provider:do(Provider, Conf), - Conf1 - end, State, TargetProviders). +-spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. +do([], State) -> + {ok, State}; +do([ProviderName | Rest], State) -> + Provider = rebar_provider:get_provider(ProviderName + ,rebar_state:providers(State)), + case rebar_provider:do(Provider, State) of + {ok, State1} -> + do(Rest, State1); + {error, Error} -> + {error, Error} + end. update_code_path(State) -> true = rebar_utils:expand_code_path(), -- cgit v1.1 From b37a5ae611aaf6b84a046fbe716f40c2aa8c75d8 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 3 Oct 2014 06:33:33 -0500 Subject: move providers to separate app --- src/rebar_core.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 9f2b168..17fc0e2 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -34,17 +34,17 @@ -spec process_command(rebar_state:t(), atom()) -> {ok, rebar_state:t()} | {error, string()}. process_command(State, Command) -> %% ? rebar_prv_install_deps:setup_env(State), - - TargetProviders = rebar_provider:get_target_providers(Command, State), + Providers = rebar_state:providers(State), + TargetProviders = providers:get_target_providers(Command, Providers), do(TargetProviders, State). -spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do([], State) -> {ok, State}; do([ProviderName | Rest], State) -> - Provider = rebar_provider:get_provider(ProviderName + Provider = providers:get_provider(ProviderName ,rebar_state:providers(State)), - case rebar_provider:do(Provider, State) of + case providers:do(Provider, State) of {ok, State1} -> do(Rest, State1); {error, Error} -> -- cgit v1.1 From b20680304d02a10babff15ff69a78a816077fa3c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 10 Oct 2014 11:47:41 -0500 Subject: split options up by task --- src/rebar_core.erl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 17fc0e2..340f2ae 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -36,14 +36,23 @@ process_command(State, Command) -> %% ? rebar_prv_install_deps:setup_env(State), Providers = rebar_state:providers(State), TargetProviders = providers:get_target_providers(Command, Providers), - do(TargetProviders, State). + CommandProvider = providers:get_provider(Command + ,Providers), + Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(), + case getopt:parse(Opts, rebar_state:command_args(State)) of + {ok, Args} -> + State2 = rebar_state:command_parsed_args(State, Args), + do(TargetProviders, State2); + {error, {invalid_option, Option}} -> + {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])} + end. -spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do([], State) -> {ok, State}; do([ProviderName | Rest], State) -> Provider = providers:get_provider(ProviderName - ,rebar_state:providers(State)), + ,rebar_state:providers(State)), case providers:do(Provider, State) of {ok, State1} -> do(Rest, State1); -- cgit v1.1 From 90cfb2a794e16dbf583a3591f448ced4a32f579f Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 10 Oct 2014 17:31:25 -0500 Subject: support compile jobs option --- src/rebar_core.erl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 340f2ae..147f64f 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -39,12 +39,17 @@ process_command(State, Command) -> CommandProvider = providers:get_provider(Command ,Providers), Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(), - case getopt:parse(Opts, rebar_state:command_args(State)) of - {ok, Args} -> - State2 = rebar_state:command_parsed_args(State, Args), - do(TargetProviders, State2); - {error, {invalid_option, Option}} -> - {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])} + case Command of + do -> + do(TargetProviders, State); + _ -> + case getopt:parse(Opts, rebar_state:command_args(State)) of + {ok, Args} -> + State2 = rebar_state:command_parsed_args(State, Args), + do(TargetProviders, State2); + {error, {invalid_option, Option}} -> + {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])} + end end. -spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. -- cgit v1.1 From 3b5f22f0663c545117692dfa88d0a6fc66235ed6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 11 Oct 2014 09:21:01 -0500 Subject: formatting --- src/rebar_core.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 147f64f..155e14f 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -36,8 +36,7 @@ process_command(State, Command) -> %% ? rebar_prv_install_deps:setup_env(State), Providers = rebar_state:providers(State), TargetProviders = providers:get_target_providers(Command, Providers), - CommandProvider = providers:get_provider(Command - ,Providers), + CommandProvider = providers:get_provider(Command, Providers), Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(), case Command of do -> -- cgit v1.1 From 8c0212d6d3f938ed4a9cfc24828b98224619d475 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Wed, 22 Oct 2014 18:27:06 -0500 Subject: return error on not found provider for command --- src/rebar_core.erl | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/rebar_core.erl') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 155e14f..16d8f07 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -36,18 +36,22 @@ process_command(State, Command) -> %% ? rebar_prv_install_deps:setup_env(State), Providers = rebar_state:providers(State), TargetProviders = providers:get_target_providers(Command, Providers), - CommandProvider = providers:get_provider(Command, Providers), - Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(), - case Command of - do -> - do(TargetProviders, State); - _ -> - case getopt:parse(Opts, rebar_state:command_args(State)) of - {ok, Args} -> - State2 = rebar_state:command_parsed_args(State, Args), - do(TargetProviders, State2); - {error, {invalid_option, Option}} -> - {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])} + case providers:get_provider(Command, Providers) of + not_found -> + {error, io_lib:format("Command ~p not found", [Command])}; + CommandProvider -> + Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(), + case Command of + do -> + do(TargetProviders, State); + _ -> + case getopt:parse(Opts, rebar_state:command_args(State)) of + {ok, Args} -> + State2 = rebar_state:command_parsed_args(State, Args), + do(TargetProviders, State2); + {error, {invalid_option, Option}} -> + {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])} + end end end. -- cgit v1.1