Makefile 4.5 KB

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