forked from bragful/ephp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebar.config.script
31 lines (31 loc) · 1.09 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
NATIVE_FLOOR = case erlang:function_exported(erlang, floor, 1) of
true -> [{d, 'NATIVE_FLOOR', "1"}];
false -> []
end,
NATIVE_CEIL = case erlang:function_exported(erlang, ceil, 1) of
true -> [{d, 'NATIVE_CEIL', "1"}];
false -> []
end,
STRING_REPLACE = case erlang:function_exported(string, replace, 3) of
true -> [{d, 'NATIVE_STR_REPLACE', "1"}];
false -> []
end,
PCRE_VERSION = case erlang:function_exported(re, version, 0) of
false -> {d, 'PCRE_VERSION', "8.02 2010-03-19"};
true -> {d, 'PCRE_VERSION', binary_to_list(re:version())}
end,
case filelib:is_regular(".build_date") of
true -> ok;
false -> os:cmd("LANG=POSIX date '+%b %d %Y %T' > .build_date")
end,
BuildDate = binary_to_list(element(2,file:read_file(".build_date"))),
ErlOpts = lists:filter(fun
({d, 'BUILD_DATE', _}) -> false;
(_) -> true
end, proplists:get_value(erl_opts, CONFIG)),
OldErlOpts = [{erl_opts, ErlOpts}],
NewErlOpts = [{erl_opts, [
{d, 'BUILD_DATE', BuildDate},
PCRE_VERSION
|ErlOpts] ++ NATIVE_FLOOR ++ NATIVE_CEIL ++ STRING_REPLACE}],
(CONFIG -- OldErlOpts) ++ NewErlOpts.