mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Convert rebar.config.script to more declarative format
This commit is contained in:
parent
bb5a8a42c3
commit
99fdba0745
89
rebar.config
Normal file
89
rebar.config
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @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>
|
||||||
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
|
{deps, [{if_var_true, lager, {lager, ".*", {git, "git://github.com/basho/lager"}}},
|
||||||
|
{if_var_false, lager, {p1_logger, ".*", {git, "git://github.com/processone/p1_logger"}}},
|
||||||
|
{cache_tab, ".*", {git, "git://github.com/processone/cache_tab", {tag, "1.0.1"}}},
|
||||||
|
{p1_tls, ".*", {git, "https://github.com/processone/tls"}},
|
||||||
|
{p1_stringprep, ".*", {git, "git://github.com/processone/stringprep"}},
|
||||||
|
{p1_xml, ".*", {git, "https://github.com/processone/xml"}},
|
||||||
|
{esip, ".*", {git, "git://github.com/processone/p1_sip"}},
|
||||||
|
{p1_stun, ".*", {git, "git://github.com/processone/stun"}},
|
||||||
|
{p1_yaml, ".*", {git, "git://github.com/processone/p1_yaml"}},
|
||||||
|
{p1_utils, ".*", {git, "git://github.com/processone/p1_utils"}},
|
||||||
|
{jiffy, ".*", {git, "git://github.com/davisp/jiffy"}},
|
||||||
|
{oauth2, ".*", {git, "https://github.com/prefiks/oauth2.git"}},
|
||||||
|
{xmlrpc, ".*", {git, "git://github.com/rds13/xmlrpc"}},
|
||||||
|
{if_var_true, mysql, {p1_mysql, ".*", {git, "git://github.com/processone/mysql"}}},
|
||||||
|
{if_var_true, pgsql, {p1_pgsql, ".*", {git, "git://github.com/processone/pgsql"}}},
|
||||||
|
{if_var_true, sqlite, {sqlite3, ".*", {git, "git://github.com/alexeyr/erlang-sqlite3"}}},
|
||||||
|
{if_var_true, pam, {p1_pam, ".*", {git, "git://github.com/processone/epam"}}},
|
||||||
|
{if_var_true, zlib, {p1_zlib, ".*", {git, "git://github.com/processone/zlib"}}},
|
||||||
|
{if_var_true, riak, {riakc, ".*", {git, "git://github.com/basho/riak-erlang-client"}}},
|
||||||
|
{if_var_true, elixir, {rebar_elixir_plugin, ".*", {git, "git@github.com:processone/rebar_elixir_plugin.git"}}},
|
||||||
|
{if_var_true, elixir, {elixir, ".*", {git, "git://github.com/elixir-lang/elixir", {branch, "v1.0"}}}},
|
||||||
|
{if_var_true, iconv, {p1_iconv, ".*", {git, "git://github.com/processone/eiconv"}}},
|
||||||
|
{if_var_true, tools, {meck, "0.8.2", {git, "https://github.com/eproxus/meck", {tag, "0.8.2"}}}},
|
||||||
|
{if_var_true, redis, {eredis, ".*", {git, "git://github.com/wooga/eredis"}}}]}.
|
||||||
|
|
||||||
|
{erl_opts, [nowarn_deprecated_function,
|
||||||
|
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
|
||||||
|
{if_var_match, db_type, mssql, {d, 'mssql'}},
|
||||||
|
{if_var_true, lager, {d, 'LAGER'}},
|
||||||
|
{if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}},
|
||||||
|
{if_var_true, hipe, native},
|
||||||
|
{src_dirs, [asn1, src,
|
||||||
|
{if_var_true, tools, tools},
|
||||||
|
{if_var_true, elixir, include}]}]}.
|
||||||
|
|
||||||
|
{deps_erl_opts, [{if_var_true, hipe, native}]}.
|
||||||
|
|
||||||
|
{plugins, [deps_erl_opts,
|
||||||
|
{if_var_true, elixir, rebar_elixir_compiler},
|
||||||
|
{if_var_true, elixir, rebar_exunit}]}.
|
||||||
|
|
||||||
|
{lib_dirs, [{if_var_true, elixir, "deps/elixir/lib"}]}.
|
||||||
|
|
||||||
|
{sub_dirs, ["rel"]}.
|
||||||
|
|
||||||
|
{keep_build_info, true}.
|
||||||
|
|
||||||
|
{xref_warnings, false}.
|
||||||
|
|
||||||
|
{xref_checks, [deprecated_function_calls]}.
|
||||||
|
|
||||||
|
{xref_exclusions, [
|
||||||
|
"(\"gen_transport\":_/_)",
|
||||||
|
"(\"eprof\":_/_)",
|
||||||
|
{if_var_false, mysql, "(\".*mysql.*\":_/_)"},
|
||||||
|
{if_var_false, pgsql, "(\".*pgsql.*\":_/_)"},
|
||||||
|
{if_var_false, pam, "(\"epam\":_/_)"},
|
||||||
|
{if_var_false, riak, "(\"riak.*\":_/_)"},
|
||||||
|
{if_var_true, riak, "(\"riak_object\":_/_)"},
|
||||||
|
{if_var_false, zlib, "(\"ezlib\":_/_)"},
|
||||||
|
{if_var_false, http, "(\"lhttpc\":_/_)"},
|
||||||
|
{if_var_false, iconv, "(\"iconv\":_/_)"},
|
||||||
|
{if_var_false, odbc, "(\"odbc\":_/_)"},
|
||||||
|
{if_var_false, sqlite, "(\"sqlite3\":_/_)"},
|
||||||
|
{if_var_false, redis, "(\"eredis\":_/_)"}]}.
|
||||||
|
|
||||||
|
{eunit_compile_opts, [{i, "tools"}]}.
|
||||||
|
|
||||||
|
{post_hook_configure, [{"p1_tls", []},
|
||||||
|
{"p1_stringprep", []},
|
||||||
|
{"p1_yaml", []},
|
||||||
|
{"esip", []},
|
||||||
|
{"p1_xml", [{if_var_true, full_xml, "--enable-full-xml"}]},
|
||||||
|
{if_var_true, pam, {"p1_pam", []}},
|
||||||
|
{if_var_true, zlib, {"p1_zlib", []}},
|
||||||
|
{if_var_true, iconv, {"p1_iconv", []}}]}.
|
||||||
|
|
||||||
|
{port_env, [{"CFLAGS", "-g -O2 -Wall"}]}.
|
||||||
|
|
||||||
|
{port_specs, [{"priv/lib/jid.so", ["c_src/jid.c"]}]}.
|
@ -7,8 +7,6 @@
|
|||||||
%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
{require_min_otp_vsn, "16"}.
|
|
||||||
|
|
||||||
Cfg = case file:consult("vars.config") of
|
Cfg = case file:consult("vars.config") of
|
||||||
{ok, Terms} ->
|
{ok, Terms} ->
|
||||||
Terms;
|
Terms;
|
||||||
@ -16,51 +14,34 @@ Cfg = case file:consult("vars.config") of
|
|||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Macros = lists:flatmap(
|
ProcessVars = fun(_F, [], Acc) ->
|
||||||
fun({roster_gateway_workaround, true}) ->
|
lists:reverse(Acc);
|
||||||
[{d, 'ROSTER_GATEWAY_WORKAROUND'}];
|
(F, [{Type, Var, Value} | Tail], Acc) when
|
||||||
({db_type, mssql}) ->
|
Type == if_var_true orelse
|
||||||
[{d, 'mssql'}];
|
Type == if_var_false ->
|
||||||
({lager, true}) ->
|
Flag = Type == if_var_true,
|
||||||
[{d, 'LAGER'}];
|
case proplists:get_bool(Var, Cfg) of
|
||||||
({erlang_deprecated_types, true}) ->
|
V when V == Flag ->
|
||||||
[{d, 'ERL_DEPRECATED_TYPES'}];
|
F(F, Tail, [Value | Acc]);
|
||||||
(_) ->
|
_ ->
|
||||||
[]
|
F(F, Tail, Acc)
|
||||||
end, Cfg),
|
end;
|
||||||
|
(F, [{Type, Var, Match, Value} | Tail], Acc) when
|
||||||
DebugInfo = case lists:keysearch(debug, 1, Cfg) of
|
Type == if_var_match orelse
|
||||||
{value, {debug, true}} ->
|
Type == if_var_no_match ->
|
||||||
[];
|
case proplists:get_value(Var, Cfg) of
|
||||||
_ ->
|
V when V == Match ->
|
||||||
[no_debug_info]
|
F(F, Tail, [Value | Acc]);
|
||||||
end,
|
_ ->
|
||||||
|
F(F, Tail, Acc)
|
||||||
HiPE = case lists:keysearch(hipe, 1, Cfg) of
|
end;
|
||||||
{value, {hipe, true}} ->
|
(F, [Other1 | Tail1], Acc) ->
|
||||||
[native];
|
F(F, Tail1, [F(F, Other1, []) | Acc]);
|
||||||
_ ->
|
(F, Val, Acc) when is_tuple(Val) ->
|
||||||
[]
|
list_to_tuple(F(F, tuple_to_list(Val), Acc));
|
||||||
end,
|
(_F, Other2, _Acc) ->
|
||||||
|
Other2
|
||||||
SrcDirs = lists:foldl(
|
end,
|
||||||
fun({tools, true}, Acc) ->
|
|
||||||
[tools|Acc];
|
|
||||||
(_, Acc) ->
|
|
||||||
Acc
|
|
||||||
end, [], Cfg),
|
|
||||||
|
|
||||||
Deps = [{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.1"}}},
|
|
||||||
{p1_tls, ".*", {git, "https://github.com/processone/tls"}},
|
|
||||||
{p1_stringprep, ".*", {git, "https://github.com/processone/stringprep"}},
|
|
||||||
{p1_xml, ".*", {git, "https://github.com/processone/xml"}},
|
|
||||||
{esip, ".*", {git, "https://github.com/processone/p1_sip"}},
|
|
||||||
{p1_stun, ".*", {git, "https://github.com/processone/stun"}},
|
|
||||||
{p1_yaml, ".*", {git, "https://github.com/processone/p1_yaml"}},
|
|
||||||
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils"}},
|
|
||||||
{jiffy, ".*", {git, "https://github.com/davisp/jiffy"}},
|
|
||||||
{oauth2, ".*", {git, "https://github.com/prefiks/oauth2.git"}},
|
|
||||||
{xmlrpc, ".*", {git, "https://github.com/rds13/xmlrpc.git"}}],
|
|
||||||
|
|
||||||
CFLags = proplists:get_value(cflags, Cfg, ""),
|
CFLags = proplists:get_value(cflags, Cfg, ""),
|
||||||
CPPFLags = proplists:get_value(cppflags, Cfg, ""),
|
CPPFLags = proplists:get_value(cppflags, Cfg, ""),
|
||||||
@ -70,97 +51,19 @@ ConfigureCmd = fun(Pkg, Flags) ->
|
|||||||
{'get-deps',
|
{'get-deps',
|
||||||
"sh -c 'cd deps/" ++ Pkg ++
|
"sh -c 'cd deps/" ++ Pkg ++
|
||||||
" && CFLAGS=\""++ CFLags ++"\" CPPFLAGS=\""++ CPPFLags ++"\" LDFLAGS=\""++ LDFLags ++"\"" ++
|
" && CFLAGS=\""++ CFLags ++"\" CPPFLAGS=\""++ CPPFLags ++"\" LDFLAGS=\""++ LDFLags ++"\"" ++
|
||||||
" ./configure" ++ Flags ++ "'"}
|
" ./configure " ++ Flags ++ "'"}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
XMLFlags = lists:foldl(
|
Conf = ProcessVars(ProcessVars, CONFIG, []),
|
||||||
fun({full_xml, true}, Acc) ->
|
|
||||||
Acc ++ " --enable-full-xml";
|
|
||||||
(_, Acc) ->
|
|
||||||
Acc
|
|
||||||
end, "", Cfg),
|
|
||||||
|
|
||||||
PostHooks = [ConfigureCmd("p1_tls", ""),
|
Conf1 = case lists:keytake(post_hook_configure, 1, Conf) of
|
||||||
ConfigureCmd("p1_stringprep", ""),
|
{value, {_, Items}, Rest} ->
|
||||||
ConfigureCmd("p1_yaml", ""),
|
[{post_hooks, [ConfigureCmd(Mod, string:join(Opts, " ")) || {Mod, Opts} <- Items]} | Rest];
|
||||||
ConfigureCmd("esip", ""),
|
_ ->
|
||||||
ConfigureCmd("p1_xml", XMLFlags)],
|
Conf
|
||||||
|
end,
|
||||||
CfgDeps = lists:flatmap(
|
|
||||||
fun({mysql, true}) ->
|
|
||||||
[{p1_mysql, ".*", {git, "https://github.com/processone/mysql"}}];
|
|
||||||
({pgsql, true}) ->
|
|
||||||
[{p1_pgsql, ".*", {git, "https://github.com/processone/pgsql"}}];
|
|
||||||
({sqlite, true}) ->
|
|
||||||
[{sqlite3, ".*", {git, "https://github.com/alexeyr/erlang-sqlite3"}}];
|
|
||||||
({pam, true}) ->
|
|
||||||
[{p1_pam, ".*", {git, "https://github.com/processone/epam"}}];
|
|
||||||
({zlib, true}) ->
|
|
||||||
[{p1_zlib, ".*", {git, "https://github.com/processone/zlib"}}];
|
|
||||||
({riak, true}) ->
|
|
||||||
[{riakc, ".*", {git, "https://github.com/basho/riak-erlang-client"}}];
|
|
||||||
({elixir, true}) ->
|
|
||||||
[{rebar_elixir_plugin, ".*", {git, "https://github.com/yrashk/rebar_elixir_plugin"}},
|
|
||||||
{elixir, ".*", {git, "https://github.com/elixir-lang/elixir", {branch, "v1.0"}}}];
|
|
||||||
({iconv, true}) ->
|
|
||||||
[{p1_iconv, ".*", {git, "https://github.com/processone/eiconv"}}];
|
|
||||||
({lager, true}) ->
|
|
||||||
[{lager, ".*", {git, "https://github.com/basho/lager"}}];
|
|
||||||
({lager, false}) ->
|
|
||||||
[{p1_logger, ".*", {git, "https://github.com/processone/p1_logger"}}];
|
|
||||||
({tools, true}) ->
|
|
||||||
[{meck, "0.8.2", {git, "https://github.com/eproxus/meck", {tag, "0.8.2"}}}];
|
|
||||||
({redis, true}) ->
|
|
||||||
[{eredis, ".*", {git, "https://github.com/wooga/eredis"}}];
|
|
||||||
(_) ->
|
|
||||||
[]
|
|
||||||
end, Cfg),
|
|
||||||
|
|
||||||
CfgPostHooks = lists:flatmap(
|
|
||||||
fun({pam, true}) ->
|
|
||||||
[ConfigureCmd("p1_pam", "")];
|
|
||||||
({zlib, true}) ->
|
|
||||||
[ConfigureCmd("p1_zlib", "")];
|
|
||||||
({iconv, true}) ->
|
|
||||||
[ConfigureCmd("p1_iconv", "")];
|
|
||||||
(_) ->
|
|
||||||
[]
|
|
||||||
end, Cfg),
|
|
||||||
|
|
||||||
CfgXrefs = lists:flatmap(
|
|
||||||
fun({mysql, false}) ->
|
|
||||||
["(\".*mysql.*\":_/_)"];
|
|
||||||
({pgsql, false}) ->
|
|
||||||
["(\".*pgsql.*\":_/_)"];
|
|
||||||
({pam, false}) ->
|
|
||||||
["(\"epam\":_/_)"];
|
|
||||||
({riak, false}) ->
|
|
||||||
["(\"riak.*\":_/_)"];
|
|
||||||
({riak, true}) ->
|
|
||||||
% used in map-reduce function called from riak vm
|
|
||||||
["(\"riak_object\":_/_)"];
|
|
||||||
({zlib, false}) ->
|
|
||||||
["(\"ezlib\":_/_)"];
|
|
||||||
({http, false}) ->
|
|
||||||
["(\"lhttpc\":_/_)"];
|
|
||||||
({iconv, false}) ->
|
|
||||||
["(\"iconv\":_/_)"];
|
|
||||||
({odbc, false}) ->
|
|
||||||
["(\"odbc\":_/_)"];
|
|
||||||
(_) ->
|
|
||||||
[]
|
|
||||||
end, Cfg),
|
|
||||||
|
|
||||||
ElixirConfig = case lists:keysearch(elixir, 1, Cfg) of
|
|
||||||
{value, {elixir, true}} ->
|
|
||||||
[{plugins, [deps_erl_opts, rebar_elixir_compiler, rebar_exunit] },
|
|
||||||
{lib_dirs, ["deps/elixir/lib"]}];
|
|
||||||
_ ->
|
|
||||||
[{plugins, [deps_erl_opts]}]
|
|
||||||
end,
|
|
||||||
|
|
||||||
{ok, Cwd} = file:get_cwd(),
|
{ok, Cwd} = file:get_cwd(),
|
||||||
|
|
||||||
TestConfigFile = filename:join([Cwd, "test", "config.ctc"]),
|
TestConfigFile = filename:join([Cwd, "test", "config.ctc"]),
|
||||||
TestConfig = case file:read_file_info(TestConfigFile) of
|
TestConfig = case file:read_file_info(TestConfigFile) of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
@ -169,29 +72,44 @@ TestConfig = case file:read_file_info(TestConfigFile) of
|
|||||||
""
|
""
|
||||||
end,
|
end,
|
||||||
|
|
||||||
AllDeps0 = Deps ++ CfgDeps,
|
Conf2 = [{ct_extra_params, "-ct_hooks cth_surefire "
|
||||||
AllDeps = case lists:keytake(lager, 1, AllDeps0) of
|
++ TestConfig
|
||||||
{value, Tuple, Rest} -> [Tuple|Rest];
|
++ "-include "
|
||||||
false -> AllDeps0
|
++ filename:join([Cwd, "tools"])} | Conf1],
|
||||||
end,
|
|
||||||
|
|
||||||
Config = [{erl_opts, Macros ++ HiPE ++ DebugInfo ++
|
Conf3 = case lists:keytake(xref_exclusions, 1, Conf2) of
|
||||||
[{src_dirs, [asn1, src | SrcDirs]}]},
|
{value, {_, Items2}, Rest2} ->
|
||||||
{deps_erl_opts, HiPE},
|
[{xref_queries, [{lists:flatten(["(XC - UC) || (XU - X - B ",
|
||||||
{sub_dirs, ["rel"]},
|
[[" - ", V] || V <- Items2], ")"]), []}]} | Rest2];
|
||||||
{keep_build_info, true},
|
_ ->
|
||||||
{ct_extra_params, "-ct_hooks cth_surefire "
|
Conf2
|
||||||
++ TestConfig
|
end,
|
||||||
++ "-include " ++ filename:join([Cwd, "tools"])},
|
|
||||||
{xref_warnings, false},
|
Conf5 = case lists:keytake(floating_deps, 1, Conf3) of
|
||||||
{xref_checks, [deprecated_function_calls]},
|
{value, {_, FloatingDeps}, Rest4} ->
|
||||||
{xref_queries,
|
case lists:keytake(deps, 1, Rest4) of
|
||||||
[{"(XC - UC) || (XU - X - B - "
|
{value, {_, Deps}, Rest41} ->
|
||||||
++ string:join(CfgXrefs, " - ") ++ ")", []}]},
|
ND = lists:map(fun({DepName, Ver, {git, Repo, _Commit}}=Dep) ->
|
||||||
{post_hooks, PostHooks ++ CfgPostHooks},
|
case lists:member(DepName, FloatingDeps) of
|
||||||
{deps, AllDeps}] ++ ElixirConfig,
|
true ->
|
||||||
%%io:format("ejabberd configuration:~n ~p~n", [Config]),
|
{DepName, ".*", {git, Repo}};
|
||||||
Config.
|
_ ->
|
||||||
|
Dep
|
||||||
|
end;
|
||||||
|
(Dep2) ->
|
||||||
|
Dep2
|
||||||
|
end, Deps),
|
||||||
|
[{deps, ND} | Rest41];
|
||||||
|
_ ->
|
||||||
|
Rest4
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
Conf3
|
||||||
|
end,
|
||||||
|
|
||||||
|
%io:format("ejabberd configuration:~n ~p~n", [Conf5]),
|
||||||
|
|
||||||
|
Conf5.
|
||||||
|
|
||||||
%% Local Variables:
|
%% Local Variables:
|
||||||
%% mode: erlang
|
%% mode: erlang
|
||||||
|
Loading…
Reference in New Issue
Block a user