rebar.config.script 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. IsQuicSupp = fun() ->
  14. not (IsCentos6() orelse IsWin32() orelse
  15. "1" =:= os:getenv("BUILD_WITHOUT_QUIC"))
  16. end,
  17. Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
  18. Quicer =
  19. {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.1.10"}}}.
  20. Dialyzer = fun(Config) ->
  21. {dialyzer, OldDialyzerConfig} = lists:keyfind(dialyzer, 1, Config),
  22. Extra = [quicer || IsQuicSupp()],
  23. NewDialyzerConfig = [{plt_extra_apps, Extra} | OldDialyzerConfig],
  24. lists:keystore(
  25. dialyzer,
  26. 1,
  27. Config,
  28. {dialyzer, NewDialyzerConfig}
  29. )
  30. end.
  31. ExtraDeps = fun(C) ->
  32. {deps, Deps0} = lists:keyfind(deps, 1, C),
  33. {erl_opts, ErlOpts0} = lists:keyfind(erl_opts, 1, C),
  34. IsQuic = IsQuicSupp(),
  35. New = [
  36. {deps, Deps0 ++ [Bcrypt || not IsWin32()] ++ [Quicer || IsQuic]},
  37. {erl_opts, ErlOpts0 ++ [{d, 'BUILD_WITHOUT_QUIC'} || not IsQuic]}
  38. ],
  39. lists:foldl(
  40. fun({Key, _Val} = KV, Acc) ->
  41. lists:keystore(Key, 1, Acc, KV)
  42. end,
  43. C,
  44. New
  45. )
  46. end,
  47. Dialyzer(ExtraDeps(CONFIG)).