summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2011-10-22 22:25:40 +0200
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-10-23 01:12:54 +0200
commit28b9cebf0a5ceef0849b214f324f18c7ead178b7 (patch)
treeec869c0910daf6833e248c1b3711bccd80171b89
parent8eeca123e50f355c51faf53b2e9185dde25e2f6f (diff)
Add -D support to rebar_port_compiler
-rw-r--r--src/rebar_port_compiler.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 74be18c..a473fa5 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -154,7 +154,7 @@ setup_env(Config) ->
%% max flexibility for users.
DefaultEnvs = filter_envs(default_env(), []),
PortEnvs = rebar_config:get_list(Config, port_envs, []),
- OverrideEnvs = filter_envs(PortEnvs, []),
+ OverrideEnvs = global_defines() ++ filter_envs(PortEnvs, []),
RawEnv = apply_defaults(os_env(), DefaultEnvs) ++ OverrideEnvs,
expand_vars_loop(merge_each_var(RawEnv, [])).
@@ -162,6 +162,16 @@ setup_env(Config) ->
%% Internal functions
%% ===================================================================
+global_defines() ->
+ [begin
+ case string:tokens(D, "=") of
+ [Var, Val] ->
+ {Var, Val};
+ [Def] ->
+ {Def, "1"}
+ end
+ end || D <- rebar_config:get_global(defines, [])].
+
expand_sources([], Acc) ->
Acc;
expand_sources([{ArchRegex, Spec} | Rest], Acc) ->