From 194f3caa3fc1c9454ac62da7ebc096704ecf1686 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 24 Jan 2012 21:05:35 +0100 Subject: [PATCH] Fix -D and -v handling with new getopt.erl --- src/rebar.erl | 16 +++++++++++++--- src/rebar_port_compiler.erl | 11 +++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/rebar.erl b/src/rebar.erl index 0c131ef..7ce409c 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -156,9 +156,7 @@ parse_args(Args) -> proplists:get_bool(profile, Options)), %% Set global variables based on getopt options - LogLevel = proplists:get_value(verbose, Options, - rebar_log:default_level()), - rebar_config:set_global(verbose, LogLevel), + set_log_level(Options), set_global_flag(Options, force), DefJobs = rebar_config:get_jobs(), case proplists:get_value(jobs, Options, DefJobs) of @@ -184,6 +182,18 @@ parse_args(Args) -> halt(1) 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 %% diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index 05e157b..bee9644 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -155,14 +155,9 @@ setup_env(Config) -> %% =================================================================== global_defines() -> - [begin - case string:tokens(D, "=") of - [Var, Val] -> - {Var, Val}; - [Def] -> - {Def, "1"} - end - end || D <- rebar_config:get_global(defines, [])]. + Defines = rebar_config:get_global(defines, []), + Flags = string:join(["-D" ++ D || D <- Defines], " "), + [{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Flags}]. expand_sources([], Acc) -> Acc;