core_plugins.mk 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Core: External plugins.
  2. CORE_PLUGINS_CASES = all one test
  3. CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES))
  4. .PHONY: core-plugins $(CORE_PLUGINS_TARGETS)
  5. core-plugins: $(CORE_PLUGINS_TARGETS)
  6. core-plugins-all: build clean
  7. $i "Bootstrap a new OTP library named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  11. $i "Create a local git repository with two plugins"
  12. $t mkdir -p $(APP)/plugin_dep/mk
  13. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  14. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  15. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  16. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  17. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  18. # We check that overriding THIS doesn't cause an error.
  19. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  20. $t cd $(APP)/plugin_dep && \
  21. git init -q && \
  22. git config user.email "testsuite@erlang.mk" && \
  23. git config user.name "test suite" && \
  24. git add . && \
  25. git commit -q -m "Tests"
  26. $i "Add dependency and plugins to the Makefile"
  27. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = plugin_dep\ndep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\nDEP_PLUGINS = plugin_dep\n"}' $(APP)/Makefile
  28. $i "Run 'make plugin1' and check that it prints plugin1"
  29. $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
  30. $i "Run 'make plugin2' and check that it prints plugin2"
  31. $t test -n "`$(MAKE) -C $(APP) plugin2 | grep plugin2`"
  32. core-plugins-one: build clean
  33. $i "Bootstrap a new OTP library named $(APP)"
  34. $t mkdir $(APP)/
  35. $t cp ../erlang.mk $(APP)/
  36. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  37. $i "Create a local git repository with two plugins"
  38. $t mkdir -p $(APP)/plugin_dep/mk
  39. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  40. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  41. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  42. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  43. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  44. # We check that overriding THIS doesn't cause an error.
  45. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  46. $t cd $(APP)/plugin_dep && \
  47. git init -q && \
  48. git config user.email "testsuite@erlang.mk" && \
  49. git config user.name "test suite" && \
  50. git add . && \
  51. git commit -q -m "Tests"
  52. $i "Add dependency and plugins to the Makefile"
  53. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = plugin_dep\ndep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\nDEP_PLUGINS = plugin_dep/mk/plugin1.mk\n"}' $(APP)/Makefile
  54. $i "Run 'make plugin1' and check that it prints plugin1"
  55. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  56. $i "Run 'make plugin2' and confirm the target doesn't exist"
  57. $t ! $(MAKE) --no-print-directory -C $(APP) plugin2
  58. core-plugins-test: build clean
  59. $i "Bootstrap a new OTP library named $(APP)"
  60. $t mkdir $(APP)/
  61. $t cp ../erlang.mk $(APP)/
  62. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  63. $i "Write external plugin touch_plugin"
  64. $t mkdir $(APP)/touch_plugin
  65. $t echo -e "app::" >> $(APP)/touch_plugin/plugins.mk
  66. $t echo -e "\ttouch markerfile" >> $(APP)/touch_plugin/plugins.mk
  67. $t echo -e "test-build:: app" >> $(APP)/touch_plugin/plugins.mk
  68. $t echo -e "clean::" >> $(APP)/touch_plugin/plugins.mk
  69. $t echo -e "\trm -f markerfile" >> $(APP)/touch_plugin/plugins.mk
  70. $i "Inject external plugin dependencies into $(APP)"
  71. $t echo 'BUILD_DEPS = touch_plugin' >>$(APP)/Makefile.tmp
  72. $t echo 'DEP_PLUGINS = touch_plugin' >>$(APP)/Makefile.tmp
  73. $t echo 'dep_touch_plugin = cp touch_plugin' >>$(APP)/Makefile.tmp
  74. $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp
  75. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  76. $i "Build the application"
  77. $t $(MAKE) -C $(APP) $v
  78. $i "Check that the application was compiled correctly"
  79. $t test -e $(APP)/markerfile
  80. $i "Clean the application"
  81. $t $(MAKE) -C $(APP) clean $v
  82. $i "Check that the application was cleaned correctly"
  83. $t test ! -e $(APP)/markerfile
  84. $i "Run tests"
  85. $t $(MAKE) -C $(APP) tests $v
  86. $i "Check that the application was compiled correctly"
  87. $t test -e $(APP)/markerfile