Fix -D handling

This commit is contained in:
Joseph Wayne Norton 2012-07-28 23:04:51 +09:00 committed by Tuncer Ayaz
parent 74a82fa104
commit 2d62896de0
2 changed files with 9 additions and 9 deletions

View file

@ -156,15 +156,15 @@ setup_env(Config, ExtraEnv) ->
DefaultEnv = filter_env(default_env(), []),
RawPortEnv = rebar_config:get_list(Config, port_env, []),
PortEnv = filter_env(RawPortEnv, []),
GlobalDefines = global_defines(Config),
OverrideEnv = GlobalDefines ++ PortEnv ++ filter_env(ExtraEnv, []),
Defines = get_defines(Config),
OverrideEnv = Defines ++ PortEnv ++ filter_env(ExtraEnv, []),
RawEnv = apply_defaults(os_env(), DefaultEnv) ++ OverrideEnv,
expand_vars_loop(merge_each_var(RawEnv, [])).
global_defines(Config) ->
Defines = rebar_config:get_global(Config, defines, []),
Flags = string:join(["-D" ++ D || D <- Defines], " "),
[{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Flags}].
get_defines(Config) ->
RawDefines = rebar_config:get_xconf(Config, defines, []),
Defines = string:join(["-D" ++ D || D <- RawDefines], " "),
[{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Defines}].
replace_extension(File, NewExt) ->
OldExt = filename:extension(File),

View file

@ -291,9 +291,9 @@ delayed_halt(Code) ->
-spec erl_opts(rebar_config:config()) -> list().
erl_opts(Config) ->
RawErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
GlobalDefines = [{d, list_to_atom(D)} ||
D <- rebar_config:get_global(Config, defines, [])],
Opts = GlobalDefines ++ RawErlOpts,
Defines = [{d, list_to_atom(D)} ||
D <- rebar_config:get_xconf(Config, defines, [])],
Opts = Defines ++ RawErlOpts,
case proplists:is_defined(no_debug_info, Opts) of
true ->
[O || O <- Opts, O =/= no_debug_info];