mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Respect the --config switch when given
Currently the --config switch does not work because when loading a new rebar config the global setting is ignored for all paths. This patch provides a check when loading new rebar config to see whether or not the current config path matches the `base_dir` set in global conf, which produces the expected behaviour.
This commit is contained in:
parent
da31f90d1d
commit
5bb536f839
5 changed files with 49 additions and 13 deletions
1
inttest/t_custom_config/custom.config
Normal file
1
inttest/t_custom_config/custom.config
Normal file
|
@ -0,0 +1 @@
|
|||
{erl_opts, [warnings_as_errors]}.
|
6
inttest/t_custom_config/custom_config.erl
Normal file
6
inttest/t_custom_config/custom_config.erl
Normal file
|
@ -0,0 +1,6 @@
|
|||
-module(custom_config).
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
test() ->
|
||||
ok.
|
31
inttest/t_custom_config/t_custom_config_rt.erl
Normal file
31
inttest/t_custom_config/t_custom_config_rt.erl
Normal file
|
@ -0,0 +1,31 @@
|
|||
-module(t_custom_config_rt).
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
files() ->
|
||||
[{copy, "custom.config", "custom.config"},
|
||||
{create, "ebin/custom_config.app", app(custom_config, [custom_config])}].
|
||||
|
||||
run(Dir) ->
|
||||
retest_log:log(debug, "Running in Dir: ~s~n", [Dir]),
|
||||
Ref = retest:sh("rebar -C custom.config check-deps -v", [{async, true}]),
|
||||
{ok, Captured} =
|
||||
retest:sh_expect(Ref,
|
||||
"DEBUG: Consult config file .*/custom.config.*",
|
||||
[{capture, all, list}]),
|
||||
retest_log:log(debug, "[CAPTURED]: ~s~n", [Captured]),
|
||||
ok.
|
||||
|
||||
%%
|
||||
%% Generate the contents of a simple .app file
|
||||
%%
|
||||
app(Name, Modules) ->
|
||||
App = {application, Name,
|
||||
[{description, atom_to_list(Name)},
|
||||
{vsn, "1"},
|
||||
{modules, Modules},
|
||||
{registered, []},
|
||||
{applications, [kernel, stdlib]}]},
|
||||
io_lib:format("~p.\n", [App]).
|
|
@ -108,9 +108,10 @@ run_aux(Commands) ->
|
|||
false ->
|
||||
rebar_config:new()
|
||||
end,
|
||||
BaseConfig = rebar_config:base_config(GlobalConfig),
|
||||
|
||||
%% Process each command, resetting any state between each one
|
||||
rebar_core:process_commands(CommandAtoms, GlobalConfig).
|
||||
rebar_core:process_commands(CommandAtoms, BaseConfig).
|
||||
|
||||
%%
|
||||
%% print help/usage string
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
%% -------------------------------------------------------------------
|
||||
-module(rebar_config).
|
||||
|
||||
-export([new/0, new/1,
|
||||
-export([new/0, new/1, base_config/1,
|
||||
get/3, get_local/3, get_list/3,
|
||||
get_all/2,
|
||||
set/3,
|
||||
|
@ -48,6 +48,10 @@
|
|||
%% Public API
|
||||
%% ===================================================================
|
||||
|
||||
base_config(#config{opts=Opts0}) ->
|
||||
ConfName = rebar_config:get_global(config, "rebar.config"),
|
||||
new(Opts0, ConfName).
|
||||
|
||||
new() ->
|
||||
#config { dir = rebar_utils:get_cwd(),
|
||||
opts = [] }.
|
||||
|
@ -60,17 +64,10 @@ new(ConfigFile) when is_list(ConfigFile) ->
|
|||
Other ->
|
||||
?ABORT("Failed to load ~s: ~p~n", [ConfigFile, Other])
|
||||
end;
|
||||
new(#config{opts=Opts0}=ParentConfig)->
|
||||
%% If we are at the top level we might want to load another rebar.config
|
||||
%% We can be certain that we are at the top level if we don't have any
|
||||
%% configs yet since if we are at another level we must have some config.
|
||||
ConfName = case ParentConfig of
|
||||
{config, _, []} ->
|
||||
rebar_config:get_global(config, "rebar.config");
|
||||
_ ->
|
||||
"rebar.config"
|
||||
end,
|
||||
new(_ParentConfig=#config{opts=Opts0})->
|
||||
new(Opts0, "rebar.config").
|
||||
|
||||
new(Opts0, ConfName) ->
|
||||
%% Load terms from rebar.config, if it exists
|
||||
Dir = rebar_utils:get_cwd(),
|
||||
ConfigFile = filename:join([Dir, ConfName]),
|
||||
|
|
Loading…
Reference in a new issue