ci.mk 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright (c) 2015, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. .PHONY: ci ci-setup distclean-kerl
  4. KERL ?= $(CURDIR)/kerl
  5. export KERL
  6. KERL_URL ?= https://raw.githubusercontent.com/yrashk/kerl/master/kerl
  7. OTP_GIT ?= https://github.com/erlang/otp
  8. CI_INSTALL_DIR ?= $(HOME)/erlang
  9. CI_OTP ?=
  10. ifeq ($(strip $(CI_OTP)),)
  11. ci::
  12. else
  13. ci:: $(KERL) $(addprefix ci-,$(CI_OTP))
  14. ci-setup::
  15. ci_verbose_0 = @echo " CI " $(1);
  16. ci_verbose = $(ci_verbose_$(V))
  17. define ci_target
  18. ci-$(1): $(CI_INSTALL_DIR)/$(1)
  19. -$(ci_verbose) \
  20. PATH="$(CI_INSTALL_DIR)/$(1)/bin:$(PATH)" \
  21. CI_OTP_RELEASE="$(1)" \
  22. CT_OPTS="-label $(1)" \
  23. $(MAKE) clean ci-setup tests
  24. endef
  25. $(foreach otp,$(CI_OTP),$(eval $(call ci_target,$(otp))))
  26. define ci_otp_target
  27. $(CI_INSTALL_DIR)/$(1):
  28. $(KERL) build git $(OTP_GIT) $(1) $(1)
  29. $(KERL) install $(1) $(CI_INSTALL_DIR)/$(1)
  30. endef
  31. $(foreach otp,$(CI_OTP),$(eval $(call ci_otp_target,$(otp))))
  32. define kerl_fetch
  33. $(call core_http_get,$(KERL),$(KERL_URL))
  34. chmod +x $(KERL)
  35. endef
  36. $(KERL):
  37. @$(call kerl_fetch)
  38. help::
  39. @printf "%s\n" "" \
  40. "Continuous Integration targets:" \
  41. " ci Run '$(MAKE) tests' on all configured Erlang versions." \
  42. "" \
  43. "The CI_OTP variable must be defined with the Erlang versions" \
  44. "that must be tested. For example: CI_OTP = OTP-17.3.4 OTP-17.5.3"
  45. distclean:: distclean-kerl
  46. distclean-kerl:
  47. $(gen_verbose) rm -rf $(KERL)
  48. endif