ci.mk 2.4 KB

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