summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) ->