Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. .PHONY: plugins tests
  2. PROJECT = emqx
  3. PROJECT_DESCRIPTION = EMQ X Broker
  4. DEPS = jsx gproc gen_rpc ekka esockd cowboy replayq
  5. dep_jsx = git-emqx https://github.com/talentdeficit/jsx 2.9.0
  6. dep_gproc = git-emqx https://github.com/uwiger/gproc 0.8.0
  7. dep_gen_rpc = git-emqx https://github.com/emqx/gen_rpc 2.3.1
  8. dep_esockd = git-emqx https://github.com/emqx/esockd v5.4.4
  9. dep_ekka = git-emqx https://github.com/emqx/ekka v0.5.3
  10. dep_cowboy = git-emqx https://github.com/ninenines/cowboy 2.6.1
  11. dep_replayq = git-emqx https://github.com/emqx/replayq v0.1.1
  12. NO_AUTOPATCH = cuttlefish
  13. ERLC_OPTS += +debug_info -DAPPLICATION=emqx
  14. BUILD_DEPS = cuttlefish
  15. dep_cuttlefish = git-emqx https://github.com/emqx/cuttlefish v2.2.1
  16. TEST_DEPS = meck
  17. dep_meck = hex-emqx 0.8.13
  18. TEST_ERLC_OPTS += +debug_info -DAPPLICATION=emqx
  19. EUNIT_OPTS = verbose
  20. # CT_SUITES = emqx_bridge
  21. ## emqx_trie emqx_router emqx_frame emqx_mqtt_compat
  22. CT_SUITES = emqx emqx_client emqx_zone emqx_banned emqx_session \
  23. emqx_broker emqx_cm emqx_frame emqx_guid emqx_inflight emqx_json \
  24. emqx_keepalive emqx_lib emqx_metrics emqx_mod emqx_mod_sup emqx_mqtt_caps \
  25. emqx_mqtt_props emqx_mqueue emqx_net emqx_pqueue emqx_router emqx_sm \
  26. emqx_tables emqx_time emqx_topic emqx_trie emqx_vm emqx_mountpoint \
  27. emqx_listeners emqx_protocol emqx_pool emqx_shared_sub emqx_bridge \
  28. emqx_hooks emqx_batch emqx_sequence emqx_pmon emqx_pd emqx_gc emqx_ws_connection \
  29. emqx_packet emqx_connection emqx_tracer emqx_sys_mon emqx_message emqx_os_mon \
  30. emqx_vm_mon emqx_alarm_handler emqx_rpc
  31. CT_NODE_NAME = emqxct@127.0.0.1
  32. CT_OPTS = -cover test/ct.cover.spec -erl_args -name $(CT_NODE_NAME)
  33. COVER = true
  34. PLT_APPS = sasl asn1 ssl syntax_tools runtime_tools crypto xmerl os_mon inets public_key ssl compiler mnesia
  35. DIALYZER_DIRS := ebin/
  36. DIALYZER_OPTS := --verbose --statistics -Werror_handling -Wrace_conditions #-Wunmatched_returns
  37. $(shell [ -f erlang.mk ] || curl -s -o erlang.mk https://raw.githubusercontent.com/emqx/erlmk/master/erlang.mk)
  38. include erlang.mk
  39. clean:: gen-clean
  40. .PHONY: gen-clean
  41. gen-clean:
  42. @rm -rf bbmustache
  43. @rm -f etc/gen.emqx.conf
  44. bbmustache:
  45. $(verbose) git clone https://github.com/soranoba/bbmustache.git && cd bbmustache && ./rebar3 compile && cd ..
  46. # This hack is to generate a conf file for testing
  47. # relx overlay is used for release
  48. etc/gen.emqx.conf: bbmustache etc/emqx.conf
  49. $(verbose) erl -noshell -pa bbmustache/_build/default/lib/bbmustache/ebin -eval \
  50. "{ok, Temp} = file:read_file('etc/emqx.conf'), \
  51. {ok, Vars0} = file:consult('vars'), \
  52. Vars = [{atom_to_list(N), list_to_binary(V)} || {N, V} <- Vars0], \
  53. Targ = bbmustache:render(Temp, Vars), \
  54. ok = file:write_file('etc/gen.emqx.conf', Targ), \
  55. halt(0)."
  56. CUTTLEFISH_SCRIPT = _build/default/lib/cuttlefish/cuttlefish
  57. app.config: $(CUTTLEFISH_SCRIPT) etc/gen.emqx.conf
  58. $(verbose) $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/
  59. ct: app.config
  60. rebar-cover:
  61. @rebar3 cover
  62. coveralls:
  63. @rebar3 coveralls send
  64. $(CUTTLEFISH_SCRIPT): rebar-deps
  65. @if [ ! -f cuttlefish ]; then make -C _build/default/lib/cuttlefish; fi
  66. rebar-xref:
  67. @rebar3 xref
  68. rebar-deps:
  69. @rebar3 get-deps
  70. rebar-eunit: $(CUTTLEFISH_SCRIPT)
  71. @rebar3 eunit -v
  72. rebar-compile:
  73. @rebar3 compile
  74. rebar-ct-setup: app.config
  75. @rebar3 as test compile
  76. @ln -s -f '../../../../etc' _build/test/lib/emqx/
  77. @ln -s -f '../../../../data' _build/test/lib/emqx/
  78. rebar-ct: rebar-ct-setup
  79. @rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(shell echo $(foreach var,$(CT_SUITES),test/$(var)_SUITE) | tr ' ' ',')
  80. ## Run one single CT with rebar3
  81. ## e.g. make ct-one-suite suite=emqx_bridge
  82. ct-one-suite: rebar-ct-setup
  83. @rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(suite)_SUITE
  84. rebar-clean:
  85. @rebar3 clean
  86. distclean::
  87. @rm -rf _build cover deps logs log data
  88. @rm -f rebar.lock compile_commands.json cuttlefish