From 75cafb4166360bb441af666044759652ecdd88e4 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Tue, 22 Feb 2022 11:56:27 -0600 Subject: [PATCH] WIP: Allow rebar2 when compiled correctly --- rebar.config | 3 --- rebar.config.script | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/rebar.config b/rebar.config index b951b5e..4a2a240 100644 --- a/rebar.config +++ b/rebar.config @@ -35,6 +35,3 @@ {eunit_opts, [ verbose ]}. - -{pre_hooks, [{"", compile, "escript enc compile"}]}. -{post_hooks, [{"", clean, "escript enc clean"}]}. diff --git a/rebar.config.script b/rebar.config.script index 066a7c3..37deacb 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -45,13 +45,16 @@ OTPVsn = case re:run(OTPRel, "R?(\\d+)", [{capture, all_but_first, list}]) of nomatch -> erlang:error(unknown_otp_release) end, -case OTPVsn < 25 of - true -> +case {IsRebar3, OTPVsn} of + {false, _} -> Config2; - false when IsRebar3 -> - Config3 = lists:keydelete(pre_hooks, 1, Config2), - Config4 = lists:keydelete(post_hooks, 1, Config3), - Config4 ++ [ + {true, Vsn} when Vsn < 25 -> + Config2 ++ [ + {pre_hooks, [{"", compile, "escript enc compile"}]}, + {post_hooks, [{"", clean, "escript enc clean"}]} + ]; + {true, Vsn} when Vsn >= 25 -> + Config2 ++ [ {plugins, [{pc, "~> 1.0"}]}, {artifacts, ["priv/jiffy.so"]}, {provider_hooks, [ @@ -60,8 +63,5 @@ case OTPVsn < 25 of {clean, {pc, clean}} ]} ]} - ]; - false -> - io:format("Rebar 2 is no longer supported as of Erlang 25.0~n", []), - halt(1) + ] end.