-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebar.config.script
28 lines (25 loc) · 1022 Bytes
/
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
%% -*- mode: erlang; indent-tabs-mode: nil -*-
Conf0 = CONFIG,
MapString = "#{X => 1}.",
HasOpt = {d,'HAS_MAPS',true},
FullOpt = {d,'HAS_FULL_KEYS',true},
MapsOpts = case erl_scan:string(MapString) of
{ok,Ts,_} ->
case erl_parse:parse_exprs(Ts) of
{ok,Es} -> %We have maps!
Binds = [{'X',49}], %We need to bind X
case erl_lint:exprs(Es, Binds) of
{ok,_} -> [HasOpt,FullOpt];
{error,_,_} -> [HasOpt]
end;
{error,_} -> []
end;
{error,_,_} -> []
end,
case lists:keyfind(erl_opts, 1, Conf0) of
{erl_opts,Opts} -> %Existing erl_opts
NewOpts = {erl_opts,Opts ++ MapsOpts},
lists:keyreplace(erl_opts, 1, Conf0, NewOpts);
false -> %No erl_opts
Conf0 ++ [{erl_opts,MapsOpts}]
end.