2013-04-08 11:12:54 +02:00
|
|
|
%%%-------------------------------------------------------------------
|
|
|
|
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
|
|
|
%%% @copyright (C) 2013, Evgeniy Khramtsov
|
|
|
|
%%% @doc
|
|
|
|
%%%
|
|
|
|
%%% @end
|
|
|
|
%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
|
|
|
%%%-------------------------------------------------------------------
|
2015-03-23 14:54:29 +01:00
|
|
|
|
2013-04-08 11:12:54 +02:00
|
|
|
Cfg = case file:consult("vars.config") of
|
|
|
|
{ok, Terms} ->
|
|
|
|
Terms;
|
|
|
|
_Err ->
|
|
|
|
[]
|
|
|
|
end,
|
|
|
|
|
2015-12-18 17:17:13 +01:00
|
|
|
ProcessVars = fun(_F, [], Acc) ->
|
|
|
|
lists:reverse(Acc);
|
|
|
|
(F, [{Type, Var, Value} | Tail], Acc) when
|
|
|
|
Type == if_var_true orelse
|
|
|
|
Type == if_var_false ->
|
|
|
|
Flag = Type == if_var_true,
|
|
|
|
case proplists:get_bool(Var, Cfg) of
|
|
|
|
V when V == Flag ->
|
|
|
|
F(F, Tail, [Value | Acc]);
|
|
|
|
_ ->
|
|
|
|
F(F, Tail, Acc)
|
|
|
|
end;
|
|
|
|
(F, [{Type, Var, Match, Value} | Tail], Acc) when
|
|
|
|
Type == if_var_match orelse
|
|
|
|
Type == if_var_no_match ->
|
|
|
|
case proplists:get_value(Var, Cfg) of
|
|
|
|
V when V == Match ->
|
|
|
|
F(F, Tail, [Value | Acc]);
|
|
|
|
_ ->
|
|
|
|
F(F, Tail, Acc)
|
|
|
|
end;
|
|
|
|
(F, [Other1 | Tail1], Acc) ->
|
|
|
|
F(F, Tail1, [F(F, Other1, []) | Acc]);
|
|
|
|
(F, Val, Acc) when is_tuple(Val) ->
|
|
|
|
list_to_tuple(F(F, tuple_to_list(Val), Acc));
|
|
|
|
(_F, Other2, _Acc) ->
|
|
|
|
Other2
|
|
|
|
end,
|
2013-04-08 11:12:54 +02:00
|
|
|
|
2015-10-20 15:22:39 +02:00
|
|
|
CFLags = proplists:get_value(cflags, Cfg, ""),
|
|
|
|
CPPFLags = proplists:get_value(cppflags, Cfg, ""),
|
|
|
|
LDFLags = proplists:get_value(ldflags, Cfg, ""),
|
|
|
|
|
2013-04-08 11:12:54 +02:00
|
|
|
ConfigureCmd = fun(Pkg, Flags) ->
|
|
|
|
{'get-deps',
|
|
|
|
"sh -c 'cd deps/" ++ Pkg ++
|
2015-10-20 15:22:39 +02:00
|
|
|
" && CFLAGS=\""++ CFLags ++"\" CPPFLAGS=\""++ CPPFLags ++"\" LDFLAGS=\""++ LDFLags ++"\"" ++
|
2015-12-18 17:17:13 +01:00
|
|
|
" ./configure " ++ Flags ++ "'"}
|
2013-04-08 11:12:54 +02:00
|
|
|
end,
|
|
|
|
|
2015-12-18 17:17:13 +01:00
|
|
|
Conf = ProcessVars(ProcessVars, CONFIG, []),
|
2013-04-08 11:12:54 +02:00
|
|
|
|
2015-12-18 17:17:13 +01:00
|
|
|
Conf1 = case lists:keytake(post_hook_configure, 1, Conf) of
|
|
|
|
{value, {_, Items}, Rest} ->
|
|
|
|
[{post_hooks, [ConfigureCmd(Mod, string:join(Opts, " ")) || {Mod, Opts} <- Items]} | Rest];
|
|
|
|
_ ->
|
|
|
|
Conf
|
|
|
|
end,
|
2014-08-26 16:12:57 +02:00
|
|
|
|
2013-04-08 11:12:54 +02:00
|
|
|
{ok, Cwd} = file:get_cwd(),
|
2015-04-09 17:14:30 +02:00
|
|
|
TestConfigFile = filename:join([Cwd, "test", "config.ctc"]),
|
|
|
|
TestConfig = case file:read_file_info(TestConfigFile) of
|
|
|
|
{ok, _} ->
|
|
|
|
"-userconfig ct_config_plain " ++ TestConfigFile ++ " ";
|
|
|
|
_ ->
|
|
|
|
""
|
|
|
|
end,
|
|
|
|
|
2015-12-18 17:17:13 +01:00
|
|
|
Conf2 = [{ct_extra_params, "-ct_hooks cth_surefire "
|
|
|
|
++ TestConfig
|
|
|
|
++ "-include "
|
|
|
|
++ filename:join([Cwd, "tools"])} | Conf1],
|
|
|
|
|
|
|
|
Conf3 = case lists:keytake(xref_exclusions, 1, Conf2) of
|
|
|
|
{value, {_, Items2}, Rest2} ->
|
|
|
|
[{xref_queries, [{lists:flatten(["(XC - UC) || (XU - X - B ",
|
|
|
|
[[" - ", V] || V <- Items2], ")"]), []}]} | Rest2];
|
|
|
|
_ ->
|
|
|
|
Conf2
|
|
|
|
end,
|
|
|
|
|
|
|
|
Conf5 = case lists:keytake(floating_deps, 1, Conf3) of
|
|
|
|
{value, {_, FloatingDeps}, Rest4} ->
|
|
|
|
case lists:keytake(deps, 1, Rest4) of
|
|
|
|
{value, {_, Deps}, Rest41} ->
|
|
|
|
ND = lists:map(fun({DepName, Ver, {git, Repo, _Commit}}=Dep) ->
|
|
|
|
case lists:member(DepName, FloatingDeps) of
|
|
|
|
true ->
|
|
|
|
{DepName, ".*", {git, Repo}};
|
|
|
|
_ ->
|
|
|
|
Dep
|
|
|
|
end;
|
|
|
|
(Dep2) ->
|
|
|
|
Dep2
|
|
|
|
end, Deps),
|
|
|
|
[{deps, ND} | Rest41];
|
|
|
|
_ ->
|
|
|
|
Rest4
|
|
|
|
end;
|
|
|
|
_ ->
|
|
|
|
Conf3
|
|
|
|
end,
|
|
|
|
|
|
|
|
%io:format("ejabberd configuration:~n ~p~n", [Conf5]),
|
|
|
|
|
|
|
|
Conf5.
|
2013-04-08 11:12:54 +02:00
|
|
|
|
|
|
|
%% Local Variables:
|
|
|
|
%% mode: erlang
|
|
|
|
%% End:
|
|
|
|
%% vim: set filetype=erlang tabstop=8:
|