-
Notifications
You must be signed in to change notification settings - Fork 153
/
rebar.config.script
72 lines (58 loc) · 2.53 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
%% -*- erlang -*-
NoHaveMapsOpts = try maps:size(maps:new()) of
0 -> []
catch error:undef -> [{d,'NO_HAVE_MAPS',true}]
end.
%% In Erlang 19, the random module is deprecated
NoHaveRandOpts = try rand:uniform() of
F when is_float(F) -> []
catch error:undef -> [{d,'NO_HAVE_RAND',true}]
end.
%% In Erlang 21, a number of string module functions are deprecated:
%% string:join/2 -> lists:join/2 (appeared in Erlang 19)
%% string:str/2 -> string:find/2 (appeared in Erlang 20)
%% string:substr/2 -> string:slice/2 (appeared in Erlang 20)
%% string:tokens/2 -> string:lexemes/2 (appeared in Erlang 20)
%% string:{to_lower,to_upper}/1 -> and string:{lowercase,uppercase}/1
NoHaveErl20StrFunctions =
try string:find("abc", "b") of
"bc" -> []
catch error:undef -> [{d,'NO_HAVE_ERL20_STR_FUNCTIONS'}]
end.
%% In Erlang 27, the expression +0.0 =:= -0.0 will evaluate to false
%% whereas in Erlang 26 and earlier, it evaluates to true.
%% In Erlang 26.1, as a prep for Erlang 27, using 0.0 in match expreessions or
%% in comparisons with =:= or =/= will result in a warning that hints about
%% rewriting the value to either +0.0 or -0.0.
%% This preprocessor definition is for we want to run something, eg a unit
%% test, in Erlang versions that can tell +0.0 and -0.0 apart.
NoHavePlusMinusZeroFloat =
case +0.0 =:= -0.0 of
true -> [{d,'NO_HAVE_PLUS_MINUS_ZERO_FLOAT'}];
false -> []
end.
ConfigOpts = NoHaveMapsOpts ++ NoHaveRandOpts ++ NoHaveErl20StrFunctions ++
NoHavePlusMinusZeroFloat.
[{require_otp_vsn, ".*"},
{pre_hooks,
[{compile,
"escript build/mk_version_hrl include/gpb_version.hrl.in"
" include/gpb_version.hrl"}
]},
%% Erlang compiler options
{erl_opts, [debug_info] ++ ConfigOpts},
{erl_first_files, ["src/gpb_codegen.erl"]},
%% This line is useful if you have gpb_eqc.erl symlinked to
%% the symlink in the test/ directory.
{eunit_compile_opts, [{i,"../include"}]},
{edoc_opts, [{preprocess,true}, {pretty_printer,erl_pp}]},
{post_hooks,
[{compile,
"escript build/compile_descriptor"}
]},
%% XRef checks to perform
{xref_checks, [undefined_function_calls]},
%% Clean files
{clean_files, [".eunit", "ebin/*.beam", "include/gpb_version.hrl",
"descr_src/gpb_descriptor.erl", "descr_src/gpb_descriptor.hrl"]}
].