Skip to content

Commit 53eb069

Browse files
committed
Copy support for loose deps versioning
1 parent 8fc4153 commit 53eb069

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{port_specs, [{"priv/lib/fxml.so", ["c_src/fxml.c"]},
3838
{"priv/lib/fxml_stream.so", ["c_src/fxml_stream.c"]}]}.
3939

40-
{deps, [{p1_utils, "~> 1.0.26", {git, "https://github.com/processone/p1_utils", {tag, "1.0.26"}}}]}.
40+
{deps, [{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.26"}}}]}.
4141

4242
{clean_files, ["c_src/fxml.gcda", "c_src/fxml.gcno", "c_src/fxml_stream.gcda", "c_src/fxml_stream.gcno"]}.
4343

rebar.config.script

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ Cfg = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"]))
3030
{ldflags, CfgLDFlags} = lists:keyfind(ldflags, 1, Cfg),
3131
{with_gcov, CfgWithGCov} = lists:keyfind(with_gcov, 1, Cfg),
3232

33-
IsRebar3 = case erlang:function_exported(rebar3, main, 1) of
34-
true ->
35-
true;
36-
_ ->
33+
IsRebar3 = case application:get_key(rebar, vsn) of
34+
{ok, VSN} ->
35+
[VSN1 | _] = string:tokens(VSN, "-"),
36+
[Maj|_] = string:tokens(VSN1, "."),
37+
(list_to_integer(Maj) >= 3);
38+
undefined ->
3739
lists:keymember(mix, 1, application:loaded_applications())
3840
end,
3941

@@ -77,13 +79,31 @@ AppendList = fun(Append) ->
7779
end
7880
end,
7981

80-
Rebar3DepsFilter = fun(DepsList) ->
81-
lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
82-
{DepName, Version};
83-
(Dep) ->
84-
Dep
85-
end, DepsList)
86-
end,
82+
% Convert our rich deps syntax to rebar2 format:
83+
% https://github.com/rebar/rebar/wiki/Dependency-management
84+
Rebar2DepsFilter =
85+
fun(DepsList) ->
86+
lists:map(fun({DepName, _HexVersion, Source}) ->
87+
{DepName, ".*", Source}
88+
end, DepsList)
89+
end,
90+
91+
% Convert our rich deps syntax to rebar3 version definition format:
92+
% https://rebar3.org/docs/configuration/dependencies/#dependency-version-handling
93+
% https://hexdocs.pm/elixir/Version.html
94+
Rebar3DepsFilter =
95+
fun(DepsList) ->
96+
lists:map(fun({DepName, HexVersion, {git, _, {tag, GitVersion}} = Source}) ->
97+
case HexVersion == ".*" of
98+
true ->
99+
{DepName, GitVersion};
100+
false ->
101+
{DepName, HexVersion}
102+
end;
103+
({DepName, _HexVersion, Source}) ->
104+
{DepName, ".*", Source}
105+
end, DepsList)
106+
end,
87107

88108
GlobalDepsFilter = fun(Deps) ->
89109
DepNames = lists:map(fun({DepName, _, _}) -> DepName;

0 commit comments

Comments
 (0)