Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. .PHONY: plugins tests
  2. PROJECT = emqx
  3. PROJECT_DESCRIPTION = EMQ X Broker
  4. PROJECT_VERSION = 3.0
  5. DEPS = jsx gproc gen_rpc ekka esockd cowboy clique
  6. dep_jsx = git https://github.com/talentdeficit/jsx 2.9.0
  7. dep_gproc = git https://github.com/uwiger/gproc 0.8.0
  8. dep_gen_rpc = git https://github.com/emqx/gen_rpc 2.3.0
  9. dep_esockd = git https://github.com/emqx/esockd v5.4.2
  10. dep_ekka = git https://github.com/emqx/ekka v0.5.0
  11. dep_cowboy = git https://github.com/ninenines/cowboy 2.4.0
  12. dep_clique = git https://github.com/emqx/clique develop
  13. NO_AUTOPATCH = cuttlefish
  14. ERLC_OPTS += +debug_info -DAPPLICATION=emqx
  15. BUILD_DEPS = cuttlefish
  16. dep_cuttlefish = git https://github.com/emqx/cuttlefish v2.1.0
  17. #TEST_DEPS = emqx_ct_helplers
  18. #dep_emqx_ct_helplers = git git@github.com:emqx/emqx-ct-helpers
  19. TEST_ERLC_OPTS += +debug_info -DAPPLICATION=emqx
  20. EUNIT_OPTS = verbose
  21. # CT_SUITES = emqx_frame
  22. ## emqx_trie emqx_router emqx_frame emqx_mqtt_compat
  23. CT_SUITES = emqx emqx_client emqx_zone emqx_banned emqx_session \
  24. emqx_access emqx_broker emqx_cm emqx_frame emqx_guid emqx_inflight emqx_json \
  25. emqx_keepalive emqx_lib emqx_metrics emqx_mod emqx_mod_sup emqx_mqtt_caps \
  26. emqx_mqtt_props emqx_mqueue emqx_net emqx_pqueue emqx_router emqx_sm \
  27. emqx_tables emqx_time emqx_topic emqx_trie emqx_vm emqx_mountpoint \
  28. emqx_listeners emqx_protocol emqx_pool emqx_shared_sub emqx_bridge emqx_hooks
  29. CT_NODE_NAME = emqxct@127.0.0.1
  30. CT_OPTS = -cover test/ct.cover.spec -erl_args -name $(CT_NODE_NAME)
  31. COVER = true
  32. PLT_APPS = sasl asn1 ssl syntax_tools runtime_tools crypto xmerl os_mon inets public_key ssl compiler mnesia
  33. DIALYZER_DIRS := ebin/
  34. DIALYZER_OPTS := --verbose --statistics -Werror_handling -Wrace_conditions #-Wunmatched_returns
  35. include erlang.mk
  36. clean:: gen-clean rebar-clean
  37. .PHONY: gen-clean
  38. gen-clean:
  39. @rm -rf bbmustache
  40. @rm -f etc/gen.emqx.conf
  41. bbmustache:
  42. $(verbose) git clone https://github.com/soranoba/bbmustache.git && cd bbmustache && ./rebar3 compile && cd ..
  43. # This hack is to generate a conf file for testing
  44. # relx overlay is used for release
  45. etc/gen.emqx.conf: bbmustache etc/emqx.conf
  46. $(verbose) erl -noshell -pa bbmustache/_build/default/lib/bbmustache/ebin -eval \
  47. "{ok, Temp} = file:read_file('etc/emqx.conf'), \
  48. {ok, Vars0} = file:consult('vars'), \
  49. Vars = [{atom_to_list(N), list_to_binary(V)} || {N, V} <- Vars0], \
  50. Targ = bbmustache:render(Temp, Vars), \
  51. ok = file:write_file('etc/gen.emqx.conf', Targ), \
  52. halt(0)."
  53. CUTTLEFISH_SCRIPT = _build/default/lib/cuttlefish/cuttlefish
  54. app.config: $(CUTTLEFISH_SCRIPT) etc/gen.emqx.conf
  55. $(verbose) $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/
  56. ct: app.config
  57. rebar-cover:
  58. @rebar3 cover
  59. coveralls:
  60. @rebar3 coveralls send
  61. $(CUTTLEFISH_SCRIPT): rebar-deps
  62. @if [ ! -f cuttlefish ]; then make -C _build/default/lib/cuttlefish; fi
  63. rebar-xref:
  64. @rebar3 xref
  65. rebar-deps:
  66. @rebar3 get-deps
  67. rebar-eunit: $(CUTTLEFISH_SCRIPT)
  68. @rebar3 eunit
  69. rebar-compile:
  70. @rebar3 compile
  71. rebar-ct: app.config
  72. @rebar3 as test compile
  73. @ln -s -f '../../../../etc' _build/test/lib/emqx/
  74. @ln -s -f '../../../../data' _build/test/lib/emqx/
  75. @rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(shell echo $(foreach var,$(CT_SUITES),test/$(var)_SUITE) | tr ' ' ',')
  76. rebar-clean:
  77. @rebar3 clean
  78. distclean:: rebar-clean
  79. @rm -rf _build cover deps logs log data
  80. @rm -f rebar.lock compile_commands.json cuttlefish
  81. ## Below are for version consistency check during erlang.mk and rebar3 dual mode support
  82. none=
  83. space = $(none) $(none)
  84. comma = ,
  85. quote = \"
  86. curly_l = "{"
  87. curly_r = "}"
  88. dep-versions = [$(foreach dep,$(DEPS) $(BUILD_DEPS),$(curly_l)$(dep),$(quote)$(word 3,$(dep_$(dep)))$(quote)$(curly_r)$(comma))[]]
  89. .PHONY: dep-vsn-check
  90. dep-vsn-check:
  91. $(verbose) erl -noshell -eval \
  92. "MkVsns = lists:sort(lists:flatten($(dep-versions))), \
  93. {ok, Conf} = file:consult('rebar.config'), \
  94. {_, Deps1} = lists:keyfind(deps, 1, Conf), \
  95. {_, Deps2} = lists:keyfind(github_emqx_deps, 1, Conf), \
  96. F = fun({N, V}) when is_list(V) -> {N, V}; ({N, {git, _, {branch, V}}}) -> {N, V} end, \
  97. RebarVsns = lists:sort(lists:map(F, Deps1 ++ Deps2)), \
  98. case {RebarVsns -- MkVsns, MkVsns -- RebarVsns} of \
  99. {[], []} -> halt(0); \
  100. {Rebar, Mk} -> erlang:error({deps_version_discrepancy, [{rebar, Rebar}, {mk, Mk}]}) \
  101. end."