Created
June 7, 2012 17:42
-
-
Save evanmcc/2890276 to your computer and use it in GitHub Desktop.
proposed rebar change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check_versions(Config) -> | |
ErtsRegex = rebar_config:get(Config, require_erts_vsn, ".*"), | |
ReOpts = [{capture, none}], | |
case re:run(erlang:system_info(version), ErtsRegex, ReOpts) of | |
match -> | |
?DEBUG("Matched required ERTS version: ~s -> ~s\n", | |
[erlang:system_info(version), ErtsRegex]); | |
nomatch -> | |
?ABORT("ERTS version ~s does not match required regex ~s\n", | |
[erlang:system_info(version), ErtsRegex]) | |
end, | |
OtpRegex = rebar_config:get(Config, require_otp_vsn, ".*"), | |
case re:run(erlang:system_info(otp_release), OtpRegex, ReOpts) of | |
match -> | |
?DEBUG("Matched required OTP release: ~s -> ~s\n", | |
[erlang:system_info(otp_release), OtpRegex]); | |
nomatch -> | |
?ABORT("OTP release ~s does not match required regex ~s\n", | |
[erlang:system_info(otp_release), OtpRegex]) | |
end, | |
MinOtpVers = rebar_config:get(Config, require_min_otp_vsn, nil), | |
if | |
MinOtpVers /= nil -> | |
{MinMaj, MinMin} = case otp_vers_to_tup(MinOtpVers, "configured") of | |
{Maj, Min} -> {Maj, Min}; | |
Other -> Other | |
end, | |
{OtpMaj, OtpMin} = case otp_vers_to_tup(erlang:system_info(otp_release), | |
"OTP Release") of | |
{Maj1, Min1} -> {Maj1, Min1}; | |
Other1 -> Other1 | |
end, | |
case OtpMaj >= MinMaj andalso OtpMin >= MinMin of | |
true -> | |
?DEBUG("OTP release ~s is later than ~s~n", | |
[erlang:system_info(otp_release), MinOtpVers]); | |
false -> | |
?ABORT("OTP release ~s is earlier than ~s~n", | |
[erlang:system_info(otp_release), MinOtpVers]) | |
end; | |
MinOtpVers == nil -> ?DEBUG("Min OTP version unconfigured~n", []) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment