rebar.config.script 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. %% -*- mode: erlang -*-
  2. IsCentos6 = fun() ->
  3. case file:read_file("/etc/centos-release") of
  4. {ok, <<"CentOS release 6", _/binary>>} ->
  5. true;
  6. _ ->
  7. false
  8. end
  9. end,
  10. IsWin32 = fun() ->
  11. win32 =:= element(1, os:type())
  12. end,
  13. IsMacOS = fun() ->
  14. {unix, darwin} =:= os:type()
  15. end,
  16. IsQuicSupp = fun() ->
  17. not (IsCentos6() orelse IsWin32() orelse
  18. IsMacOS() orelse
  19. false =/= os:getenv("BUILD_WITHOUT_QUIC")) orelse
  20. "1" == os:getenv("BUILD_WITH_QUIC")
  21. end,
  22. Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
  23. Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.16"}}}.
  24. ExtraDeps = fun(C) ->
  25. {deps, Deps0} = lists:keyfind(deps, 1, C),
  26. {erl_opts, ErlOpts0} = lists:keyfind(erl_opts, 1, C),
  27. IsQuic = IsQuicSupp(),
  28. New = [
  29. {deps, Deps0 ++ [Bcrypt || not IsWin32()] ++ [Quicer || IsQuic]},
  30. {erl_opts, ErlOpts0 ++ [{d, 'BUILD_WITHOUT_QUIC'} || not IsQuic]}
  31. ],
  32. lists:foldl(
  33. fun({Key, _Val} = KV, Acc) ->
  34. lists:keystore(Key, 1, Acc, KV)
  35. end,
  36. C,
  37. New
  38. )
  39. end,
  40. ExtraDeps(CONFIG).