ci.mk 1.5 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:: $(addprefix ci-,$(CI_OTP))
  14. ci-prepare: $(addprefix $(CI_INSTALL_DIR)/,$(CI_OTP))
  15. ci-setup::
  16. ci_verbose_0 = @echo " CI " $(1);
  17. ci_verbose = $(ci_verbose_$(V))
  18. define ci_target
  19. ci-$(1): $(CI_INSTALL_DIR)/$(1)
  20. $(ci_verbose) \
  21. PATH="$(CI_INSTALL_DIR)/$(1)/bin:$(PATH)" \
  22. CI_OTP_RELEASE="$(1)" \
  23. CT_OPTS="-label $(1)" \
  24. $(MAKE) clean ci-setup tests
  25. endef
  26. $(foreach otp,$(CI_OTP),$(eval $(call ci_target,$(otp))))
  27. define ci_otp_target
  28. ifeq ($(wildcard $(CI_INSTALL_DIR)/$(1)),)
  29. $(CI_INSTALL_DIR)/$(1): $(KERL)
  30. $(KERL) build git $(OTP_GIT) $(1) $(1)
  31. $(KERL) install $(1) $(CI_INSTALL_DIR)/$(1)
  32. endif
  33. endef
  34. $(foreach otp,$(CI_OTP),$(eval $(call ci_otp_target,$(otp))))
  35. $(KERL):
  36. $(gen_verbose) $(call core_http_get,$(KERL),$(KERL_URL))
  37. $(verbose) chmod +x $(KERL)
  38. help::
  39. $(verbose) 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