build: move otp version check to rebar.config.erl

This commit is contained in:
Zaiming (Stone) Shi 2022-01-31 16:27:31 +01:00
parent 4fe7b93c43
commit c643db6bca
3 changed files with 17 additions and 13 deletions

View File

@ -34,7 +34,6 @@ all: $(REBAR) $(PROFILES)
.PHONY: ensure-rebar3 .PHONY: ensure-rebar3
ensure-rebar3: ensure-rebar3:
@$(SCRIPTS)/fail-on-old-otp-version.escript
@$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION) @$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION)
.PHONY: ensure-hex .PHONY: ensure-hex

View File

@ -3,6 +3,7 @@
-export([do/2]). -export([do/2]).
do(Dir, CONFIG) -> do(Dir, CONFIG) ->
ok = assert_otp(),
case iolist_to_binary(Dir) of case iolist_to_binary(Dir) of
<<".">> -> <<".">> ->
C1 = deps(CONFIG), C1 = deps(CONFIG),
@ -12,6 +13,22 @@ do(Dir, CONFIG) ->
CONFIG CONFIG
end. end.
assert_otp() ->
Oldest = 23,
Latest = 24,
OtpRelease = list_to_integer(erlang:system_info(otp_release)),
case OtpRelease < Oldest orelse OtpRelease > Latest of
true ->
io:format(standard_error, "ERROR: Erlang/OTP version ~p found. min=~p, recommended=~p~n",
[OtpRelease, Oldest, Latest]),
halt(1);
false when OtpRelease =/= Latest ->
io:format("WARNING: Erlang/OTP version ~p found, recommended==~p~n",
[OtpRelease, Latest]);
false ->
ok
end.
bcrypt() -> bcrypt() ->
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}. {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}.

View File

@ -1,12 +0,0 @@
#!/usr/bin/env escript
main(_) ->
OtpRelease = list_to_integer(erlang:system_info(otp_release)),
case OtpRelease < 21 of
true ->
io:format(standard_error, "ERROR: Erlang/OTP version ~p found. required_min=21, recommended=23~n", [OtpRelease]),
halt(1);
false ->
ok
end.