Skip to content

Commit

Permalink
rebar.config.script: Supported 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 22, 2024
1 parent da947fd commit 02ecdc7
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
%%% limitations under the License.
%%%
%%%----------------------------------------------------------------------
SysVersion = lists:map(fun erlang:list_to_integer/1,
string:tokens(erlang:system_info(version), ".")),

Cfg = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"])) of
{ok, Terms} ->
Expand Down Expand Up @@ -57,7 +55,6 @@ ProcessVars = fun(_F, [], Acc) ->
(F, [{Type, Ver, Value} | Tail], Acc) when
Type == if_version_above orelse
Type == if_version_below ->
SysVer = erlang:system_info(otp_release),
Include = if Type == if_version_above ->
SysVer > Ver;
true ->
Expand Down Expand Up @@ -167,13 +164,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 @@ -207,6 +222,8 @@ GithubConfig = case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of
end,

Rules = [
{[deps], (not IsRebar3),
Rebar2DepsFilter, []},
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[plugins], IsRebar3,
Expand Down

0 comments on commit 02ecdc7

Please sign in to comment.