|
|
@@ -1,37 +1,9 @@
|
|
|
-.PHONY: plugins tests
|
|
|
+## shallow clone for speed
|
|
|
|
|
|
-PROJECT = emqx
|
|
|
-PROJECT_DESCRIPTION = EMQ X Broker
|
|
|
+REBAR_GIT_CLONE_OPTIONS += --depth 1
|
|
|
+export REBAR_GIT_CLONE_OPTIONS
|
|
|
|
|
|
-DEPS = jsx gproc gen_rpc ekka esockd cowboy replayq
|
|
|
-
|
|
|
-dep_jsx = git-emqx https://github.com/talentdeficit/jsx 2.9.0
|
|
|
-dep_gproc = git-emqx https://github.com/uwiger/gproc 0.8.0
|
|
|
-dep_gen_rpc = git-emqx https://github.com/emqx/gen_rpc 2.3.1
|
|
|
-dep_esockd = git-emqx https://github.com/emqx/esockd v5.4.4
|
|
|
-dep_ekka = git-emqx https://github.com/emqx/ekka v0.5.4
|
|
|
-dep_cowboy = git-emqx https://github.com/ninenines/cowboy 2.6.1
|
|
|
-dep_replayq = git-emqx https://github.com/emqx/replayq v0.1.1
|
|
|
-
|
|
|
-NO_AUTOPATCH = cuttlefish
|
|
|
-
|
|
|
-ERLC_OPTS += +debug_info -DAPPLICATION=emqx
|
|
|
-
|
|
|
-BUILD_DEPS = cuttlefish
|
|
|
-dep_cuttlefish = git-emqx https://github.com/emqx/cuttlefish v2.2.1
|
|
|
-
|
|
|
-CUR_BRANCH := $(shell git branch | grep -e "^*" | cut -d' ' -f 2)
|
|
|
-BRANCH := $(if $(filter $(CUR_BRANCH), master develop), $(CUR_BRANCH), develop)
|
|
|
-
|
|
|
-TEST_DEPS = emqx_ct_helpers
|
|
|
-dep_emqx_ct_helpers = git-emqx https://github.com/emqx/emqx-ct-helpers.git v1.0
|
|
|
-
|
|
|
-TEST_ERLC_OPTS += +debug_info -DAPPLICATION=emqx
|
|
|
-
|
|
|
-EUNIT_OPTS = verbose
|
|
|
-
|
|
|
-# CT_SUITES = emqx_bridge
|
|
|
-## emqx_trie emqx_router emqx_frame emqx_mqtt_compat
|
|
|
+# CT_SUITES = emqx_trie emqx_router emqx_frame emqx_mqtt_compat
|
|
|
|
|
|
CT_SUITES = emqx emqx_client emqx_zone emqx_banned emqx_session \
|
|
|
emqx_broker emqx_cm emqx_frame emqx_guid emqx_inflight emqx_json \
|
|
|
@@ -44,31 +16,32 @@ CT_SUITES = emqx emqx_client emqx_zone emqx_banned emqx_session \
|
|
|
emqx_vm_mon emqx_alarm_handler emqx_rpc emqx_flapping
|
|
|
|
|
|
CT_NODE_NAME = emqxct@127.0.0.1
|
|
|
-CT_OPTS = -cover test/ct.cover.spec -erl_args -name $(CT_NODE_NAME)
|
|
|
-
|
|
|
-COVER = true
|
|
|
|
|
|
-PLT_APPS = sasl asn1 ssl syntax_tools runtime_tools crypto xmerl os_mon inets public_key ssl compiler mnesia
|
|
|
-DIALYZER_DIRS := ebin/
|
|
|
-DIALYZER_OPTS := --verbose --statistics -Werror_handling -Wrace_conditions #-Wunmatched_returns
|
|
|
-
|
|
|
-$(shell [ -f erlang.mk ] || curl -s -o erlang.mk https://raw.githubusercontent.com/emqx/erlmk/master/erlang.mk)
|
|
|
-include erlang.mk
|
|
|
+compile:
|
|
|
+ @rebar3 compile
|
|
|
|
|
|
-clean:: gen-clean
|
|
|
+clean: gen-clean
|
|
|
|
|
|
.PHONY: gen-clean
|
|
|
gen-clean:
|
|
|
- @rm -rf bbmustache
|
|
|
@rm -f etc/gen.emqx.conf
|
|
|
|
|
|
-bbmustache:
|
|
|
- $(verbose) git clone https://github.com/soranoba/bbmustache.git && cd bbmustache && ./rebar3 compile && cd ..
|
|
|
+## bbmustache is a mustache template library used to render templated config files
|
|
|
+## for common tests.
|
|
|
+BBMUSTACHE := _build/test/lib/bbmustache
|
|
|
+$(BBMUSTACHE):
|
|
|
+ @rebar3 as test compile
|
|
|
|
|
|
-# This hack is to generate a conf file for testing
|
|
|
-# relx overlay is used for release
|
|
|
-etc/gen.emqx.conf: bbmustache etc/emqx.conf
|
|
|
- $(verbose) erl -noshell -pa bbmustache/_build/default/lib/bbmustache/ebin -eval \
|
|
|
+## Cuttlefish escript is built by default when cuttlefish app (as dependency) was built
|
|
|
+CUTTLEFISH_SCRIPT := _build/default/lib/cuttlefish/cuttlefish
|
|
|
+
|
|
|
+app.config: etc/gen.emqx.conf
|
|
|
+ $(verbose) $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/
|
|
|
+
|
|
|
+## NOTE: Mustache templating was resolved by relx overlay when building a release.
|
|
|
+## This is only to generate a conf file for testing,
|
|
|
+etc/gen.emqx.conf: $(BBMUSTACHE) etc/emqx.conf
|
|
|
+ @$(verbose) erl -noshell -pa _build/test/lib/bbmustache/ebin -eval \
|
|
|
"{ok, Temp} = file:read_file('etc/emqx.conf'), \
|
|
|
{ok, Vars0} = file:consult('vars'), \
|
|
|
Vars = [{atom_to_list(N), list_to_binary(V)} || {N, V} <- Vars0], \
|
|
|
@@ -76,51 +49,46 @@ etc/gen.emqx.conf: bbmustache etc/emqx.conf
|
|
|
ok = file:write_file('etc/gen.emqx.conf', Targ), \
|
|
|
halt(0)."
|
|
|
|
|
|
-CUTTLEFISH_SCRIPT = _build/default/lib/cuttlefish/cuttlefish
|
|
|
-
|
|
|
-app.config: $(CUTTLEFISH_SCRIPT) etc/gen.emqx.conf
|
|
|
- $(verbose) $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/
|
|
|
-
|
|
|
-ct: app.config
|
|
|
-
|
|
|
-rebar-cover:
|
|
|
+.PHONY: cover
|
|
|
+cover:
|
|
|
@rebar3 cover
|
|
|
|
|
|
+.PHONY: coveralls
|
|
|
coveralls:
|
|
|
@rebar3 coveralls send
|
|
|
|
|
|
-
|
|
|
-$(CUTTLEFISH_SCRIPT): rebar-deps
|
|
|
- @if [ ! -f cuttlefish ]; then make -C _build/default/lib/cuttlefish; fi
|
|
|
-
|
|
|
-rebar-xref:
|
|
|
+.PHONY: xref
|
|
|
+xref:
|
|
|
@rebar3 xref
|
|
|
|
|
|
-rebar-deps:
|
|
|
+.PHONY: deps
|
|
|
+deps:
|
|
|
@rebar3 get-deps
|
|
|
|
|
|
-rebar-eunit: $(CUTTLEFISH_SCRIPT)
|
|
|
+.PHONY: eunit
|
|
|
+eunit:
|
|
|
@rebar3 eunit -v
|
|
|
|
|
|
-rebar-compile:
|
|
|
- @rebar3 compile
|
|
|
-
|
|
|
-rebar-ct-setup: app.config
|
|
|
+## 'ct-setup' is a pre hook for 'rebar3 ct',
|
|
|
+## but not the makefile target ct's dependency
|
|
|
+## because 'ct-setup' requires test dependencies to be compiled first
|
|
|
+.PHONY: ct-setup
|
|
|
+ct-setup:
|
|
|
@rebar3 as test compile
|
|
|
@ln -s -f '../../../../etc' _build/test/lib/emqx/
|
|
|
@ln -s -f '../../../../data' _build/test/lib/emqx/
|
|
|
|
|
|
-rebar-ct: rebar-ct-setup
|
|
|
+.PHONY: ct
|
|
|
+ct: app.config ct-setup
|
|
|
@rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(shell echo $(foreach var,$(CT_SUITES),test/$(var)_SUITE) | tr ' ' ',')
|
|
|
|
|
|
## Run one single CT with rebar3
|
|
|
## e.g. make ct-one-suite suite=emqx_bridge
|
|
|
-ct-one-suite: rebar-ct-setup
|
|
|
+.PHONY: ct-one-suite
|
|
|
+ct-one-suite: ct-setup
|
|
|
@rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(suite)_SUITE
|
|
|
|
|
|
-rebar-clean:
|
|
|
- @rebar3 clean
|
|
|
-
|
|
|
-distclean::
|
|
|
+.PHONY: clean
|
|
|
+clean:
|
|
|
@rm -rf _build cover deps logs log data
|
|
|
@rm -f rebar.lock compile_commands.json cuttlefish
|