diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-04 14:04:27 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-04 14:04:27 +0200 |
commit | 392adcf967bc92566d03eeaa32e22aa7c5532a1b (patch) | |
tree | 3450dafe61591e374115f33cd5526868d2a0cf34 | |
parent | c9ddb8325a22ddd48b79208f8236ad8c18ebe651 (diff) |
Refactor setup_env rebar_config funs
-rw-r--r-- | src/rebar_config.erl | 9 | ||||
-rw-r--r-- | src/rebar_core.erl | 10 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 8b856ab..f0c6d63 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -32,7 +32,7 @@ set/3, set_global/3, get_global/3, is_verbose/1, - set_env/3, get_env/2, reset_env/1, + save_env/3, get_env/2, reset_envs/1, set_skip_dir/2, is_skip_dir/2, reset_skip_dirs/1, clean_config/2, set_xconf/3, get_xconf/2, get_xconf/3, erase_xconf/2]). @@ -42,9 +42,8 @@ -record(config, { dir :: file:filename(), opts = [] :: list(), globals = new_globals() :: dict(), - %% TODO: consider storing envs in xconf envs = new_env() :: dict(), - %% cross-directory config + %% cross-directory/-command config skip_dirs = new_skip_dirs() :: dict(), xconf = new_xconf() :: dict() }). @@ -132,14 +131,14 @@ consult_file(File) -> end end. -set_env(Config, Mod, Env) -> +save_env(Config, Mod, Env) -> NewEnvs = dict:store(Mod, Env, Config#config.envs), Config#config{envs = NewEnvs}. get_env(Config, Mod) -> dict:fetch(Mod, Config#config.envs). -reset_env(Config) -> +reset_envs(Config) -> Config#config{envs = new_env()}. set_skip_dir(Config, Dir) -> diff --git a/src/rebar_core.erl b/src/rebar_core.erl index e4755b1..dd4a9be 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -257,8 +257,8 @@ processing_base_dir(Config, Dir) -> %% process each one we haven't seen yet %% process_each([], _Command, Config, _ModuleSetFile, DirSet) -> - %% reset cached setup_env - Config1 = rebar_config:reset_env(Config), + %% reset cached (setup_env) envs + Config1 = rebar_config:reset_envs(Config), {Config1, DirSet}; process_each([Dir | Rest], Command, Config, ModuleSetFile, DirSet) -> case sets:is_element(Dir, DirSet) of @@ -268,8 +268,8 @@ process_each([Dir | Rest], Command, Config, ModuleSetFile, DirSet) -> false -> {Config1, DirSet2} = process_dir(Dir, Config, Command, DirSet), Config2 = rebar_config:clean_config(Config, Config1), - %% reset cached setup_env - Config3 = rebar_config:reset_env(Config2), + %% reset cached (setup_env) envs + Config3 = rebar_config:reset_envs(Config2), process_each(Rest, Command, Config3, ModuleSetFile, DirSet2) end. @@ -434,7 +434,7 @@ setup_envs(Config, Modules) -> case erlang:function_exported(M, setup_env, 1) of true -> Env = M:setup_env(C), - C1 = rebar_config:set_env(C, M, Env), + C1 = rebar_config:save_env(C, M, Env), {C1, E++Env}; false -> T |