From 4faa508758bf4ce8bf75a519273917b4f9d4f150 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Fri, 18 Feb 2022 11:31:56 -0600 Subject: [PATCH] Drop support for rebar2 as of Erlang 25.0 Erlang 25.0 removes the ability to load modules compiled prior to Erlang 22.0. This patch replaces the Jiffy's `enc` based build system with the `rebar3` port compiler plugin for Erlang 25.0 and newer. --- rebar.config.script | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/rebar.config.script b/rebar.config.script index a5da769..066a7c3 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -17,7 +17,7 @@ Config1 = case lists:keyfind(erl_opts, 1, CONFIG) of CONFIG ++ [{erl_opts, ErlOpts}] end, -case os:type() of +Config2 = case os:type() of {unix, _} -> CC = case os:getenv("CC") of false -> "cc"; @@ -36,4 +36,32 @@ case os:type() of end; _ -> Config1 +end, + +IsRebar3 = code:which(rebar3) /= non_existing, +OTPRel = erlang:system_info(otp_release), +OTPVsn = case re:run(OTPRel, "R?(\\d+)", [{capture, all_but_first, list}]) of + {match, [V]} -> list_to_integer(V); + nomatch -> erlang:error(unknown_otp_release) +end, + +case OTPVsn < 25 of + true -> + Config2; + false when IsRebar3 -> + Config3 = lists:keydelete(pre_hooks, 1, Config2), + Config4 = lists:keydelete(post_hooks, 1, Config3), + Config4 ++ [ + {plugins, [{pc, "~> 1.0"}]}, + {artifacts, ["priv/jiffy.so"]}, + {provider_hooks, [ + {post, [ + {compile, {pc, compile}}, + {clean, {pc, clean}} + ]} + ]} + ]; + false -> + io:format("Rebar 2 is no longer supported as of Erlang 25.0~n", []), + halt(1) end.