Skip to content

Commit

Permalink
rebar.config.script: Support relaxed deps (processone/ejabberd#4192)
Browse files Browse the repository at this point in the history
Instead of adding another element to the tuple, let's reuse the second
element, which was used only by rebar2, and always has ".*" as value.
  • Loading branch information
badlop committed Apr 23, 2024
1 parent 401894a commit c13ae51
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,31 @@ AppendList = fun(Append) ->
end
end,

Rebar3DepsFilter = fun(DepsList) ->
lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
{DepName, Version};
(Dep) ->
Dep
end, DepsList)
end,
% Convert our rich deps syntax to rebar2 format:
% https://github.com/rebar/rebar/wiki/Dependency-management
Rebar2DepsFilter =
fun(DepsList) ->
lists:map(fun({DepName, _HexVersion, Source}) ->
{DepName, ".*", Source}
end, DepsList)
end,

% Convert our rich deps syntax to rebar3 version definition format:
% https://rebar3.org/docs/configuration/dependencies/#dependency-version-handling
% https://hexdocs.pm/elixir/Version.html
Rebar3DepsFilter =
fun(DepsList) ->
lists:map(fun({DepName, HexVersion, {git, _, {tag, GitVersion}} = Source}) ->
case HexVersion == ".*" of
true ->
{DepName, GitVersion};
false ->
{DepName, HexVersion}
end;
({DepName, _HexVersion, Source}) ->
{DepName, ".*", Source}
end, DepsList)
end,

GlobalDepsFilter = fun(Deps) ->
DepNames = lists:map(fun({DepName, _, _}) -> DepName;
Expand Down Expand Up @@ -156,6 +174,8 @@ Rules = [
AppendStr("--coverage"), ""},
{[port_env, "CFLAGS"], CfgWithGCov == "true",
AppendStr("--coverage"), ""},
{[deps], (not IsRebar3),
Rebar2DepsFilter, []},
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[plugins], IsRebar3,
Expand Down

0 comments on commit c13ae51

Please sign in to comment.