-
Notifications
You must be signed in to change notification settings - Fork 1
/
rebar.config.script
48 lines (44 loc) · 1.71 KB
/
rebar.config.script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% vim: set ft=erlang:
begin
TakeOutPlugin
= fun (Config, Name) ->
{project_plugins, ProjPlugins}
= lists:keyfind(project_plugins, 1, Config),
{value, {Name, _PluginVersion}, RemainingProjPlugins}
= lists:keytake(Name, 1, ProjPlugins),
_UpdatedConfig
= lists:keystore(project_plugins, 1, Config,
{project_plugins, RemainingProjPlugins})
end,
TakeOutHankIfMaybeExprNotEnabledOnEnv
= fun (Config) ->
Env = os:getenv(),
case [V || "ERL_FLAGS=" ++ V <- Env] of
[Flags | _] ->
% katana-code (a dependent of rebar3_hank) requires maybe_expr
case string:find(Flags, "-enable-feature maybe_expr") of
nomatch ->
TakeOutPlugin(Config, rebar3_hank);
_ ->
Config
end;
[] ->
TakeOutPlugin(Config, rebar3_hank)
end
end,
OtpRelease = erlang:system_info(otp_release),
try list_to_integer(OtpRelease) of
Unsupported when Unsupported =< 23 ->
% Don't import plugins that may no longer run (or even compile) under older OTP versions
{value, {project_plugins, _}, RemainingConfig} = lists:keytake(project_plugins, 1, CONFIG),
RemainingConfig;
25 ->
TakeOutHankIfMaybeExprNotEnabledOnEnv(CONFIG);
_ ->
CONFIG
catch
error:badarg ->
logger:warning("Don't now how to compare to OTP release: ~tp", [OtpRelease]),
CONFIG
end
end.