mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Make compatible with rebar3
This commit is contained in:
parent
49f1275e20
commit
28d0a1b9d2
@ -21,6 +21,14 @@ ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
|
||||
end,
|
||||
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end,
|
||||
|
||||
IsRebar3 = case application:get_key(rebar, vsn) of
|
||||
{ok, VSN} ->
|
||||
[VSN1 | _] = string:tokens(VSN, "-"),
|
||||
[Maj, Min, Patch] = string:tokens(VSN1, "."),
|
||||
(list_to_integer(Maj) >= 3);
|
||||
undefined ->
|
||||
lists:keymember(mix, 1, application:loaded_applications())
|
||||
end,
|
||||
Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of
|
||||
{ok, Terms} ->
|
||||
Terms;
|
||||
@ -121,16 +129,62 @@ TestConfig = case file:read_file_info(TestConfigFile) of
|
||||
""
|
||||
end,
|
||||
|
||||
ResolveDepPath = case IsRebar3 of
|
||||
true ->
|
||||
fun("deps/" ++ Rest) ->
|
||||
Slash = string:str(Rest, "/"),
|
||||
Dir = "_build/default/lib/" ++
|
||||
string:sub_string(Rest, 1, Slash-1),
|
||||
Dir ++ string:sub_string(Rest, Slash);
|
||||
(Path) ->
|
||||
Path
|
||||
end;
|
||||
_ ->
|
||||
fun(P) ->
|
||||
P
|
||||
end
|
||||
end,
|
||||
|
||||
CtIncludes = case lists:keyfind(eunit_compile_opts, 1, Conf1) of
|
||||
false ->
|
||||
[];
|
||||
{_, EunitCompOpts} ->
|
||||
[[" -include ", filename:join([Cwd, IncPath])]
|
||||
[[" -include ", filename:join([Cwd, ResolveDepPath(IncPath)])]
|
||||
|| {i, IncPath} <- EunitCompOpts]
|
||||
end,
|
||||
|
||||
Conf2 = [{ct_extra_params, lists:flatten(["-ct_hooks cth_surefire ", TestConfig,
|
||||
CtIncludes])} | Conf1],
|
||||
ProcessErlOpt = fun({i, Path}) ->
|
||||
{i, ResolveDepPath(Path)};
|
||||
(ErlOpt) ->
|
||||
ErlOpt
|
||||
end,
|
||||
|
||||
Conf1a = ModCfg(Conf1, [erl_opts],
|
||||
fun(ErlOpts) -> lists:map(ProcessErlOpt, ErlOpts) end, []),
|
||||
|
||||
Conf2a = [{ct_extra_params, lists:flatten(["-ct_hooks cth_surefire ", TestConfig,
|
||||
CtIncludes])} | Conf1a],
|
||||
|
||||
Conf2 = case IsRebar3 of
|
||||
true ->
|
||||
DepsFun = fun(DepsList) ->
|
||||
lists:filtermap(fun({rebar_elixir_plugin, _, _}) ->
|
||||
false;
|
||||
({DepName,_, {git,_, _} = Git}) ->
|
||||
{true, {DepName, Git}};
|
||||
(Dep) ->
|
||||
true
|
||||
end, DepsList)
|
||||
end,
|
||||
RB1 = ModCfg(Conf2a, [deps], DepsFun, []),
|
||||
ModCfg(RB1, [plugins], fun(V) -> V -- [deps_erl_opts,
|
||||
rebar_elixir_compiler,
|
||||
rebar_exunit] ++
|
||||
[rebar3_hex] end, []);
|
||||
false ->
|
||||
Conf2a
|
||||
end,
|
||||
|
||||
|
||||
Conf3 = case lists:keytake(xref_exclusions, 1, Conf2) of
|
||||
{value, {_, Items2}, Rest2} ->
|
||||
|
Loading…
Reference in New Issue
Block a user