core_plugins.mk 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 "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-early-help: 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 "Write external plugin helpful_plugin"
  72. $t mkdir $(APP)/helpful_plugin
  73. $t echo "help-plugins:: ; @echo WORKING" >> $(APP)/helpful_plugin/early-plugins.mk
  74. $i "Inject external plugin dependencies into $(APP)"
  75. $t echo 'BUILD_DEPS = helpful_plugin' >> $(APP)/Makefile.tmp
  76. $t echo 'DEP_EARLY_PLUGINS = helpful_plugin' >> $(APP)/Makefile.tmp
  77. $t echo 'dep_helpful_plugin = cp helpful_plugin' >> $(APP)/Makefile.tmp
  78. $t cat $(APP)/Makefile >> $(APP)/Makefile.tmp
  79. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  80. $i "Build the application"
  81. $t $(MAKE) -C $(APP) $v
  82. $i "Run 'make help' and check that it prints external plugins help"
  83. $t test -n "`$(MAKE) -C $(APP) help` | grep WORKING"
  84. core-plugins-local: build clean
  85. $i "Bootstrap a new OTP library named $(APP)"
  86. $t mkdir $(APP)/
  87. $t cp ../erlang.mk $(APP)/
  88. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  89. $i "Create two internal plugin makefiles"
  90. $t mkdir -p $(APP)/mk
  91. $t echo "plugin1: ; @echo \$$@" > $(APP)/mk/plugin1.mk
  92. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugins.mk
  93. $i "Add dependency and plugins to the Makefile"
  94. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEP_PLUGINS = \$$(PROJECT) \$$(PROJECT)/mk/plugin1.mk\n"}' $(APP)/Makefile
  95. $i "Run 'make plugin1' and check that it prints plugin1"
  96. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  97. $i "Run 'make plugin2' and check that it prints plugin2"
  98. $t $(MAKE) --no-print-directory -C $(APP) plugin2 | grep -qw plugin2
  99. core-plugins-one: build clean
  100. $i "Bootstrap a new OTP library named $(APP)"
  101. $t mkdir $(APP)/
  102. $t cp ../erlang.mk $(APP)/
  103. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  104. $i "Create a local git repository with two plugins"
  105. $t mkdir -p $(APP)/plugin_dep/mk
  106. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  107. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  108. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  109. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  110. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  111. # We check that overriding THIS doesn't cause an error.
  112. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  113. $t cd $(APP)/plugin_dep && \
  114. git init -q && \
  115. git config user.email "testsuite@erlang.mk" && \
  116. git config user.name "test suite" && \
  117. git add . && \
  118. git commit -q --no-gpg-sign -m "Tests"
  119. $i "Add dependency and plugins to the Makefile"
  120. $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
  121. $i "Run 'make plugin1' and check that it prints plugin1"
  122. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  123. $i "Run 'make plugin2' and confirm the target doesn't exist"
  124. $t ! $(MAKE) --no-print-directory -C $(APP) plugin2
  125. core-plugins-templates: build clean
  126. $i "Bootstrap a new OTP library named $(APP)"
  127. $t mkdir $(APP)/
  128. $t cp ../erlang.mk $(APP)/
  129. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  130. $i "Create a local git repository with a plugin containing a template"
  131. $t mkdir -p $(APP)/plugin_dep
  132. $t printf "%s\n" \
  133. "define tpl_test_mk" \
  134. "-module(test_mk)." \
  135. "endef" > $(APP)/plugin_dep/plugins.mk
  136. $t cd $(APP)/plugin_dep && \
  137. git init -q && \
  138. git config user.email "testsuite@erlang.mk" && \
  139. git config user.name "test suite" && \
  140. git add . && \
  141. git commit -q --no-gpg-sign -m "Tests"
  142. $i "Add dependency and plugins to the Makefile"
  143. $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
  144. $i "Run 'make list-templates' and check that it prints test_mk"
  145. $t $(MAKE) --no-print-directory -C $(APP) list-templates | grep -qw test_mk
  146. $i "Create a new file using the template"
  147. $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk $v
  148. $i "Confirm the file exists"
  149. $t test -f $(APP)/src/test_mk.erl
  150. $i "Build the application"
  151. $t $(MAKE) -C $(APP) $v
  152. $i "Check that the file was compiled correctly"
  153. $t test -f $(APP)/ebin/test_mk.beam
  154. core-plugins-templates-apps-only: build clean
  155. $i "Create a multi application repository with no root application"
  156. $t mkdir $(APP)/
  157. $t cp ../erlang.mk $(APP)/
  158. $t echo "include erlang.mk" > $(APP)/Makefile
  159. $i "Create a new application my_app"
  160. $t $(MAKE) -C $(APP) new-app in=my_app $v
  161. $i "Create a local git repository with a plugin containing a template"
  162. $t mkdir -p $(APP)/plugin_dep
  163. $t printf "%s\n" \
  164. "define tpl_test_mk" \
  165. "-module(test_mk)." \
  166. "endef" > $(APP)/plugin_dep/plugins.mk
  167. $t cd $(APP)/plugin_dep && \
  168. git init -q && \
  169. git config user.email "testsuite@erlang.mk" && \
  170. git config user.name "test suite" && \
  171. git add . && \
  172. git commit -q --no-gpg-sign -m "Tests"
  173. $i "Add dependency and plugins to the Makefile"
  174. $t printf "%s\n" \
  175. "DEPS = plugin_dep" \
  176. "dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master" \
  177. "DEP_PLUGINS = plugin_dep" \
  178. "include erlang.mk" > $(APP)/Makefile
  179. $i "Create a new file using the template in the my_app application"
  180. $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk in=my_app $v
  181. $i "Confirm the file exists"
  182. $t test -f $(APP)/apps/my_app/src/test_mk.erl
  183. $i "Build the application"
  184. $t $(MAKE) -C $(APP) $v
  185. $i "Check that the file was compiled correctly"
  186. $t test -f $(APP)/apps/my_app/ebin/test_mk.beam
  187. core-plugins-test: build clean
  188. $i "Bootstrap a new OTP library named $(APP)"
  189. $t mkdir $(APP)/
  190. $t cp ../erlang.mk $(APP)/
  191. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  192. $i "Write external plugin touch_plugin"
  193. $t mkdir $(APP)/touch_plugin
  194. $t printf "%s\n" \
  195. "app::" \
  196. " touch markerfile" \
  197. "test-build:: app" \
  198. "clean::" \
  199. " rm -f markerfile" \
  200. > $(APP)/touch_plugin/plugins.mk
  201. $i "Inject external plugin dependencies into $(APP)"
  202. $t echo 'BUILD_DEPS = touch_plugin' >> $(APP)/Makefile.tmp
  203. $t echo 'DEP_PLUGINS = touch_plugin' >> $(APP)/Makefile.tmp
  204. $t echo 'dep_touch_plugin = cp touch_plugin' >> $(APP)/Makefile.tmp
  205. $t cat $(APP)/Makefile >> $(APP)/Makefile.tmp
  206. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  207. $i "Build the application"
  208. $t $(MAKE) -C $(APP) $v
  209. $i "Check that the application was compiled correctly"
  210. $t test -e $(APP)/markerfile
  211. $i "Clean the application"
  212. $t $(MAKE) -C $(APP) clean $v
  213. $i "Check that the application was cleaned correctly"
  214. $t test ! -e $(APP)/markerfile
  215. $i "Run tests"
  216. $t $(MAKE) -C $(APP) tests $v
  217. $i "Check that the application was compiled correctly"
  218. $t test -e $(APP)/markerfile