core_deps.mk 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. # Core: Packages and dependencies.
  2. CORE_DEPS_CASES = build-c-8cc build-c-imagejs build-erl build-js doc otp pkg rel search
  3. CORE_DEPS_TARGETS = $(addprefix core-deps-,$(CORE_DEPS_CASES))
  4. CORE_DEPS_CLEAN_TARGETS = $(addprefix clean-,$(CORE_DEPS_TARGETS))
  5. .PHONY: core-deps $(CORE_DEPS_TARGETS) clean-core-deps $(CORE_DEPS_CLEAN_TARGETS)
  6. clean-core-deps: $(CORE_DEPS_CLEAN_TARGETS)
  7. $(CORE_DEPS_CLEAN_TARGETS):
  8. $t rm -rf $(APP_TO_CLEAN)/
  9. core-deps: $(CORE_DEPS_TARGETS)
  10. ifneq ($(PLATFORM),msys2)
  11. core-deps-build-c-8cc: build clean-core-deps-build-c-8cc
  12. $i "Bootstrap a new OTP library named $(APP)"
  13. $t mkdir $(APP)/
  14. $t cp ../erlang.mk $(APP)/
  15. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  16. $i "Add 8cc to the list of build dependencies"
  17. $t sed -i.bak '2i\
  18. BUILD_DEPS = 8cc\
  19. dep_8cc = git https://github.com/rui314/8cc master\
  20. ' $(APP)/Makefile
  21. $i "Build the application"
  22. $t $(MAKE) -C $(APP) $v
  23. $i "Check that all dependencies were fetched"
  24. $t test -d $(APP)/deps/8cc
  25. $i "Check that 8cc can be started"
  26. $t $(APP)/deps/8cc/8cc -h $v
  27. $i "Check that the application was compiled correctly"
  28. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  29. [ok = application:load(App) || App <- [$(APP)]], \
  30. {ok, Deps} = application:get_key($(APP), applications), \
  31. false = lists:member('8cc', Deps), \
  32. halt()"
  33. endif
  34. core-deps-build-c-imagejs: build clean-core-deps-build-c-imagejs
  35. $i "Bootstrap a new OTP library named $(APP)"
  36. $t mkdir $(APP)/
  37. $t cp ../erlang.mk $(APP)/
  38. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  39. $i "Add imagejs to the list of build dependencies"
  40. $t sed -i.bak '2i\
  41. BUILD_DEPS = imagejs\
  42. dep_imagejs = git https://github.com/jklmnn/imagejs master\
  43. ' $(APP)/Makefile
  44. $i "Build the application"
  45. $t $(MAKE) -C $(APP) $v
  46. $i "Check that all dependencies were fetched"
  47. $t test -d $(APP)/deps/imagejs
  48. $i "Check that imagejs works"
  49. $t $(APP)/deps/imagejs/imagejs bmp $(APP)/deps/imagejs/Makefile
  50. $t test -f $(APP)/deps/imagejs/Makefile.bmp
  51. $i "Check that the application was compiled correctly"
  52. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  53. [ok = application:load(App) || App <- [$(APP)]], \
  54. {ok, Deps} = application:get_key($(APP), applications), \
  55. false = lists:member(imagejs, Deps), \
  56. halt()"
  57. core-deps-build-erl: build clean-core-deps-build-erl
  58. $i "Bootstrap a new OTP library named $(APP)"
  59. $t mkdir $(APP)/
  60. $t cp ../erlang.mk $(APP)/
  61. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  62. $i "Add cowlib to the list of build dependencies"
  63. $t sed -i.bak '2i\
  64. BUILD_DEPS = cowlib\
  65. ' $(APP)/Makefile
  66. $i "Build the application"
  67. $t $(MAKE) -C $(APP) $v
  68. $i "Check that all dependencies were fetched"
  69. $t test -d $(APP)/deps/cowlib
  70. $i "Check that the application was compiled correctly"
  71. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  72. [ok = application:load(App) || App <- [$(APP), cowlib]], \
  73. {ok, Deps} = application:get_key($(APP), applications), \
  74. false = lists:member(cowlib, Deps), \
  75. halt()"
  76. core-deps-build-js: build clean-core-deps-build-js
  77. $i "Bootstrap a new OTP library named $(APP)"
  78. $t mkdir $(APP)/
  79. $t cp ../erlang.mk $(APP)/
  80. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  81. $i "Add jquery to the list of build dependencies"
  82. $t sed -i.bak '2i\
  83. BUILD_DEPS = jquery\
  84. dep_jquery = git https://github.com/jquery/jquery master\
  85. ' $(APP)/Makefile
  86. $i "Build the application"
  87. $t $(MAKE) -C $(APP) $v
  88. $i "Check that all dependencies were fetched"
  89. $t test -d $(APP)/deps/jquery
  90. $i "Check that the application was compiled correctly"
  91. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  92. [ok = application:load(App) || App <- [$(APP)]], \
  93. {ok, Deps} = application:get_key($(APP), applications), \
  94. false = lists:member(jquery, Deps), \
  95. halt()"
  96. core-deps-doc: build clean-core-deps-doc
  97. $i "Bootstrap a new OTP library named $(APP)"
  98. $t mkdir $(APP)/
  99. $t cp ../erlang.mk $(APP)/
  100. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  101. $i "Generate .erl files"
  102. $t echo "-module(boy)." > $(APP)/src/boy.erl
  103. $t echo "-module(girl)." > $(APP)/src/girl.erl
  104. $i "Add Edown as a documentation building dependency"
  105. $t sed -i.bak '2i\
  106. DOC_DEPS = edown\
  107. EDOC_OPTS = {doclet, edown_doclet}\
  108. ' $(APP)/Makefile
  109. $i "Build the application"
  110. $t $(MAKE) -C $(APP) $v
  111. $i "Check that no dependencies were fetched"
  112. $t test ! -e $(APP)/deps
  113. $i "Check that the application was compiled correctly"
  114. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  115. [ok = application:load(App) || App <- [$(APP)]], \
  116. {ok, Deps} = application:get_key($(APP), applications), \
  117. false = lists:member(edown, Deps), \
  118. halt()"
  119. $i "Build the application documentation"
  120. $t $(MAKE) -C $(APP) docs $v
  121. $i "Check that documentation dependencies were fetched"
  122. $t test -d $(APP)/deps/edown
  123. $i "Check the Edown generated Markdown documentation"
  124. $t test -f $(APP)/doc/boy.md
  125. $t test -f $(APP)/doc/girl.md
  126. ifndef LEGACY
  127. core-deps-otp: build clean-core-deps-otp
  128. $i "Bootstrap a new OTP library named $(APP)"
  129. $t mkdir $(APP)/
  130. $t cp ../erlang.mk $(APP)/
  131. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  132. $i "Add Crypto to the list of OTP dependencies"
  133. $t sed -i.bak '2i\
  134. OTP_DEPS = crypto\
  135. ' $(APP)/Makefile
  136. $i "Build the application"
  137. $t $(MAKE) -C $(APP) $v
  138. $i "Check that no dependencies were fetched"
  139. $t test ! -e $(APP)/deps
  140. $i "Check that the application was compiled correctly"
  141. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  142. [ok = application:load(App) || App <- [$(APP), crypto]], \
  143. {ok, Deps} = application:get_key($(APP), applications), \
  144. true = lists:member(crypto, Deps), \
  145. halt()"
  146. endif
  147. core-deps-pkg: build clean-core-deps-pkg
  148. $i "Bootstrap a new OTP library named $(APP)"
  149. $t mkdir $(APP)/
  150. $t cp ../erlang.mk $(APP)/
  151. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  152. $i "Add Cowboy to the list of dependencies"
  153. $t sed -i.bak '2i\
  154. DEPS = cowboy\
  155. ' $(APP)/Makefile
  156. ifdef LEGACY
  157. $i "Add Cowboy to the applications key in the .app.src file"
  158. $t sed -i.bak '8i\
  159. cowboy,' $(APP)/src/$(APP).app.src
  160. endif
  161. $i "Build the application"
  162. $t $(MAKE) -C $(APP) $v
  163. $i "Check that all dependencies were fetched"
  164. $t test -d $(APP)/deps/cowboy
  165. $t test -d $(APP)/deps/cowlib
  166. $t test -d $(APP)/deps/ranch
  167. $i "Check that the application was compiled correctly"
  168. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  169. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  170. {ok, Deps} = application:get_key($(APP), applications), \
  171. true = lists:member(cowboy, Deps), \
  172. halt()"
  173. core-deps-rel: build clean-core-deps-rel
  174. $i "Bootstrap a new release-enabled OTP application named $(APP)"
  175. $t mkdir $(APP)/
  176. $t cp ../erlang.mk $(APP)/
  177. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib bootstrap-rel $v
  178. $i "Add Recon to the list of dependencies"
  179. $t sed -i.bak '2i\
  180. REL_DEPS = recon\
  181. ' $(APP)/Makefile
  182. $i "Add Recon to the relx.config file"
  183. $t $(ERL) -eval " \
  184. {ok, Conf0} = file:consult(\"$(APP)/relx.config\"), \
  185. Conf = lists:keyreplace(release, 1, Conf0, {release, {$(APP)_release, \"1\"}, [$(APP), recon]}), \
  186. ok = file:write_file(\"$(APP)/relx.config\", \
  187. lists:map(fun(Term) -> io_lib:format(\"~p.~n\", [Term]) end, Conf)), \
  188. halt()"
  189. $i "Build the application and its dependencies"
  190. $t $(MAKE) -C $(APP) deps app $v
  191. $i "Check that no dependencies were fetched"
  192. $t test ! -e $(APP)/deps
  193. $i "Check that the application was compiled correctly"
  194. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  195. [ok = application:load(App) || App <- [$(APP)]], \
  196. {ok, Deps} = application:get_key($(APP), applications), \
  197. false = lists:member(recon, Deps), \
  198. halt()"
  199. $i "Build the release"
  200. $t $(MAKE) -C $(APP) $v
  201. $i "Check that all dependencies were fetched"
  202. $t test -d $(APP)/deps/recon
  203. $i "Check that the application was compiled correctly"
  204. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  205. [ok = application:load(App) || App <- [$(APP)]], \
  206. {ok, Deps} = application:get_key($(APP), applications), \
  207. false = lists:member(recon, Deps), \
  208. halt()"
  209. $i "Start the release and check that Recon is loaded"
  210. ifeq ($(PLATFORM),msys2)
  211. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd install $v
  212. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd start $v
  213. else
  214. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  215. endif
  216. $t test -n "`$(APP)/_rel/$(APP)_release/bin/$(APP)_release rpcterms \
  217. application loaded_applications | grep recon`"
  218. ifeq ($(PLATFORM),msys2)
  219. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd stop $v
  220. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd uninstall $v
  221. else
  222. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  223. endif
  224. core-deps-search: build clean-core-deps-search
  225. $i "Bootstrap a new OTP library named $(APP)"
  226. $t mkdir $(APP)/
  227. $t cp ../erlang.mk $(APP)/
  228. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  229. $i "Run 'make search' and check that it prints packages"
  230. $t test -n "`$(MAKE) -C $(APP) search`"
  231. $i "Run 'make search q=cowboy' and check that it prints packages"
  232. $t test -n "`$(MAKE) -C $(APP) search q=cowboy`"