From 14cb6803e0a0742613cd4e476c5db0e5a1b134e7 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 28 Nov 2014 22:32:20 -0600 Subject: wip: profiles --- src/rebar3.erl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index 40f80d3..5ea62e6 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -107,12 +107,9 @@ run_aux(State, RawArgs) -> inets:start(), %% Process each command, resetting any state between each one - State2 = case rebar_state:get(State, base_dir, undefined) of - undefined -> - rebar_state:set(State, base_dir, filename:absname(rebar_state:dir(State))); - Dir -> - rebar_state:set(State, base_dir, filename:absname(Dir)) - end, + BaseDir = rebar_utils:base_dir(State), + State2 = rebar_state:set(State, base_dir, + filename:join(filename:absname(rebar_state:dir(State)), BaseDir)), {ok, Providers} = application:get_env(rebar, providers), -- cgit v1.1 From 9afd6e89b2dde0f8261bfd9eb371ffd33af0d889 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 29 Nov 2014 17:05:21 -0600 Subject: global plugins install to global config directory --- src/rebar3.erl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index 5ea62e6..c2161b7 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -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 -- cgit v1.1 From 731f05cc3db67ae49d6c7b5d7b5775c928f22691 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 29 Nov 2014 17:21:06 -0600 Subject: fix handle_deps when no deps are to be fetched --- src/rebar3.erl | 1 - 1 file changed, 1 deletion(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index c2161b7..9de8236 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -112,7 +112,6 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> filename:join(filename:absname(rebar_state:dir(State)), BaseDir)), {ok, Providers} = application:get_env(rebar, providers), - {ok, PluginProviders, State3} = rebar_plugins:install(State2), rebar_core:update_code_path(State3), -- cgit v1.1 From 5fdf2f82d57ed0b404e5dfa207b4944f0b8a412d Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 30 Nov 2014 10:54:48 -0600 Subject: add use of REBAR_PROFILE os var to set default profile --- src/rebar3.erl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index 9de8236..ebb0ea2 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -106,20 +106,28 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> application:start(ssl), inets:start(), + State2 = case os:getenv("REBAR_PROFILE") of + false -> + State; + Profile -> + State1 = rebar_state:current_profile(State, list_to_atom(Profile)), + rebar_state:default(State1, rebar_state:opts(State1)) + end, + %% Process each command, resetting any state between each one - BaseDir = rebar_utils:base_dir(State), - State2 = rebar_state:set(State, base_dir, - filename:join(filename:absname(rebar_state:dir(State)), BaseDir)), + BaseDir = rebar_utils:base_dir(State2), + State3 = rebar_state:set(State2, base_dir, + filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)), {ok, Providers} = application:get_env(rebar, providers), - {ok, PluginProviders, State3} = rebar_plugins:install(State2), - rebar_core:update_code_path(State3), + {ok, PluginProviders, State4} = rebar_plugins:install(State3), + rebar_core:update_code_path(State4), AllProviders = Providers++PluginProviders++GlobalPluginProviders, - State4 = rebar_state:create_logic_providers(AllProviders, State3), + State5 = rebar_state:create_logic_providers(AllProviders, State4), {Task, Args} = parse_args(RawArgs), - rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)). + rebar_core:process_command(rebar_state:command_args(State5, Args), list_to_atom(Task)). init_config() -> %% Initialize logging system -- cgit v1.1 From 56fdedaf7278accf6e261c54d022f4c9e1afc1fc Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 30 Nov 2014 10:55:36 -0600 Subject: switch to REBAR_DEFAULT_PROFILE to make it clear the profile becomes the default for the run --- src/rebar3.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index ebb0ea2..94ba2a4 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -106,7 +106,7 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> application:start(ssl), inets:start(), - State2 = case os:getenv("REBAR_PROFILE") of + State2 = case os:getenv("REBAR_DEFAULT_PROFILE") of false -> State; Profile -> -- cgit v1.1 From 8e5c916cb6e93b484278e7463af3e7b07fe6db07 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 1 Dec 2014 17:54:47 -0600 Subject: move dir functions from utils to new module rebar_dir --- src/rebar3.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index 94ba2a4..65b125e 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -115,7 +115,7 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> end, %% Process each command, resetting any state between each one - BaseDir = rebar_utils:base_dir(State2), + BaseDir = rebar_dir:base_dir(State2), State3 = rebar_state:set(State2, base_dir, filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)), @@ -149,7 +149,7 @@ init_config() -> end, %% If $HOME/.rebar3/config exists load and use as global config - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), GlobalConfigFile = filename:join([Home, ?CONFIG_DIR, "config"]), State = case filelib:is_regular(GlobalConfigFile) of true -> -- cgit v1.1 From 3af351cec28521caaa15308b1a4a992380723794 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Tue, 2 Dec 2014 10:00:44 -0600 Subject: set current_profile to default after checking global plugins --- src/rebar3.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar3.erl') diff --git a/src/rebar3.erl b/src/rebar3.erl index 65b125e..24d9ad3 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -108,7 +108,7 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> State2 = case os:getenv("REBAR_DEFAULT_PROFILE") of false -> - State; + rebar_state:current_profile(State, default); Profile -> State1 = rebar_state:current_profile(State, list_to_atom(Profile)), rebar_state:default(State1, rebar_state:opts(State1)) -- cgit v1.1