You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 line
1.6 KiB

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. %
  4. % Only run the EQC checks when EQC is present.
  5. HaveEQC = code:which(eqc) =/= non_existing,
  6. ErlOpts = if not HaveEQC -> []; true ->
  7. [{d, 'HAVE_EQC'}]
  8. end,
  9. Config1 = case lists:keyfind(erl_opts, 1, CONFIG) of
  10. {erl_opts, Opts} ->
  11. NewOpts = {erl_opts, Opts ++ ErlOpts},
  12. lists:keyreplace(erl_opts, 1, CONFIG, NewOpts);
  13. false ->
  14. CONFIG ++ [{erl_opts, ErlOpts}]
  15. end,
  16. Config2 = case os:type() of
  17. {unix, _} ->
  18. CC = case os:getenv("CC") of
  19. false -> "cc";
  20. Else -> Else
  21. end,
  22. FLTO_CHECK = "echo 'int main(int argc, char *argv[]) {return 0;}' | "
  23. ++ CC ++ " -c -x c -o /dev/null -flto -",
  24. case os:cmd(FLTO_CHECK) of
  25. [] ->
  26. {port_env, PortEnv} = lists:keyfind(port_env, 1, Config1),
  27. NewFlag = {".*", "FLTO_FLAG", "-flto"},
  28. NewPortEnv = lists:keyreplace("FLTO_FLAG", 2, PortEnv, NewFlag),
  29. lists:keyreplace(port_env, 1, Config1, {port_env, NewPortEnv});
  30. _ ->
  31. Config1
  32. end;
  33. _ ->
  34. Config1
  35. end,
  36. IsRebar3 = code:which(rebar3) /= non_existing,
  37. case IsRebar3 of
  38. false ->
  39. Config2;
  40. true ->
  41. Config2 ++ [
  42. {plugins, [{pc, "~> 1.0"}]},
  43. {artifacts, ["priv/jiffy.so"]},
  44. {provider_hooks, [
  45. {post, [
  46. {compile, {pc, compile}},
  47. {clean, {pc, clean}}
  48. ]}
  49. ]}
  50. ]
  51. end.