Fix -D and -v handling with new getopt.erl

This commit is contained in:
Tuncer Ayaz 2012-01-24 21:05:35 +01:00
parent c4e40714ee
commit 194f3caa3f
2 changed files with 16 additions and 11 deletions

View file

@ -156,9 +156,7 @@ parse_args(Args) ->
proplists:get_bool(profile, Options)), proplists:get_bool(profile, Options)),
%% Set global variables based on getopt options %% Set global variables based on getopt options
LogLevel = proplists:get_value(verbose, Options, set_log_level(Options),
rebar_log:default_level()),
rebar_config:set_global(verbose, LogLevel),
set_global_flag(Options, force), set_global_flag(Options, force),
DefJobs = rebar_config:get_jobs(), DefJobs = rebar_config:get_jobs(),
case proplists:get_value(jobs, Options, DefJobs) of case proplists:get_value(jobs, Options, DefJobs) of
@ -184,6 +182,18 @@ parse_args(Args) ->
halt(1) halt(1)
end. end.
%%
%% set log level based on getopt option
%%
set_log_level(Options) ->
LogLevel = case proplists:get_all_values(verbose, Options) of
[] ->
rebar_log:default_level();
Verbosities ->
lists:last(Verbosities)
end,
rebar_config:set_global(verbose, LogLevel).
%% %%
%% show version information and halt %% show version information and halt
%% %%

View file

@ -155,14 +155,9 @@ setup_env(Config) ->
%% =================================================================== %% ===================================================================
global_defines() -> global_defines() ->
[begin Defines = rebar_config:get_global(defines, []),
case string:tokens(D, "=") of Flags = string:join(["-D" ++ D || D <- Defines], " "),
[Var, Val] -> [{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Flags}].
{Var, Val};
[Def] ->
{Def, "1"}
end
end || D <- rebar_config:get_global(defines, [])].
expand_sources([], Acc) -> expand_sources([], Acc) ->
Acc; Acc;