core_plugins.mk 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. # Core: External plugins.
  2. CORE_PLUGINS_TARGETS = $(call list_targets,core-plugins)
  3. .PHONY: core-plugins $(CORE_PLUGINS_TARGETS)
  4. core-plugins: $(CORE_PLUGINS_TARGETS)
  5. core-plugins-all: build clean
  6. $i "Bootstrap a new OTP library named $(APP)"
  7. $t mkdir $(APP)/
  8. $t cp ../erlang.mk $(APP)/
  9. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  10. $i "Create a local git repository with two plugins"
  11. $t mkdir -p $(APP)/plugin_dep/mk
  12. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  13. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  14. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  15. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  16. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  17. # We check that overriding THIS doesn't cause an error.
  18. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  19. $t cd $(APP)/plugin_dep && \
  20. git init -q && \
  21. git config user.email "testsuite@erlang.mk" && \
  22. git config user.name "test suite" && \
  23. git add . && \
  24. git commit -q --no-gpg-sign -m "Tests"
  25. $i "Add dependency and plugins to the Makefile"
  26. $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
  27. $i "Run 'make plugin1' and check that it prints plugin1"
  28. $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
  29. $i "Run 'make plugin2' and check that it prints plugin2"
  30. $t test -n "`$(MAKE) -C $(APP) plugin2 | grep plugin2`"
  31. core-plugins-early: build clean
  32. $i "Bootstrap a new OTP library named $(APP)"
  33. $t mkdir $(APP)/
  34. $t cp ../erlang.mk $(APP)/
  35. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  36. $i "Write external plugin adddep_plugin"
  37. $t mkdir $(APP)/adddep_plugin
  38. $t echo -e "DEPS += cowlib" >> $(APP)/adddep_plugin/early-plugins.mk
  39. $i "Inject external plugin dependencies into $(APP)"
  40. $t echo 'DEPS = ranch' >>$(APP)/Makefile.tmp
  41. $t echo 'BUILD_DEPS = adddep_plugin' >>$(APP)/Makefile.tmp
  42. $t echo 'DEP_EARLY_PLUGINS = adddep_plugin' >>$(APP)/Makefile.tmp
  43. $t echo 'dep_adddep_plugin = cp adddep_plugin' >>$(APP)/Makefile.tmp
  44. $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp
  45. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  46. $i "Build the application"
  47. $t $(MAKE) -C $(APP) $v
  48. $i "Check that all dependencies were fetched"
  49. $t test -e $(APP)/deps/cowlib
  50. $t test -e $(APP)/deps/ranch
  51. core-plugins-early-local: build clean
  52. $i "Bootstrap a new OTP library named $(APP)"
  53. $t mkdir $(APP)/
  54. $t cp ../erlang.mk $(APP)/
  55. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  56. $i "Create two internal plugin makefiles"
  57. $t mkdir -p $(APP)/mk
  58. $t echo "plugin1: ; @echo \$$@" > $(APP)/mk/plugin1.mk
  59. $t echo "plugin2: ; @echo \$$@" > $(APP)/early-plugins.mk
  60. $i "Add dependency and plugins to the Makefile"
  61. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEP_EARLY_PLUGINS = \$$(PROJECT) \$$(PROJECT)/mk/plugin1.mk\n"}' $(APP)/Makefile
  62. $i "Run 'make plugin1' and check that it prints plugin1"
  63. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  64. $i "Run 'make plugin2' and check that it prints plugin2"
  65. $t $(MAKE) --no-print-directory -C $(APP) plugin2 | grep -qw plugin2
  66. core-plugins-local: build clean
  67. $i "Bootstrap a new OTP library named $(APP)"
  68. $t mkdir $(APP)/
  69. $t cp ../erlang.mk $(APP)/
  70. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  71. $i "Create two internal plugin makefiles"
  72. $t mkdir -p $(APP)/mk
  73. $t echo "plugin1: ; @echo \$$@" > $(APP)/mk/plugin1.mk
  74. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugins.mk
  75. $i "Add dependency and plugins to the Makefile"
  76. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEP_PLUGINS = \$$(PROJECT) \$$(PROJECT)/mk/plugin1.mk\n"}' $(APP)/Makefile
  77. $i "Run 'make plugin1' and check that it prints plugin1"
  78. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  79. $i "Run 'make plugin2' and check that it prints plugin2"
  80. $t $(MAKE) --no-print-directory -C $(APP) plugin2 | grep -qw plugin2
  81. core-plugins-one: build clean
  82. $i "Bootstrap a new OTP library named $(APP)"
  83. $t mkdir $(APP)/
  84. $t cp ../erlang.mk $(APP)/
  85. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  86. $i "Create a local git repository with two plugins"
  87. $t mkdir -p $(APP)/plugin_dep/mk
  88. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  89. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  90. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  91. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  92. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  93. # We check that overriding THIS doesn't cause an error.
  94. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  95. $t cd $(APP)/plugin_dep && \
  96. git init -q && \
  97. git config user.email "testsuite@erlang.mk" && \
  98. git config user.name "test suite" && \
  99. git add . && \
  100. git commit -q --no-gpg-sign -m "Tests"
  101. $i "Add dependency and plugins to the Makefile"
  102. $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
  103. $i "Run 'make plugin1' and check that it prints plugin1"
  104. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  105. $i "Run 'make plugin2' and confirm the target doesn't exist"
  106. $t ! $(MAKE) --no-print-directory -C $(APP) plugin2
  107. core-plugins-templates: build clean
  108. $i "Bootstrap a new OTP library named $(APP)"
  109. $t mkdir $(APP)/
  110. $t cp ../erlang.mk $(APP)/
  111. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  112. $i "Create a local git repository with a plugin containing a template"
  113. $t mkdir -p $(APP)/plugin_dep
  114. $t printf "%s\n" \
  115. "define tpl_test_mk" \
  116. "-module(test_mk)." \
  117. "endef" > $(APP)/plugin_dep/plugins.mk
  118. $t cd $(APP)/plugin_dep && \
  119. git init -q && \
  120. git config user.email "testsuite@erlang.mk" && \
  121. git config user.name "test suite" && \
  122. git add . && \
  123. git commit -q --no-gpg-sign -m "Tests"
  124. $i "Add dependency and plugins to the Makefile"
  125. $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
  126. $i "Run 'make list-templates' and check that it prints test_mk"
  127. $t $(MAKE) --no-print-directory -C $(APP) list-templates | grep -qw test_mk
  128. $i "Create a new file using the template"
  129. $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk $v
  130. $i "Confirm the file exists"
  131. $t test -f $(APP)/src/test_mk.erl
  132. $i "Build the application"
  133. $t $(MAKE) -C $(APP) $v
  134. $i "Check that the file was compiled correctly"
  135. $t test -f $(APP)/ebin/test_mk.beam
  136. core-plugins-templates-apps-only: build clean
  137. $i "Create a multi application repository with no root application"
  138. $t mkdir $(APP)/
  139. $t cp ../erlang.mk $(APP)/
  140. $t echo "include erlang.mk" > $(APP)/Makefile
  141. $i "Create a new application my_app"
  142. $t $(MAKE) -C $(APP) new-app in=my_app $v
  143. $i "Create a local git repository with a plugin containing a template"
  144. $t mkdir -p $(APP)/plugin_dep
  145. $t printf "%s\n" \
  146. "define tpl_test_mk" \
  147. "-module(test_mk)." \
  148. "endef" > $(APP)/plugin_dep/plugins.mk
  149. $t cd $(APP)/plugin_dep && \
  150. git init -q && \
  151. git config user.email "testsuite@erlang.mk" && \
  152. git config user.name "test suite" && \
  153. git add . && \
  154. git commit -q --no-gpg-sign -m "Tests"
  155. $i "Add dependency and plugins to the Makefile"
  156. $t printf "%s\n" \
  157. "DEPS = plugin_dep" \
  158. "dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master" \
  159. "DEP_PLUGINS = plugin_dep" \
  160. "include erlang.mk" > $(APP)/Makefile
  161. $i "Create a new file using the template in the my_app application"
  162. $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk in=my_app $v
  163. $i "Confirm the file exists"
  164. $t test -f $(APP)/apps/my_app/src/test_mk.erl
  165. $i "Build the application"
  166. $t $(MAKE) -C $(APP) $v
  167. $i "Check that the file was compiled correctly"
  168. $t test -f $(APP)/apps/my_app/ebin/test_mk.beam
  169. core-plugins-test: build clean
  170. $i "Bootstrap a new OTP library named $(APP)"
  171. $t mkdir $(APP)/
  172. $t cp ../erlang.mk $(APP)/
  173. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  174. $i "Write external plugin touch_plugin"
  175. $t mkdir $(APP)/touch_plugin
  176. $t echo -e "app::" >> $(APP)/touch_plugin/plugins.mk
  177. $t echo -e "\ttouch markerfile" >> $(APP)/touch_plugin/plugins.mk
  178. $t echo -e "test-build:: app" >> $(APP)/touch_plugin/plugins.mk
  179. $t echo -e "clean::" >> $(APP)/touch_plugin/plugins.mk
  180. $t echo -e "\trm -f markerfile" >> $(APP)/touch_plugin/plugins.mk
  181. $i "Inject external plugin dependencies into $(APP)"
  182. $t echo 'BUILD_DEPS = touch_plugin' >>$(APP)/Makefile.tmp
  183. $t echo 'DEP_PLUGINS = touch_plugin' >>$(APP)/Makefile.tmp
  184. $t echo 'dep_touch_plugin = cp touch_plugin' >>$(APP)/Makefile.tmp
  185. $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp
  186. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  187. $i "Build the application"
  188. $t $(MAKE) -C $(APP) $v
  189. $i "Check that the application was compiled correctly"
  190. $t test -e $(APP)/markerfile
  191. $i "Clean the application"
  192. $t $(MAKE) -C $(APP) clean $v
  193. $i "Check that the application was cleaned correctly"
  194. $t test ! -e $(APP)/markerfile
  195. $i "Run tests"
  196. $t $(MAKE) -C $(APP) tests $v
  197. $i "Check that the application was compiled correctly"
  198. $t test -e $(APP)/markerfile