ci.mk 2.7 KB

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