ci.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright (c) 2015-2016, 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-prepare ci-setup distclean-kerl
  4. CI_OTP ?=
  5. ifeq ($(strip $(CI_OTP)),)
  6. ci::
  7. else
  8. ifeq ($(strip $(KERL)),)
  9. KERL := $(ERLANG_MK_TMP)/kerl/kerl
  10. endif
  11. export KERL
  12. KERL_GIT ?= https://github.com/kerl/kerl
  13. KERL_COMMIT ?= master
  14. KERL_MAKEFLAGS ?=
  15. OTP_GIT ?= https://github.com/erlang/otp
  16. CI_INSTALL_DIR ?= $(HOME)/erlang
  17. ci:: $(addprefix ci-,$(CI_OTP))
  18. ci-prepare: $(addprefix $(CI_INSTALL_DIR)/,$(CI_OTP))
  19. ci-setup::
  20. ci_verbose_0 = @echo " CI " $(1);
  21. ci_verbose = $(ci_verbose_$(V))
  22. define ci_target
  23. ci-$(1): $(CI_INSTALL_DIR)/$(1)
  24. $(verbose) $(MAKE) --no-print-directory clean;
  25. $(ci_verbose) \
  26. PATH="$(CI_INSTALL_DIR)/$(1)/bin:$(PATH)" \
  27. CI_OTP_RELEASE="$(1)" \
  28. CT_OPTS="-label $(1)" \
  29. $(MAKE) ci-setup tests
  30. endef
  31. $(foreach otp,$(CI_OTP),$(eval $(call ci_target,$(otp))))
  32. define ci_otp_target
  33. ifeq ($(wildcard $(CI_INSTALL_DIR)/$(1)),)
  34. $(CI_INSTALL_DIR)/$(1): $(KERL)
  35. MAKEFLAGS="$(KERL_MAKEFLAGS)" $(KERL) build git $(OTP_GIT) $(1) $(1)
  36. $(KERL) install $(1) $(CI_INSTALL_DIR)/$(1)
  37. endif
  38. endef
  39. $(foreach otp,$(CI_OTP),$(eval $(call ci_otp_target,$(otp))))
  40. $(KERL):
  41. $(verbose) mkdir -p $(ERLANG_MK_TMP)
  42. $(gen_verbose) git clone --depth 1 $(KERL_GIT) $(ERLANG_MK_TMP)/kerl
  43. $(verbose) cd $(ERLANG_MK_TMP)/kerl && git checkout $(KERL_COMMIT)
  44. $(verbose) chmod +x $(KERL)
  45. help::
  46. $(verbose) printf "%s\n" "" \
  47. "Continuous Integration targets:" \
  48. " ci Run '$(MAKE) tests' on all configured Erlang versions." \
  49. "" \
  50. "The CI_OTP variable must be defined with the Erlang versions" \
  51. "that must be tested. For example: CI_OTP = OTP-17.3.4 OTP-17.5.3"
  52. distclean:: distclean-kerl
  53. distclean-kerl:
  54. $(gen_verbose) rm -rf $(KERL)
  55. endif