Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.4
  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. CUR_BRANCH := $(shell git branch | grep -e "^*" | cut -d' ' -f 2)
  17. BRANCH := $(if $(filter $(CUR_BRANCH), master develop), $(CUR_BRANCH), develop)
  18. TEST_DEPS = emqx_ct_helpers
  19. dep_emqx_ct_helpers = git-emqx https://github.com/emqx/emqx-ct-helpers.git v1.0
  20. TEST_ERLC_OPTS += +debug_info -DAPPLICATION=emqx
  21. EUNIT_OPTS = verbose
  22. # CT_SUITES = emqx_bridge
  23. ## emqx_trie emqx_router emqx_frame emqx_mqtt_compat
  24. CT_SUITES = emqx emqx_client emqx_zone emqx_banned emqx_session \
  25. emqx_broker emqx_cm emqx_frame emqx_guid emqx_inflight emqx_json \
  26. emqx_keepalive emqx_lib emqx_metrics emqx_mod emqx_mod_sup emqx_mqtt_caps \
  27. emqx_mqtt_props emqx_mqueue emqx_net emqx_pqueue emqx_router emqx_sm \
  28. emqx_tables emqx_time emqx_topic emqx_trie emqx_vm emqx_mountpoint \
  29. emqx_listeners emqx_protocol emqx_pool emqx_shared_sub emqx_bridge \
  30. emqx_hooks emqx_batch emqx_sequence emqx_pmon emqx_pd emqx_gc emqx_ws_connection \
  31. emqx_packet emqx_connection emqx_tracer emqx_sys_mon emqx_message emqx_os_mon \
  32. emqx_vm_mon emqx_alarm_handler emqx_rpc emqx_flapping
  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 compiler mnesia
  37. DIALYZER_DIRS := ebin/
  38. DIALYZER_OPTS := --verbose --statistics -Werror_handling -Wrace_conditions #-Wunmatched_returns
  39. $(shell [ -f erlang.mk ] || curl -s -o erlang.mk https://raw.githubusercontent.com/emqx/erlmk/master/erlang.mk)
  40. include erlang.mk
  41. clean:: gen-clean
  42. .PHONY: gen-clean
  43. gen-clean:
  44. @rm -rf bbmustache
  45. @rm -f etc/gen.emqx.conf
  46. bbmustache:
  47. $(verbose) git clone https://github.com/soranoba/bbmustache.git && cd bbmustache && ./rebar3 compile && cd ..
  48. # This hack is to generate a conf file for testing
  49. # relx overlay is used for release
  50. etc/gen.emqx.conf: bbmustache etc/emqx.conf
  51. $(verbose) erl -noshell -pa bbmustache/_build/default/lib/bbmustache/ebin -eval \
  52. "{ok, Temp} = file:read_file('etc/emqx.conf'), \
  53. {ok, Vars0} = file:consult('vars'), \
  54. Vars = [{atom_to_list(N), list_to_binary(V)} || {N, V} <- Vars0], \
  55. Targ = bbmustache:render(Temp, Vars), \
  56. ok = file:write_file('etc/gen.emqx.conf', Targ), \
  57. halt(0)."
  58. CUTTLEFISH_SCRIPT = _build/default/lib/cuttlefish/cuttlefish
  59. app.config: $(CUTTLEFISH_SCRIPT) etc/gen.emqx.conf
  60. $(verbose) $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/
  61. ct: app.config
  62. rebar-cover:
  63. @rebar3 cover
  64. coveralls:
  65. @rebar3 coveralls send
  66. $(CUTTLEFISH_SCRIPT): rebar-deps
  67. @if [ ! -f cuttlefish ]; then make -C _build/default/lib/cuttlefish; fi
  68. rebar-xref:
  69. @rebar3 xref
  70. rebar-deps:
  71. @rebar3 get-deps
  72. rebar-eunit: $(CUTTLEFISH_SCRIPT)
  73. @rebar3 eunit -v
  74. rebar-compile:
  75. @rebar3 compile
  76. rebar-ct-setup: app.config
  77. @rebar3 as test compile
  78. @ln -s -f '../../../../etc' _build/test/lib/emqx/
  79. @ln -s -f '../../../../data' _build/test/lib/emqx/
  80. rebar-ct: rebar-ct-setup
  81. @rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(shell echo $(foreach var,$(CT_SUITES),test/$(var)_SUITE) | tr ' ' ',')
  82. ## Run one single CT with rebar3
  83. ## e.g. make ct-one-suite suite=emqx_bridge
  84. ct-one-suite: rebar-ct-setup
  85. @rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(suite)_SUITE
  86. rebar-clean:
  87. @rebar3 clean
  88. distclean::
  89. @rm -rf _build cover deps logs log data
  90. @rm -f rebar.lock compile_commands.json cuttlefish