File: rebar.config.script

package info (click to toggle)
erlang-jiffy 1.0.8%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,228 kB
  • sloc: cpp: 3,733; ansic: 2,326; erlang: 1,193; makefile: 31
file content (39 lines) | stat: -rw-r--r-- 1,210 bytes parent folder | download
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
% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information.
%
% Only run the EQC checks when EQC is present.

HaveEQC = code:which(eqc) =/= non_existing,

ErlOpts = if not HaveEQC -> []; true ->
    [{d, 'HAVE_EQC'}]
end,

Config1 = case lists:keyfind(erl_opts, 1, CONFIG) of
    {erl_opts, Opts} ->
        NewOpts = {erl_opts, Opts ++ ErlOpts},
        lists:keyreplace(erl_opts, 1, CONFIG, NewOpts);
    false ->
        CONFIG ++ [{erl_opts, ErlOpts}]
end,

case os:type() of
    {unix, _} ->
        CC = case os:getenv("CC") of
            false -> "cc";
            Else -> Else
        end,
        FLTO_CHECK = "echo 'int main(int argc, char *argv[]) {return 0;}' | "
                ++ CC ++ " -c -x c -o /dev/null -flto -",
        case os:cmd(FLTO_CHECK) of
            [] ->
                {port_env, PortEnv} = lists:keyfind(port_env, 1, Config1),
                NewFlag = {".*", "FLTO_FLAG", "-flto"},
                NewPortEnv = lists:keyreplace("FLTO_FLAG", 2, PortEnv, NewFlag),
                lists:keyreplace(port_env, 1, Config1, {port_env, NewPortEnv});
            _ ->
                Config1
        end;
    _ ->
        Config1
end.