diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2017-09-26 17:32:37 +0200 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2017-09-26 17:32:37 +0200 |
commit | 05feab35c4169ec5cf9c4d0fba8f56075e3d0152 (patch) | |
tree | e27203677401d2bfc1d0e53d421869073ed07c5d /plugins | |
parent | Fix command set_last that always returned code 1, error (#2010) (diff) |
Call earlier deps configure scripts durring compilation
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/override_opts.erl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/override_opts.erl b/plugins/override_opts.erl new file mode 100644 index 000000000..1b83fb6a1 --- /dev/null +++ b/plugins/override_opts.erl @@ -0,0 +1,32 @@ +-module(override_opts). +-export([preprocess/2]). + +override_opts(override, Config, Opts) -> + lists:foldl(fun({Opt, Value}, Conf) -> + rebar_config:set(Conf, Opt, Value) + end, Config, Opts); +override_opts(add, Config, Opts) -> + lists:foldl(fun({Opt, Value}, Conf) -> + V = rebar_config:get_local(Conf, Opt, []), + rebar_config:set(Conf, Opt, [Value | V]) + end, Config, Opts). + +preprocess(Config, _Dirs) -> + Overrides = rebar_config:get_local(Config, overrides, []), + TopOverrides = case rebar_config:get_xconf(Config, top_overrides, []) of + [] -> Overrides; + Val -> Val + end, + Config2 = rebar_config:set_xconf(Config, top_overrides, TopOverrides), + Config3 = case rebar_app_utils:load_app_file(Config2, _Dirs) of + {ok, C, AppName, _AppData} -> + lists:foldl(fun({Type, AppName2, Opts}, Conf1) when + AppName2 == AppName -> + override_opts(Type, Conf1, Opts); + (_, Conf2) -> + Conf2 + end, C, TopOverrides); + _ -> + Config2 + end, + {ok, Config3, []}. |