Merge pull request #4254 from zmstone/chore-build-fail-fast-if-otp-is-too-old

chore(build): Fail fast on old version OTP
This commit is contained in:
Zaiming Shi 2021-03-01 20:28:56 +01:00 committed by GitHub
commit b166ee5651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 21 deletions

View File

@ -21,49 +21,50 @@ all: $(REBAR) $(PROFILES)
.PHONY: ensure-rebar3 .PHONY: ensure-rebar3
ensure-rebar3: ensure-rebar3:
$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION) @$(SCRIPTS)/fail-on-old-otp-version.escript
@$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION)
$(REBAR): ensure-rebar3 $(REBAR): ensure-rebar3
.PHONY: get-dashboard .PHONY: get-dashboard
get-dashboard: get-dashboard:
$(SCRIPTS)/get-dashboard.sh $(DASHBOARD_VERSION) @$(SCRIPTS)/get-dashboard.sh $(DASHBOARD_VERSION)
.PHONY: eunit .PHONY: eunit
eunit: $(REBAR) eunit: $(REBAR)
$(REBAR) eunit -v -c @$(REBAR) eunit -v -c
.PHONY: proper .PHONY: proper
proper: $(REBAR) proper: $(REBAR)
$(REBAR) as test proper -d test/props -c @$(REBAR) as test proper -d test/props -c
.PHONY: ct .PHONY: ct
ct: $(REBAR) ct: $(REBAR)
$(REBAR) ct --name 'test@127.0.0.1' -c -v @$(REBAR) ct --name 'test@127.0.0.1' -c -v
.PHONY: cover .PHONY: cover
cover: $(REBAR) cover: $(REBAR)
$(REBAR) cover @$(REBAR) cover
.PHONY: coveralls .PHONY: coveralls
coveralls: $(REBAR) coveralls: $(REBAR)
$(REBAR) as test coveralls send @$(REBAR) as test coveralls send
.PHONY: $(REL_PROFILES) .PHONY: $(REL_PROFILES)
$(REL_PROFILES:%=%): $(REBAR) get-dashboard $(REL_PROFILES:%=%): $(REBAR) get-dashboard
ifneq ($(shell echo $(@) |grep edge),) ifneq ($(shell echo $(@) |grep edge),)
export EMQX_DESC="EMQ X Edge" @export EMQX_DESC="EMQ X Edge"
else else
export EMQX_DESC="EMQ X Broker" @export EMQX_DESC="EMQ X Broker"
endif endif
$(REBAR) as $(@) release @$(REBAR) as $(@) release
# rebar clean # rebar clean
.PHONY: clean $(PROFILES:%=clean-%) .PHONY: clean $(PROFILES:%=clean-%)
clean: $(PROFILES:%=clean-%) clean: $(PROFILES:%=clean-%)
$(PROFILES:%=clean-%): $(REBAR) $(PROFILES:%=clean-%): $(REBAR)
$(REBAR) as $(@:clean-%=%) clean @$(REBAR) as $(@:clean-%=%) clean
rm -rf apps/emqx_dashboard/priv/www @rm -rf apps/emqx_dashboard/priv/www
.PHONY: deps-all .PHONY: deps-all
deps-all: $(REBAR) $(PROFILES:%=deps-%) deps-all: $(REBAR) $(PROFILES:%=deps-%)
@ -71,35 +72,35 @@ deps-all: $(REBAR) $(PROFILES:%=deps-%)
.PHONY: $(PROFILES:%=deps-%) .PHONY: $(PROFILES:%=deps-%)
$(PROFILES:%=deps-%): $(REBAR) get-dashboard $(PROFILES:%=deps-%): $(REBAR) get-dashboard
ifneq ($(shell echo $(@) |grep edge),) ifneq ($(shell echo $(@) |grep edge),)
export EMQX_DESC="EMQ X Edge" @export EMQX_DESC="EMQ X Edge"
else else
export EMQX_DESC="EMQ X Broker" @export EMQX_DESC="EMQ X Broker"
endif endif
$(REBAR) as $(@:deps-%=%) get-deps @$(REBAR) as $(@:deps-%=%) get-deps
.PHONY: xref .PHONY: xref
xref: $(REBAR) xref: $(REBAR)
$(REBAR) as check xref @$(REBAR) as check xref
.PHONY: dialyzer .PHONY: dialyzer
dialyzer: $(REBAR) dialyzer: $(REBAR)
$(REBAR) as check dialyzer @$(REBAR) as check dialyzer
.PHONY: $(REL_PROFILES:%=relup-%) .PHONY: $(REL_PROFILES:%=relup-%)
$(REL_PROFILES:%=relup-%): $(REBAR) $(REL_PROFILES:%=relup-%): $(REBAR)
ifneq ($(OS),Windows_NT) ifneq ($(OS),Windows_NT)
$(BUILD) $(@:relup-%=%) relup @$(BUILD) $(@:relup-%=%) relup
endif endif
.PHONY: $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar) .PHONY: $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar)
$(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR) get-dashboard $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR) get-dashboard
$(BUILD) $(subst -tar,,$(@)) tar @$(BUILD) $(subst -tar,,$(@)) tar
## zip targets depend on the corresponding relup and tar artifacts ## zip targets depend on the corresponding relup and tar artifacts
.PHONY: $(REL_PROFILES:%=%-zip) .PHONY: $(REL_PROFILES:%=%-zip)
define gen-zip-target define gen-zip-target
$1-zip: relup-$1 $1-tar $1-zip: relup-$1 $1-tar
$(BUILD) $1 zip @$(BUILD) $1 zip
endef endef
ALL_ZIPS = $(REL_PROFILES) $(PKG_PROFILES) ALL_ZIPS = $(REL_PROFILES) $(PKG_PROFILES)
$(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt)))) $(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt))))
@ -109,7 +110,7 @@ $(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt))))
.PHONY: $(PKG_PROFILES) .PHONY: $(PKG_PROFILES)
define gen-pkg-target define gen-pkg-target
$1: $(subst -pkg,,$1)-zip $1-tar $1: $(subst -pkg,,$1)-zip $1-tar
$(BUILD) $1 pkg @$(BUILD) $1 pkg
endef endef
$(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt)))) $(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))

View File

@ -0,0 +1,12 @@
#!/usr/bin/env escript
main(_) ->
OtpRelease = list_to_integer(erlang:system_info(otp_release)),
case OtpRelease < 21 of
true ->
io:format(standard_error, "ERROR: Erlang/OTP version ~p found. required_min=21, recommended=23~n", [OtpRelease]),
halt(1);
false ->
ok
end.