xmpp.chapril.org-ejabberd/rebar.config.script

200 lines
7.2 KiB
Plaintext
Raw Normal View History

%%%-------------------------------------------------------------------
%%% @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>
%%%-------------------------------------------------------------------
{require_min_otp_vsn, "16"}.
Cfg = case file:consult("vars.config") of
{ok, Terms} ->
Terms;
_Err ->
[]
end,
Macros = lists:flatmap(
fun({roster_gateway_workaround, true}) ->
[{d, 'ROSTER_GATEWAY_WORKAROUND'}];
({db_type, mssql}) ->
[{d, 'mssql'}];
({lager, true}) ->
[{d, 'LAGER'}];
({erlang_deprecated_types, true}) ->
[{d, 'ERL_DEPRECATED_TYPES'}];
(_) ->
[]
end, Cfg),
DebugInfo = case lists:keysearch(debug, 1, Cfg) of
{value, {debug, true}} ->
[];
_ ->
[no_debug_info]
end,
HiPE = case lists:keysearch(hipe, 1, Cfg) of
{value, {hipe, true}} ->
[native];
_ ->
[]
end,
SrcDirs = lists:foldl(
fun({tools, true}, Acc) ->
[tools|Acc];
(_, Acc) ->
Acc
end, [], Cfg),
2015-12-01 19:17:51 +01:00
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"}},
2015-09-25 16:39:47 +02:00
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils"}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy"}},
{oauth2, ".*", {git, "https://github.com/prefiks/oauth2.git"}},
2015-09-25 16:39:47 +02:00
{xmlrpc, ".*", {git, "https://github.com/rds13/xmlrpc.git"}}],
CFLags = proplists:get_value(cflags, Cfg, ""),
CPPFLags = proplists:get_value(cppflags, Cfg, ""),
LDFLags = proplists:get_value(ldflags, Cfg, ""),
ConfigureCmd = fun(Pkg, Flags) ->
{'get-deps',
"sh -c 'cd deps/" ++ Pkg ++
" && CFLAGS=\""++ CFLags ++"\" CPPFLAGS=\""++ CPPFLags ++"\" LDFLAGS=\""++ LDFLags ++"\"" ++
" ./configure" ++ Flags ++ "'"}
end,
XMLFlags = lists:foldl(
fun({full_xml, true}, Acc) ->
Acc ++ " --enable-full-xml";
(_, Acc) ->
Acc
end, "", Cfg),
PostHooks = [ConfigureCmd("p1_tls", ""),
ConfigureCmd("p1_stringprep", ""),
ConfigureCmd("p1_yaml", ""),
2014-05-02 15:27:46 +02:00
ConfigureCmd("esip", ""),
ConfigureCmd("p1_xml", XMLFlags)],
CfgDeps = lists:flatmap(
fun({mysql, true}) ->
[{p1_mysql, ".*", {git, "https://github.com/processone/mysql"}}];
({pgsql, true}) ->
[{p1_pgsql, ".*", {git, "https://github.com/processone/pgsql"}}];
2015-03-16 19:53:19 +01:00
({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"}}];
2014-07-09 14:40:06 +02:00
({riak, true}) ->
2015-11-23 10:50:08 +01:00
[{riakc, ".*", {git, "https://github.com/basho/riak-erlang-client"}}];
2015-01-29 18:43:47 +01:00
({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}) ->
2015-11-23 10:50:08 +01:00
[{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),
2015-01-29 18:43:47 +01:00
ElixirConfig = case lists:keysearch(elixir, 1, Cfg) of
{value, {elixir, true}} ->
[{plugins, [deps_erl_opts, rebar_elixir_compiler, rebar_exunit] },
2015-01-29 18:43:47 +01:00
{lib_dirs, ["deps/elixir/lib"]}];
_ ->
[{plugins, [deps_erl_opts]}]
2015-01-29 18:43:47 +01:00
end,
{ok, Cwd} = file:get_cwd(),
TestConfigFile = filename:join([Cwd, "test", "config.ctc"]),
TestConfig = case file:read_file_info(TestConfigFile) of
{ok, _} ->
"-userconfig ct_config_plain " ++ TestConfigFile ++ " ";
_ ->
""
end,
AllDeps0 = Deps ++ CfgDeps,
AllDeps = case lists:keytake(lager, 1, AllDeps0) of
{value, Tuple, Rest} -> [Tuple|Rest];
false -> AllDeps0
end,
Config = [{erl_opts, Macros ++ HiPE ++ DebugInfo ++
[{src_dirs, [asn1, src | SrcDirs]}]},
{deps_erl_opts, HiPE},
{sub_dirs, ["rel"]},
{keep_build_info, true},
{ct_extra_params, "-ct_hooks cth_surefire "
++ TestConfig
++ "-include " ++ filename:join([Cwd, "tools"])},
{xref_warnings, false},
{xref_checks, [deprecated_function_calls]},
{xref_queries,
[{"(XC - UC) || (XU - X - B - "
2014-10-30 16:51:01 +01:00
++ string:join(CfgXrefs, " - ") ++ ")", []}]},
{post_hooks, PostHooks ++ CfgPostHooks},
{deps, AllDeps}] ++ ElixirConfig,
%%io:format("ejabberd configuration:~n ~p~n", [Config]),
Config.
%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8: