Skip to content

Commit

Permalink
rebar.config.script: Support relaxed dependency version (#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 22, 2024
1 parent 0345f79 commit 1a63443
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,35 @@ AppendList2 = fun(Append) ->
end
end,

% Convert our rich deps syntax to rebar2 format:
% https://github.com/rebar/rebar/wiki/Dependency-management
Rebar2DepsFilter =
fun(DepsList, GitOnlyDeps) ->
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, GitOnlyDeps) ->
lists:map(fun({DepName, _, {git, _, {tag, Version}}} = Dep) ->
case lists:member(DepName, GitOnlyDeps) of
true ->
Dep;
_ ->
{DepName, Version}
lists:map(fun({DepName, HexVersion, {git, _, {tag, GitVersion}} = Source}) ->
case {lists:member(DepName, GitOnlyDeps), HexVersion == ".*"} of
{true, _} ->
{DepName, ".*", Source};
{false, true} ->
{DepName, GitVersion};
{false, false} ->
{DepName, HexVersion}
end;
(Dep) ->
Dep
({DepName, _HexVersion, Source}) ->
{DepName, ".*", Source}
end, DepsList)
end,


DepAlts = fun("esip") -> ["esip", "p1_sip"];
("xmpp") -> ["xmpp", "p1_xmpp"];
("fast_xml") -> ["fast_xml", "p1_xml"];
Expand Down Expand Up @@ -423,6 +438,8 @@ Rules = [
ProcessRelx, [], []},
{[deps], [floating_deps], true,
ProcessFloatingDeps, [], []},
{[deps], [gitonly_deps], (not IsRebar3),
Rebar2DepsFilter, [], []},
{[deps], [gitonly_deps], IsRebar3,
Rebar3DepsFilter, [], []},
{[deps], SystemDeps /= false,
Expand Down

0 comments on commit 1a63443

Please sign in to comment.