Procházet zdrojové kódy

global plugins install to global config directory

pull/31/head
Tristan Sloughter před 10 roky
rodič
revize
9afd6e89b2
6 změnil soubory, kde provedl 38 přidání a 20 odebrání
  1. +11
    -8
      src/rebar3.erl
  2. +1
    -2
      src/rebar_packages.erl
  3. +6
    -4
      src/rebar_plugins.erl
  4. +3
    -2
      src/rebar_prv_install_deps.erl
  5. +6
    -1
      src/rebar_state.erl
  6. +11
    -3
      src/rebar_utils.erl

+ 11
- 8
src/rebar3.erl Zobrazit soubor

@ -74,7 +74,7 @@ main(Args) ->
run(BaseState, Command) ->
_ = application:load(rebar),
BaseState1 = rebar_state:set(BaseState, task, Command),
run_aux(BaseState1, [Command]).
run_aux(BaseState1, [], [Command]).
%% ====================================================================
%% Internal functions
@ -82,7 +82,7 @@ run(BaseState, Command) ->
run(RawArgs) ->
_ = application:load(rebar),
BaseConfig = init_config(),
{GlobalPluginProviders, BaseConfig} = init_config(),
case erlang:system_info(version) of
"6.1" ->
@ -93,9 +93,9 @@ run(RawArgs) ->
end,
{BaseConfig1, _Args1} = set_options(BaseConfig, {[], []}),
run_aux(BaseConfig1, RawArgs).
run_aux(BaseConfig1, GlobalPluginProviders, RawArgs).
run_aux(State, RawArgs) ->
run_aux(State, GlobalPluginProviders, RawArgs) ->
%% Make sure crypto is running
case crypto:start() of
ok -> ok;
@ -116,7 +116,8 @@ run_aux(State, RawArgs) ->
{ok, PluginProviders, State3} = rebar_plugins:install(State2),
rebar_core:update_code_path(State3),
State4 = rebar_state:create_logic_providers(Providers++PluginProviders, State3),
AllProviders = Providers++PluginProviders++GlobalPluginProviders,
State4 = rebar_state:create_logic_providers(AllProviders, State3),
{Task, Args} = parse_args(RawArgs),
rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)).
@ -147,9 +148,11 @@ init_config() ->
true ->
?DEBUG("Load global config file ~p",
[GlobalConfigFile]),
GlobalConfig = rebar_state:new(rebar_config:consult_file(GlobalConfigFile)),
rebar_state:new(GlobalConfig, Config1);
GlobalConfig = rebar_state:new(global, rebar_config:consult_file(GlobalConfigFile)),
{ok, PluginProviders, GlobalConfig1} = rebar_plugins:install(GlobalConfig),
rebar_state:new(GlobalConfig1, Config1);
false ->
PluginProviders = [],
rebar_state:new(Config1)
end,
@ -165,7 +168,7 @@ init_config() ->
%% TODO: Do we need this still? I think it may still be used.
%% Initialize vsn cache
rebar_state:set(State1, vsn_cache, dict:new()).
{PluginProviders, rebar_state:set(State1, vsn_cache, dict:new())}.
%%
%% Parse command line arguments using getopt and also filtering out any

+ 1
- 2
src/rebar_packages.erl Zobrazit soubor

@ -12,8 +12,7 @@
-spec get_packages(rebar_state:t()) -> {rebar_dict(), rebar_digraph()}.
get_packages(State) ->
Home = rebar_utils:home_dir(),
RebarDir = rebar_state:get(State, global_rebar_dir, filename:join(Home, ?CONFIG_DIR)),
RebarDir = rebar_utils:global_config_dir(State),
PackagesFile = filename:join(RebarDir, "packages"),
case ec_file:exists(PackagesFile) of
true ->

+ 6
- 4
src/rebar_plugins.erl Zobrazit soubor

