core_deps.mk 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. # Core: Packages and dependencies.
  2. CORE_DEPS_CASES = build-c-8cc build-c-imagejs build-erl build-js dep-commit doc otp pkg rel search shell test
  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-dep-commit: build clean-core-deps-dep-commit
  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 "Add Cowboy 1.0.0 to the list of dependencies"
  102. $t sed -i.bak '2i\
  103. DEPS = cowboy\
  104. dep_cowboy_commit = 1.0.0\
  105. ' $(APP)/Makefile
  106. ifdef LEGACY
  107. $i "Add Cowboy to the applications key in the .app.src file"
  108. $t sed -i.bak '8i\
  109. cowboy,' $(APP)/src/$(APP).app.src
  110. endif
  111. $i "Build the application"
  112. $t $(MAKE) -C $(APP) $v
  113. $i "Check that all dependencies were fetched"
  114. $t test -d $(APP)/deps/cowboy
  115. $t test -d $(APP)/deps/cowlib
  116. $t test -d $(APP)/deps/ranch
  117. $i "Check that the application was compiled correctly"
  118. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  119. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  120. {ok, Deps} = application:get_key($(APP), applications), \
  121. true = lists:member(cowboy, Deps), \
  122. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  123. halt()"
  124. core-deps-doc: build clean-core-deps-doc
  125. $i "Bootstrap a new OTP library named $(APP)"
  126. $t mkdir $(APP)/
  127. $t cp ../erlang.mk $(APP)/
  128. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  129. $i "Generate .erl files"
  130. $t echo "-module(boy)." > $(APP)/src/boy.erl
  131. $t echo "-module(girl)." > $(APP)/src/girl.erl
  132. $i "Add Edown as a documentation building dependency"
  133. $t sed -i.bak '2i\
  134. DOC_DEPS = edown\
  135. EDOC_OPTS = {doclet, edown_doclet}\
  136. ' $(APP)/Makefile
  137. $i "Build the application"
  138. $t $(MAKE) -C $(APP) $v
  139. $i "Check that no dependencies were fetched"
  140. $t test ! -e $(APP)/deps
  141. $i "Check that the application was compiled correctly"
  142. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  143. [ok = application:load(App) || App <- [$(APP)]], \
  144. {ok, Deps} = application:get_key($(APP), applications), \
  145. false = lists:member(edown, Deps), \
  146. halt()"
  147. $i "Build the application documentation"
  148. $t $(MAKE) -C $(APP) docs $v
  149. $i "Check that documentation dependencies were fetched"
  150. $t test -d $(APP)/deps/edown
  151. $i "Check the Edown generated Markdown documentation"
  152. $t test -f $(APP)/doc/boy.md
  153. $t test -f $(APP)/doc/girl.md
  154. ifndef LEGACY
  155. core-deps-otp: build clean-core-deps-otp
  156. $i "Bootstrap a new OTP library named $(APP)"
  157. $t mkdir $(APP)/
  158. $t cp ../erlang.mk $(APP)/
  159. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  160. $i "Add Crypto to the list of OTP dependencies"
  161. $t sed -i.bak '2i\
  162. OTP_DEPS = crypto\
  163. ' $(APP)/Makefile
  164. $i "Build the application"
  165. $t $(MAKE) -C $(APP) $v
  166. $i "Check that no dependencies were fetched"
  167. $t test ! -e $(APP)/deps
  168. $i "Check that the application was compiled correctly"
  169. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  170. [ok = application:load(App) || App <- [$(APP), crypto]], \
  171. {ok, Deps} = application:get_key($(APP), applications), \
  172. true = lists:member(crypto, Deps), \
  173. halt()"
  174. endif
  175. core-deps-pkg: build clean-core-deps-pkg
  176. $i "Bootstrap a new OTP library named $(APP)"
  177. $t mkdir $(APP)/
  178. $t cp ../erlang.mk $(APP)/
  179. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  180. $i "Add Cowboy to the list of dependencies"
  181. $t sed -i.bak '2i\
  182. DEPS = cowboy\
  183. ' $(APP)/Makefile
  184. ifdef LEGACY
  185. $i "Add Cowboy to the applications key in the .app.src file"
  186. $t sed -i.bak '8i\
  187. cowboy,' $(APP)/src/$(APP).app.src
  188. endif
  189. $i "Build the application"
  190. $t $(MAKE) -C $(APP) $v
  191. $i "Check that all dependencies were fetched"
  192. $t test -d $(APP)/deps/cowboy
  193. $t test -d $(APP)/deps/cowlib
  194. $t test -d $(APP)/deps/ranch
  195. $i "Check that the application was compiled correctly"
  196. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  197. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  198. {ok, Deps} = application:get_key($(APP), applications), \
  199. true = lists:member(cowboy, Deps), \
  200. halt()"
  201. core-deps-rel: build clean-core-deps-rel
  202. $i "Bootstrap a new release-enabled OTP library named $(APP)"
  203. $t mkdir $(APP)/
  204. $t cp ../erlang.mk $(APP)/
  205. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib bootstrap-rel $v
  206. $i "Add Recon to the list of release dependencies"
  207. $t sed -i.bak '2i\
  208. REL_DEPS = recon\
  209. ' $(APP)/Makefile
  210. $i "Add Recon to the relx.config file"
  211. $t $(ERL) -eval " \
  212. {ok, Conf0} = file:consult(\"$(APP)/relx.config\"), \
  213. Conf = lists:keyreplace(release, 1, Conf0, {release, {$(APP)_release, \"1\"}, [$(APP), recon]}), \
  214. ok = file:write_file(\"$(APP)/relx.config\", \
  215. lists:map(fun(Term) -> io_lib:format(\"~p.~n\", [Term]) end, Conf)), \
  216. halt()"
  217. $i "Build the application and its dependencies"
  218. $t $(MAKE) -C $(APP) deps app $v
  219. $i "Check that no dependencies were fetched"
  220. $t test ! -e $(APP)/deps
  221. $i "Check that the application was compiled correctly"
  222. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  223. [ok = application:load(App) || App <- [$(APP)]], \
  224. {ok, Deps} = application:get_key($(APP), applications), \
  225. false = lists:member(recon, Deps), \
  226. halt()"
  227. $i "Build the release"
  228. $t $(MAKE) -C $(APP) $v
  229. $i "Check that all dependencies were fetched"
  230. $t test -d $(APP)/deps/recon
  231. $i "Check that the application was compiled correctly"
  232. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  233. [ok = application:load(App) || App <- [$(APP)]], \
  234. {ok, Deps} = application:get_key($(APP), applications), \
  235. false = lists:member(recon, Deps), \
  236. halt()"
  237. # @todo Add check for MSYS2 when releases under Windows become usable.
  238. # $i "Start the release and check that Recon is loaded"
  239. ifeq ($(PLATFORM),msys2)
  240. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd install $v
  241. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd start $v
  242. # $t test -n "`$(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd rpcterms \
  243. # application loaded_applications | grep recon`"
  244. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd stop $v
  245. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd uninstall $v
  246. else
  247. $i "Start the release and check that Recon is loaded"
  248. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  249. $t test -n "`$(APP)/_rel/$(APP)_release/bin/$(APP)_release rpcterms \
  250. application loaded_applications | grep recon`"
  251. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  252. endif
  253. core-deps-search: build clean-core-deps-search
  254. $i "Bootstrap a new OTP library named $(APP)"
  255. $t mkdir $(APP)/
  256. $t cp ../erlang.mk $(APP)/
  257. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  258. $i "Run 'make search' and check that it prints packages"
  259. $t test -n "`$(MAKE) -C $(APP) search`"
  260. $i "Run 'make search q=cowboy' and check that it prints packages"
  261. $t test -n "`$(MAKE) -C $(APP) search q=cowboy`"
  262. core-deps-shell: build clean-core-deps-shell
  263. $i "Bootstrap a new OTP library named $(APP)"
  264. $t mkdir $(APP)/
  265. $t cp ../erlang.mk $(APP)/
  266. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  267. $i "Add TDDReloader to the list of shell dependencies"
  268. $t sed -i.bak '2i\
  269. SHELL_DEPS = tddreloader\
  270. ' $(APP)/Makefile
  271. $i "Build the application and its dependencies"
  272. $t $(MAKE) -C $(APP) deps app $v
  273. $i "Check that no dependencies were fetched"
  274. $t test ! -e $(APP)/deps
  275. $i "Check that the application was compiled correctly"
  276. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  277. [ok = application:load(App) || App <- [$(APP)]], \
  278. {ok, Deps} = application:get_key($(APP), applications), \
  279. false = lists:member(tddreloader, Deps), \
  280. halt()"
  281. $i "Run the shell"
  282. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval \" \
  283. ok = application:load($(APP)), \
  284. ok = application:load(tddreloader), \
  285. halt()\"" $v
  286. $i "Check that all dependencies were fetched"
  287. $t test -d $(APP)/deps/tddreloader
  288. $i "Check that the application was compiled correctly"
  289. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  290. [ok = application:load(App) || App <- [$(APP)]], \
  291. {ok, Deps} = application:get_key($(APP), applications), \
  292. false = lists:member(tddreloader, Deps), \
  293. halt()"
  294. core-deps-test: build clean-core-deps-test
  295. $i "Bootstrap a new OTP library named $(APP)"
  296. $t mkdir $(APP)/
  297. $t cp ../erlang.mk $(APP)/
  298. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  299. $i "Generate .erl files"
  300. $t echo "-module(boy)." > $(APP)/src/boy.erl
  301. $t echo "-module(girl)." > $(APP)/src/girl.erl
  302. $i "Add triq to the list of test dependencies"
  303. $t sed -i.bak '2i\
  304. TEST_DEPS = triq\
  305. ' $(APP)/Makefile
  306. $i "Build the application and its dependencies"
  307. $t $(MAKE) -C $(APP) deps app $v
  308. $i "Check that no dependencies were fetched"
  309. $t test ! -e $(APP)/deps
  310. $i "Check that the application was compiled correctly"
  311. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  312. [ok = application:load(App) || App <- [$(APP)]], \
  313. {ok, Deps} = application:get_key($(APP), applications), \
  314. false = lists:member(triq, Deps), \
  315. halt()"
  316. $i "Run tests"
  317. $t $(MAKE) -C $(APP) tests $v
  318. $i "Check that all dependencies were fetched"
  319. $t test -d $(APP)/deps/triq
  320. $i "Check that the application was compiled correctly"
  321. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  322. [ok = application:load(App) || App <- [$(APP)]], \
  323. {ok, Deps} = application:get_key($(APP), applications), \
  324. false = lists:member(triq, Deps), \
  325. halt()"