ci.mk 2.7 KB

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