@ -13,19 +13,21 @@
install(State) ->
%% Set deps_dir to a different dir for plugin so they don't collide
DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR),
OldDepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR),
State1 = rebar_state:set(State, deps_dir, ?DEFAULT_PLUGINS_DIR),
expand_plugins(?DEFAULT_PLUGINS_DIR),
DepsDir = rebar_utils:deps_dir(State1),
expand_plugins(DepsDir),
Plugins = rebar_state:get(State1, plugins, []),
PluginProviders = rebar_utils:filtermap(fun(Plugin) ->
handle_plugin(Plugin, State1)
end, Plugins),
{ok, PluginProviders, rebar_state:set(State1, deps_dir, DepsDir)}.
State2 = rebar_state:set(State1, deps_dir, OldDepsDir),
{ok, PluginProviders, State2}.
handle_plugin(Plugin, State) ->
try
{ok, State1} = rebar_prv_install_deps:handle_deps(State, [Plugin]),
{ok, _, State1} = rebar_prv_install_deps:handle_deps(State, [Plugin]),
Apps = rebar_state:all_deps(State1),
ToBuild = lists:dropwhile(fun rebar_app_info:valid/1, Apps),
lists:foreach(fun(AppInfo) ->

+ 3
- 2
src/rebar_prv_install_deps.erl Zobrazit soubor

@ -91,12 +91,13 @@ do(State) ->
format_error(Reason) ->
io_lib:format("~p", [Reason]).
-spec handle_deps(rebar_state:t(), [dep()]) -> {ok, rebar_state:t()}.
-spec handle_deps(rebar_state:t(), [dep()]) ->
{ok, [rebar_app_info:t()], rebar_state:t()} | {error, string()}.
handle_deps(State, Deps) ->
handle_deps(State, Deps, false).
-spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()})
-> {ok, rebar_state:t()} | {error, string()}.
-> {ok, [rebar_app_info:t()], rebar_state:t()} | {error, string()}.
handle_deps(State, [], _) ->
{ok, State};
handle_deps(State, Deps, Update) ->

+ 6
- 1
src/rebar_state.erl Zobrazit soubor

@ -54,7 +54,12 @@ new(Config) when is_list(Config) ->
#state_t { dir = rebar_utils:get_cwd(),
opts = dict:from_list(Config) }.
-spec new(t(), list()) -> t().
-spec new(t() | atom(), list()) -> t().
new(Profile, Config) when is_atom(Profile)
, is_list(Config) ->
#state_t { dir = rebar_utils:get_cwd(),
current_profile = Profile,
opts = dict:from_list(Config) };
new(ParentState=#state_t{}, Config) ->
%% Load terms from rebar.config, if it exists
Dir = rebar_utils:get_cwd(),

+ 11
- 3
src/rebar_utils.erl Zobrazit soubor

@ -36,6 +36,7 @@
default_profile_dir/1,
default_profile_deps/1,
home_dir/0,
global_config_dir/1,
droplast/1,
filtermap/2,
@ -108,10 +109,13 @@ lib_dirs(State) ->
default_profile_dir(State) ->
filename:join(base_dir(State), "default").
-spec profile_dir(rebar_state:t()) -> file:filename_all().
profile_dir(State) ->
Profile = rebar_state:current_profile(State),
filename:join(base_dir(State), atom_to_list(Profile)).
case rebar_state:current_profile(State) of
global ->
global_config_dir(State);
Profile ->
filename:join(base_dir(State), atom_to_list(Profile))
end.
-spec default_profile_deps(rebar_state:t()) -> file:filename_all().
default_profile_deps(State) ->
@ -121,6 +125,10 @@ home_dir() ->
{ok, [[Home]]} = init:get_argument(home),
Home.
global_config_dir(State) ->
Home = home_dir(),
rebar_state:get(State, global_rebar_dir, filename:join(Home, ?CONFIG_DIR)).
droplast(L) ->
lists:reverse(tl(lists:reverse(L))).

Načítá se…
Zrušit
Uložit