core_plugins.mk 11 KB

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