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, []}. diff --git a/rebar.config b/rebar.config index f1d96bae2..0744a61c4 100644 --- a/rebar.config +++ b/rebar.config @@ -107,7 +107,7 @@ {if_rebar3, {plugins, [rebar3_hex, {provider_asn1, "0.2.0"}]}}. {if_not_rebar3, {plugins, [ - deps_erl_opts, override_deps_versions, + deps_erl_opts, override_deps_versions, override_opts, {if_var_true, elixir, rebar_elixir_compiler}, {if_var_true, elixir, rebar_exunit} ]}}. @@ -163,7 +163,6 @@ {port_env, [{"CFLAGS", "-g -O2 -Wall"}]}. {port_specs, [{"priv/lib/jid.so", ["c_src/jid.c"]}]}. - %% Local Variables: %% mode: erlang %% End: diff --git a/rebar.config.script b/rebar.config.script index f31ceaae2..219514a2f 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -255,9 +255,9 @@ CtParams = fun(CompileOpts) -> GenDepConfigureLine = fun(DepPath, Flags) -> - ["sh -c 'if test ! -f ",DepPath,"config.status -o ", - "config.status -nt ",DepPath,"config.status; ", - "then (cd ", DepPath, " && ", + ["sh -c 'if test ! -f config.status -o ", + "../../config.status -nt config.status; ", + "then (", "CFLAGS=\"", CFlags,"\" ", "CPPFLAGS=\"", CPPFlags, "\" " "LDFLAGS=\"", LDFlags, "\"", @@ -269,8 +269,8 @@ GenDepsConfigure = fun(Hooks) -> lists:map(fun({Pkg, Flags}) -> DepPath = ResolveDepPath("deps/" ++ Pkg ++ "/"), - {'compile', - lists:flatten(GenDepConfigureLine(DepPath, Flags))} + {add, list_to_atom(Pkg), [{pre_hooks, {'compile', + lists:flatten(GenDepConfigureLine(DepPath, Flags))}}]} end, Hooks) end, @@ -326,7 +326,7 @@ Rules = [ AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}]), []}, {[post_hooks], [cover_enabled], os:getenv("TRAVIS") == "true", AppendList2(TravisPostHooks), [], false}, - {[pre_hooks], [post_hook_configure], true, + {[overrides], [post_hook_configure], true, AppendList2(GenDepsConfigure), [], []}, {[ct_extra_params], [eunit_compile_opts], true, AppendStr2(CtParams), "", []},