Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. $(shell $(CURDIR)/scripts/git-hooks-init.sh)
  2. REBAR_VERSION = 3.14.3-emqx-6
  3. REBAR = $(CURDIR)/rebar3
  4. BUILD = $(CURDIR)/build
  5. SCRIPTS = $(CURDIR)/scripts
  6. export PKG_VSN ?= $(shell $(CURDIR)/pkg-vsn.sh)
  7. export EMQX_DESC ?= EMQ X
  8. export EMQX_CE_DASHBOARD_VERSION ?= v4.3.0-rc.1
  9. ifeq ($(OS),Windows_NT)
  10. export REBAR_COLOR=none
  11. endif
  12. PROFILE ?= emqx
  13. REL_PROFILES := emqx emqx-edge
  14. PKG_PROFILES := emqx-pkg emqx-edge-pkg
  15. PROFILES := $(REL_PROFILES) $(PKG_PROFILES) default
  16. export REBAR_GIT_CLONE_OPTIONS += --depth=1
  17. .PHONY: default
  18. default: $(REBAR) $(PROFILE)
  19. .PHONY: all
  20. all: $(REBAR) $(PROFILES)
  21. .PHONY: ensure-rebar3
  22. ensure-rebar3:
  23. @$(SCRIPTS)/fail-on-old-otp-version.escript
  24. @$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION)
  25. $(REBAR): ensure-rebar3
  26. .PHONY: get-dashboard
  27. get-dashboard:
  28. @$(SCRIPTS)/get-dashboard.sh
  29. .PHONY: eunit
  30. eunit: $(REBAR)
  31. @ENABLE_COVER_COMPILE=1 $(REBAR) eunit -v -c
  32. .PHONY: proper
  33. proper: $(REBAR)
  34. @ENABLE_COVER_COMPILE=1 $(REBAR) proper -d test/props -c
  35. .PHONY: ct
  36. ct: $(REBAR)
  37. @ENABLE_COVER_COMPILE=1 $(REBAR) ct --name 'test@127.0.0.1' -c -v
  38. APPS=$(shell $(CURDIR)/scripts/find-apps.sh)
  39. ## app/name-ct targets are intended for local tests hence cover is not enabled
  40. .PHONY: $(APPS:%=%-ct)
  41. define gen-app-ct-target
  42. $1-ct:
  43. $(REBAR) ct --name 'test@127.0.0.1' -v --suite $(shell $(CURDIR)/scripts/find-suites.sh $1)
  44. endef
  45. $(foreach app,$(APPS),$(eval $(call gen-app-ct-target,$(app))))
  46. ## apps/name-prop targets
  47. .PHONY: $(APPS:%=%-prop)
  48. define gen-app-prop-target
  49. $1-prop:
  50. $(REBAR) proper -d test/props -v -m $(shell $(CURDIR)/scripts/find-props.sh $1)
  51. endef
  52. $(foreach app,$(APPS),$(eval $(call gen-app-prop-target,$(app))))
  53. .PHONY: cover
  54. cover: $(REBAR)
  55. @ENABLE_COVER_COMPILE=1 $(REBAR) cover
  56. .PHONY: coveralls
  57. coveralls: $(REBAR)
  58. @ENABLE_COVER_COMPILE=1 $(REBAR) as test coveralls send
  59. .PHONY: $(REL_PROFILES)
  60. $(REL_PROFILES:%=%): $(REBAR) get-dashboard
  61. @$(REBAR) as $(@) do compile,release
  62. ## Not calling rebar3 clean because
  63. ## 1. rebar3 clean relies on rebar3, meaning it reads config, fetches dependencies etc.
  64. ## 2. it's slow
  65. ## NOTE: this does not force rebar3 to fetch new version dependencies
  66. ## make clean-all to delete all fetched dependencies for a fresh start-over
  67. .PHONY: clean $(PROFILES:%=clean-%)
  68. clean: $(PROFILES:%=clean-%)
  69. $(PROFILES:%=clean-%):
  70. @if [ -d _build/$(@:clean-%=%) ]; then \
  71. rm -rf _build/$(@:clean-%=%)/rel; \
  72. find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \
  73. fi
  74. .PHONY: clean-all
  75. clean-all:
  76. @rm -rf _build
  77. .PHONY: deps-all
  78. deps-all: $(REBAR) $(PROFILES:%=deps-%)
  79. ## deps-<profile> is used in CI scripts to download deps and the
  80. ## share downloads between CI steps and/or copied into containers
  81. ## which may not have the right credentials
  82. .PHONY: $(PROFILES:%=deps-%)
  83. $(PROFILES:%=deps-%): $(REBAR) get-dashboard
  84. @$(REBAR) as $(@:deps-%=%) get-deps
  85. .PHONY: xref
  86. xref: $(REBAR)
  87. @$(REBAR) as check xref
  88. .PHONY: dialyzer
  89. dialyzer: $(REBAR)
  90. @$(REBAR) as check dialyzer
  91. .PHONY: $(REL_PROFILES:%=relup-%)
  92. $(REL_PROFILES:%=relup-%): $(REBAR)
  93. ifneq ($(OS),Windows_NT)
  94. @$(BUILD) $(@:relup-%=%) relup
  95. endif
  96. .PHONY: $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar)
  97. $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR) get-dashboard $(CONF_SEGS)
  98. @$(BUILD) $(subst -tar,,$(@)) tar
  99. ## zip targets depend on the corresponding relup and tar artifacts
  100. .PHONY: $(REL_PROFILES:%=%-zip)
  101. define gen-zip-target
  102. $1-zip: relup-$1 $1-tar
  103. @$(BUILD) $1 zip
  104. endef
  105. ALL_ZIPS = $(REL_PROFILES) $(PKG_PROFILES)
  106. $(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt))))
  107. ## A pkg target depend on a regular release profile zip to include relup,
  108. ## and also a -pkg suffixed profile tar (without relup) for making deb/rpm package
  109. .PHONY: $(PKG_PROFILES)
  110. define gen-pkg-target
  111. $1: $(subst -pkg,,$1)-zip $1-tar
  112. @$(BUILD) $1 pkg
  113. endef
  114. $(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))
  115. .PHONY: run
  116. run: $(PROFILE) quickrun
  117. .PHONY: quickrun
  118. quickrun:
  119. ./_build/$(PROFILE)/rel/emqx/bin/emqx console
  120. include docker.mk