core_apps.mk 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. # Core: Multi-applications.
  2. CORE_APPS_TARGETS = $(call list_targets,core-apps)
  3. .PHONY: core-apps $(CORE_APPS_TARGETS)
  4. core-apps: $(CORE_APPS_TARGETS)
  5. core-apps-build: init
  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. # Bootstrap the application manually to make sure it works as intended.
  11. $i "Bootstrap a repository-local application my_app"
  12. $t mkdir -p $(APP)/apps/my_app/src/
  13. $t touch $(APP)/apps/file.erl
  14. $t echo "DEPS = cowlib" > $(APP)/apps/my_app/Makefile
  15. $t echo "dep_cowlib_commit = master" >> $(APP)/apps/my_app/Makefile
  16. $t echo "include ../../erlang.mk" >> $(APP)/apps/my_app/Makefile
  17. $t echo "-module(boy)." > $(APP)/apps/my_app/src/boy.erl
  18. $t echo "-module(girl)." > $(APP)/apps/my_app/src/girl.erl
  19. $i "Build the application"
  20. $t $(MAKE) -C $(APP) $v
  21. $i "Check that all compiled files exist"
  22. $t test -f $(APP)/$(APP).d
  23. $t test -f $(APP)/ebin/$(APP).app
  24. $t test -f $(APP)/apps/my_app/my_app.d
  25. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  26. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  27. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  28. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  29. # Applications in apps are compiled automatically but not added
  30. # to the application resource file unless they are listed in LOCAL_DEPS.
  31. $i "Check that the application was compiled correctly"
  32. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  33. [ok = application:load(App) || App <- [$(APP), my_app]], \
  34. {ok, Deps} = application:get_key($(APP), applications), \
  35. false = lists:member(my_app, Deps), \
  36. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  37. true = lists:member(cowlib, MyAppDeps), \
  38. {ok, []} = application:get_key($(APP), modules), \
  39. {ok, Mods = [boy, girl]} = application:get_key(my_app, modules), \
  40. [{module, M} = code:load_file(M) || M <- Mods], \
  41. halt()"
  42. $i "Clean Cowlib"
  43. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  44. $i "Check that Cowlib compiled files were removed"
  45. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  46. $i "Build the application again"
  47. $t $(MAKE) -C $(APP) $v
  48. $i "Check that Cowlib compiled files exist"
  49. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  50. $i "Clean the application"
  51. $t $(MAKE) -C $(APP) clean $v
  52. $i "Check that Cowlib is still here"
  53. $t test -d $(APP)/deps/cowlib
  54. $i "Check that all relevant files were removed"
  55. $t test ! -e $(APP)/$(APP).d
  56. $t test ! -e $(APP)/ebin/$(APP).app
  57. $t test ! -e $(APP)/apps/my_app/my_app.d
  58. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  59. $t test ! -e $(APP)/apps/my_app/ebin/boy.beam
  60. $t test ! -e $(APP)/apps/my_app/ebin/girl.beam
  61. $i "Distclean the application"
  62. $t $(MAKE) -C $(APP) distclean $v
  63. $i "Check that all relevant files were removed"
  64. $t test ! -e $(APP)/deps
  65. $i "Add my_app to the local dependencies"
  66. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app\n"}' $(APP)/Makefile
  67. ifdef LEGACY
  68. $i "Add my_app to the applications key in the .app.src file"
  69. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_app,\n"}' $(APP)/src/$(APP).app.src
  70. endif
  71. $i "Build the application"
  72. $t $(MAKE) -C $(APP) $v
  73. $i "Check that all compiled files exist"
  74. $t test -f $(APP)/$(APP).d
  75. $t test -f $(APP)/ebin/$(APP).app
  76. $t test -f $(APP)/apps/my_app/my_app.d
  77. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  78. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  79. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  80. $t test -d $(APP)/deps/cowlib
  81. $i "Check that the application was compiled correctly"
  82. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  83. [ok = application:load(App) || App <- [$(APP), my_app]], \
  84. {ok, Deps} = application:get_key($(APP), applications), \
  85. true = lists:member(my_app, Deps), \
  86. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  87. true = lists:member(cowlib, MyAppDeps), \
  88. {ok, []} = application:get_key($(APP), modules), \
  89. {ok, Mods = [boy, girl]} = application:get_key(my_app, modules), \
  90. [{module, M} = code:load_file(M) || M <- Mods], \
  91. halt()"
  92. core-apps-build-count: init
  93. $i "Bootstrap a new OTP library named $(APP)"
  94. $t mkdir $(APP)/
  95. $t cp ../erlang.mk $(APP)/
  96. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  97. $t mkdir -p "$(APP)/priv/dep"
  98. $t echo "PROJECT = fake_dep" > $(APP)/priv/dep/Makefile
  99. $t echo "include ../../erlang.mk" >> $(APP)/priv/dep/Makefile
  100. $i "Bootstrap a repository-local application my_app"
  101. $t echo "DEPS = dep1 dep2 dep3 dep4" > $(APP)/Makefile
  102. $t echo "dep_dep1 = cp ./priv/dep" >> $(APP)/Makefile
  103. $t echo "dep_dep2 = cp ./priv/dep" >> $(APP)/Makefile
  104. $t echo "dep_dep3 = cp ./priv/dep" >> $(APP)/Makefile
  105. $t echo "dep_dep4 = cp ./priv/dep" >> $(APP)/Makefile
  106. $t echo "include erlang.mk" >> $(APP)/Makefile
  107. $i "Create a new application app_one"
  108. $t $(MAKE) -C $(APP) new-app in=app_one $v
  109. $t echo "all::" >> $(APP)/apps/app_one/Makefile
  110. $t echo " @printf '#' >> count" >> $(APP)/apps/app_one/Makefile
  111. $i "Create a new application app_two"
  112. $t $(MAKE) -C $(APP) new-app in=app_two $v
  113. $t echo "all::" >> $(APP)/apps/app_two/Makefile
  114. $t echo " @printf '#' >> count" >> $(APP)/apps/app_two/Makefile
  115. $i "Build the application"
  116. $t $(MAKE) -C $(APP) $v
  117. $i "Check the number of times each app was compiled"
  118. $t test "`wc -c $(APP)/apps/app_one/count | awk '{printf $$1}'`" -eq 1
  119. $t test "`wc -c $(APP)/apps/app_two/count | awk '{printf $$1}'`" -eq 1
  120. core-apps-conflict: init
  121. $i "Bootstrap a new OTP library named $(APP)"
  122. $t mkdir $(APP)/
  123. $t cp ../erlang.mk $(APP)/
  124. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  125. $i "Add Cowlib to the list of dependencies"
  126. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  127. $i "Create a new library Cowlib"
  128. $t $(MAKE) -C $(APP) new-lib in=cowlib $v
  129. $i "Check that building the application fails because of a conflict"
  130. $t ! $(MAKE) -C $(APP) $v
  131. $i "Check that Cowlib wasn't fetched"
  132. $t test ! -e $(APP)/deps/cowlib
  133. core-apps-deep-conflict: init
  134. $i "Bootstrap a new OTP library named $(APP)"
  135. $t mkdir $(APP)/
  136. $t cp ../erlang.mk $(APP)/
  137. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  138. $i "Add Cowboy to the list of dependencies"
  139. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
  140. $i "Create a new library Cowlib"
  141. $t $(MAKE) -C $(APP) new-lib in=cowlib $v
  142. $i "Check that building the application fails because of a conflict"
  143. $t ! $(MAKE) -C $(APP) $v
  144. $i "Check that Cowlib wasn't fetched"
  145. $t test ! -e $(APP)/deps/cowlib
  146. core-apps-dir: init
  147. $i "Bootstrap a new OTP library named $(APP)"
  148. $t mkdir $(APP)/
  149. $t cp ../erlang.mk $(APP)/
  150. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  151. $i "Set a custom APPS_DIR"
  152. $t perl -ni.bak -e 'print;if ($$.==1) {print "APPS_DIR ?= \$$(CURDIR)/deep/libs\n"}' $(APP)/Makefile
  153. $i "Create a new library my_app"
  154. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  155. $i "Add Cowlib as a dependency to my_app"
  156. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/deep/libs/my_app/Makefile
  157. ifdef LEGACY
  158. $i "Add Cowlib to the applications key in the .app.src file"
  159. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/deep/libs/my_app/src/my_app.app.src
  160. endif
  161. $i "Generate .erl files in my_app"
  162. $t echo "-module(boy)." > $(APP)/deep/libs/my_app/src/boy.erl
  163. $t echo "-module(girl)." > $(APP)/deep/libs/my_app/src/girl.erl
  164. $i "Build the application"
  165. $t $(MAKE) -C $(APP) $v
  166. $i "Check that all compiled files exist"
  167. $t test -f $(APP)/$(APP).d
  168. $t test -f $(APP)/ebin/$(APP).app
  169. $t test -f $(APP)/deep/libs/my_app/my_app.d
  170. $t test -f $(APP)/deep/libs/my_app/ebin/my_app.app
  171. $t test -f $(APP)/deep/libs/my_app/ebin/boy.beam
  172. $t test -f $(APP)/deep/libs/my_app/ebin/girl.beam
  173. $t test -d $(APP)/deps/cowlib
  174. # Applications in apps are compiled automatically but not added
  175. # to the application resource file unless they are listed in LOCAL_DEPS.
  176. $i "Check that the application was compiled correctly"
  177. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deep/libs/*/ebin/ -eval " \
  178. [ok = application:load(App) || App <- [$(APP), my_app]], \
  179. {ok, Deps} = application:get_key($(APP), applications), \
  180. false = lists:member(my_app, Deps), \
  181. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  182. true = lists:member(cowlib, MyAppDeps), \
  183. {ok, []} = application:get_key($(APP), modules), \
  184. {ok, Mods = [boy, girl]} = application:get_key(my_app, modules), \
  185. [{module, M} = code:load_file(M) || M <- Mods], \
  186. halt()"
  187. $i "Clean the application"
  188. $t $(MAKE) -C $(APP) clean $v
  189. $i "Check that Cowlib is still here"
  190. $t test -d $(APP)/deps/cowlib
  191. $i "Check that all relevant files were removed"
  192. $t test ! -e $(APP)/$(APP).d
  193. $t test ! -e $(APP)/ebin/$(APP).app
  194. $t test ! -e $(APP)/libs/my_app/my_app.d
  195. $t test ! -e $(APP)/libs/my_app/ebin/my_app.app
  196. $t test ! -e $(APP)/libs/my_app/ebin/boy.beam
  197. $t test ! -e $(APP)/libs/my_app/ebin/girl.beam
  198. $i "Distclean the application"
  199. $t $(MAKE) -C $(APP) distclean $v
  200. $i "Check that all relevant files were removed"
  201. $t test ! -e $(APP)/deps
  202. core-apps-dir-include-lib: init
  203. $i "Bootstrap a new OTP library named $(APP)"
  204. $t mkdir $(APP)/
  205. $t cp ../erlang.mk $(APP)/
  206. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  207. $i "Set a custom APPS_DIR"
  208. $t perl -ni.bak -e 'print;if ($$.==1) {print "APPS_DIR ?= \$$(CURDIR)/deep/libs\n"}' $(APP)/Makefile
  209. $i "Create new libraries boy_app and girl_app"
  210. $t $(MAKE) -C $(APP) new-lib in=boy_app $v
  211. $t $(MAKE) -C $(APP) new-lib in=girl_app $v
  212. $i "Make the applications depend on each other"
  213. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = boy_app\n"}' $(APP)/deep/libs/girl_app/Makefile
  214. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = girl_app\n"}' $(APP)/deep/libs/boy_app/Makefile
  215. $i "Generate .erl and .hrl files in apps with mutual include_lib()"
  216. $t echo '-module(boy). -include_lib("girl_app/include/girl.hrl").' > $(APP)/deep/libs/boy_app/src/boy.erl
  217. $t echo '-module(girl). -include_lib("boy_app/include/boy.hrl").' > $(APP)/deep/libs/girl_app/src/girl.erl
  218. $t mkdir -p $(APP)/deep/libs/boy_app/include
  219. $t echo '%% boy' > $(APP)/deep/libs/boy_app/include/boy.hrl
  220. $t mkdir -p $(APP)/deep/libs/girl_app/include
  221. $t echo '%% girl' > $(APP)/deep/libs/girl_app/include/girl.hrl
  222. $i "Build the application"
  223. $t $(MAKE) -C $(APP) $v
  224. $i "Check that all compiled files exist"
  225. $t test -f $(APP)/$(APP).d
  226. $t test -f $(APP)/ebin/$(APP).app
  227. $t test -f $(APP)/deep/libs/boy_app/boy_app.d
  228. $t test -f $(APP)/deep/libs/boy_app/ebin/boy_app.app
  229. $t test -f $(APP)/deep/libs/boy_app/ebin/boy.beam
  230. $t test -f $(APP)/deep/libs/girl_app/girl_app.d
  231. $t test -f $(APP)/deep/libs/girl_app/ebin/girl_app.app
  232. $t test -f $(APP)/deep/libs/girl_app/ebin/girl.beam
  233. $i "Distclean the application"
  234. $t $(MAKE) -C $(APP) distclean $v
  235. $i "Build in a subdirectory"
  236. $t $(MAKE) -C $(APP)/deep/libs/boy_app $v
  237. $i "Check that all compiled files exist (excluding the top-level app)"
  238. $t ! test -f $(APP)/$(APP).d
  239. $t ! test -f $(APP)/ebin/$(APP).app
  240. $t test -f $(APP)/deep/libs/boy_app/boy_app.d
  241. $t test -f $(APP)/deep/libs/boy_app/ebin/boy_app.app
  242. $t test -f $(APP)/deep/libs/boy_app/ebin/boy.beam
  243. $t test -f $(APP)/deep/libs/girl_app/girl_app.d
  244. $t test -f $(APP)/deep/libs/girl_app/ebin/girl_app.app
  245. $t test -f $(APP)/deep/libs/girl_app/ebin/girl.beam
  246. core-apps-new-app: init
  247. $i "Bootstrap a new OTP library named $(APP)"
  248. $t mkdir $(APP)/
  249. $t cp ../erlang.mk $(APP)/
  250. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  251. $i "Create a new application my_app"
  252. $t $(MAKE) -C $(APP) new-app in=my_app $v
  253. $i "Check that all bootstrapped files exist"
  254. $t test -f $(APP)/apps/my_app/Makefile
  255. ifdef LEGACY
  256. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  257. endif
  258. $t test -f $(APP)/apps/my_app/src/my_app_app.erl
  259. $t test -f $(APP)/apps/my_app/src/my_app_sup.erl
  260. $i "Create a new module my_server in my_app"
  261. $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
  262. $i "Check that the file exists"
  263. $t test -f $(APP)/apps/my_app/src/my_server.erl
  264. $i "Build the application"
  265. $t $(MAKE) -C $(APP) $v
  266. $i "Check that all compiled files exist"
  267. $t test -f $(APP)/$(APP).d
  268. $t test -f $(APP)/ebin/$(APP).app
  269. $t test -f $(APP)/apps/my_app/my_app.d
  270. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  271. $t test -f $(APP)/apps/my_app/ebin/my_app_app.beam
  272. $t test -f $(APP)/apps/my_app/ebin/my_app_sup.beam
  273. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  274. $i "Check that the application was compiled correctly"
  275. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  276. ok = application:start(my_app), \
  277. {ok, [my_app_app, my_app_sup, my_server]} = application:get_key(my_app, modules), \
  278. {module, my_app_app} = code:load_file(my_app_app), \
  279. {module, my_app_sup} = code:load_file(my_app_sup), \
  280. {module, my_server} = code:load_file(my_server), \
  281. halt()"
  282. core-apps-new-lib: init
  283. $i "Bootstrap a new OTP library named $(APP)"
  284. $t mkdir $(APP)/
  285. $t cp ../erlang.mk $(APP)/
  286. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  287. $i "Create a new application my_app"
  288. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  289. $i "Check that all bootstrapped files exist"
  290. $t test -f $(APP)/apps/my_app/Makefile
  291. ifdef LEGACY
  292. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  293. endif
  294. $i "Create a new module my_server in my_app"
  295. $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
  296. $i "Check that the file exists"
  297. $t test -f $(APP)/apps/my_app/src/my_server.erl
  298. $i "Build the application"
  299. $t $(MAKE) -C $(APP) $v
  300. $i "Check that all compiled files exist"
  301. $t test -f $(APP)/$(APP).d
  302. $t test -f $(APP)/ebin/$(APP).app
  303. $t test -f $(APP)/apps/my_app/my_app.d
  304. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  305. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  306. $i "Check that the application was compiled correctly"
  307. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  308. ok = application:start(my_app), \
  309. {ok, [my_server]} = application:get_key(my_app, modules), \
  310. {module, my_server} = code:load_file(my_server), \
  311. halt()"
  312. core-apps-new-tpl: init
  313. $i "Bootstrap a new OTP library named $(APP)"
  314. $t mkdir $(APP)/
  315. $t cp ../erlang.mk $(APP)/
  316. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  317. $i "Create a new library my_app"
  318. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  319. $i "Generate one of each template"
  320. $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=gen_fsm n=my_fsm
  321. $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=gen_server n=my_server
  322. $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=supervisor n=my_sup
  323. # Here we disable warnings because templates contain missing behaviors.
  324. $i "Build the application"
  325. $t $(MAKE) -C $(APP)/apps/my_app ERLC_OPTS=+debug_info $v
  326. $i "Check that all compiled files exist"
  327. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  328. $t test -f $(APP)/apps/my_app/ebin/my_fsm.beam
  329. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  330. $t test -f $(APP)/apps/my_app/ebin/my_sup.beam
  331. $i "Check that all the modules can be loaded"
  332. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  333. ok = application:start(my_app), \
  334. {ok, Mods = [my_fsm, my_server, my_sup]} = application:get_key(my_app, modules), \
  335. [{module, M} = code:load_file(M) || M <- Mods], \
  336. halt()"
  337. core-apps-local-deps: init
  338. $i "Bootstrap a new OTP library named $(APP)"
  339. $t mkdir $(APP)/
  340. $t cp ../erlang.mk $(APP)/
  341. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  342. $i "Create a new application my_app_1"
  343. $t $(MAKE) -C $(APP) new-app in=my_app_1 $v
  344. $i "Add Lager to the list of dependencies of my_app_1, and add the lager parse_transform"
  345. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nERLC_OPTS+=+{parse_transform,lager_transform}\n"}' $(APP)/apps/my_app_1/Makefile
  346. $i "Add a lager:error/2 call to my_app_1_app.erl that will fail if the parse_transform doesn't run"
  347. $t perl -ni.bak -e 'print;if (/^-export/){print "\n-export([log/0]).\n"} if (eof) {print "\nlog() -> lager:error(\"test\", []).\n"}' $(APP)/apps/my_app_1/src/my_app_1_app.erl
  348. $i "Create a new application my_app_2"
  349. $t $(MAKE) -C $(APP) new-app in=my_app_2 $v
  350. $i "Add my_app_1 to the list of local dependencies of my_app_2, don't add lager, but add the lager parse_transform (this will fail unless my_app_1 was indeed built first)"
  351. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_1\nERLC_OPTS+=+{parse_transform,lager_transform}\n"}' $(APP)/apps/my_app_2/Makefile
  352. $i "Add a lager:error/2 call to my_app_2_app.erl that will fail if the parse_transform doesn't run"
  353. $t perl -ni.bak -e 'print;if (/^-export/){print "\n-export([log/0]).\n"} if (eof) {print "\nlog() -> lager:error(\"test\", []).\n"}' $(APP)/apps/my_app_2/src/my_app_2_app.erl
  354. $i "Build the application"
  355. $t $(MAKE) -C $(APP) $v
  356. $i "Check that all compiled files exist"
  357. $t test -f $(APP)/$(APP).d
  358. $t test -f $(APP)/ebin/$(APP).app
  359. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  360. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  361. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  362. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  363. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  364. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  365. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  366. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  367. $t test -f $(APP)/deps/lager/ebin/lager.app
  368. $i "Distclean the application"
  369. $t $(MAKE) -C $(APP) distclean $v
  370. $i "Test after swapping my_app_1 and my_app_2 to make sure lexical ordering didnt incidentally build the correct app first"
  371. $i "Add my_app_2 to the list of local dependencies of my_app_1, don't add lager, but add the lager parse_transform (this will fail unless my_app_2 was indeed built first)"
  372. $t mv $(APP)/apps/my_app_1/Makefile.bak $(APP)/apps/my_app_1/Makefile
  373. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_2\nERLC_OPTS+=+{parse_transform,lager_transform}\n"}' $(APP)/apps/my_app_1/Makefile
  374. $i "Add Lager to the list of dependencies of my_app_2, and add the lager parse_transform"
  375. $t mv $(APP)/apps/my_app_2/Makefile.bak $(APP)/apps/my_app_2/Makefile
  376. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nERLC_OPTS+=+{parse_transform,lager_transform}\n"}' $(APP)/apps/my_app_2/Makefile
  377. $i "Build the application"
  378. $t $(MAKE) -C $(APP) $v
  379. $i "Check that all compiled files exist"
  380. $t test -f $(APP)/$(APP).d
  381. $t test -f $(APP)/ebin/$(APP).app
  382. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  383. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  384. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  385. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  386. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  387. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  388. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  389. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  390. $t test -f $(APP)/deps/lager/ebin/lager.app
  391. core-apps-local-deps-circular: init
  392. $i "Bootstrap a new OTP library named $(APP)"
  393. $t mkdir $(APP)/
  394. $t cp ../erlang.mk $(APP)/
  395. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  396. $i "Create a new application my_app_1"
  397. $t $(MAKE) -C $(APP) new-app in=my_app_1 $v
  398. $i "Create a new application my_app_2"
  399. $t $(MAKE) -C $(APP) new-app in=my_app_2 $v
  400. $i "Add my_app_1 to the list of local dependencies of my_app_2"
  401. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_1\n"}' $(APP)/apps/my_app_2/Makefile
  402. $i "Add my_app_2 to the list of local dependencies of my_app_1"
  403. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_2\n"}' $(APP)/apps/my_app_1/Makefile
  404. $i "Build the application"
  405. $t $(MAKE) -C $(APP) $v
  406. $i "Check that all compiled files exist"
  407. $t test -f $(APP)/$(APP).d
  408. $t test -f $(APP)/ebin/$(APP).app
  409. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  410. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  411. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  412. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  413. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  414. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  415. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  416. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  417. core-apps-only: init
  418. $i "Create a multi application repository with no root application"
  419. $t mkdir $(APP)/
  420. $t cp ../erlang.mk $(APP)/
  421. $t echo "include erlang.mk" > $(APP)/Makefile
  422. $i "Create a new application my_app"
  423. $t $(MAKE) -C $(APP) new-app in=my_app $v
  424. $i "Create a module my_server from gen_server template in my_app"
  425. $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
  426. $i "Add Cowlib to the list of dependencies"
  427. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib_commit = master\n"}' $(APP)/apps/my_app/Makefile
  428. $i "Build the application"
  429. $t $(MAKE) -C $(APP) $v
  430. $i "Check that all compiled files exist"
  431. $t test -f $(APP)/apps/my_app/my_app.d
  432. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  433. $t test -f $(APP)/apps/my_app/ebin/my_app_app.beam
  434. $t test -f $(APP)/apps/my_app/ebin/my_app_sup.beam
  435. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  436. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  437. $i "Check that the application was compiled correctly"
  438. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  439. ok = application:load(my_app), \
  440. {ok, Mods = [my_app_app, my_app_sup, my_server]} = application:get_key(my_app, modules), \
  441. [{module, M} = code:load_file(M) || M <- Mods], \
  442. halt()"
  443. $i "Clean Cowlib"
  444. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  445. $i "Check that Cowlib compiled files were removed"
  446. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  447. $i "Build the application again"
  448. $t $(MAKE) -C $(APP) $v
  449. $i "Check that Cowlib compiled files exist"
  450. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  451. $i "Clean the application"
  452. $t $(MAKE) -C $(APP) clean $v
  453. $i "Check that Cowlib is still here"
  454. $t test -d $(APP)/deps/cowlib
  455. $i "Check that all relevant files were removed"
  456. $t test ! -e $(APP)/apps/my_app/my_app.d
  457. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  458. $t test ! -e $(APP)/apps/my_app/ebin/my_app_app.beam
  459. $t test ! -e $(APP)/apps/my_app/ebin/my_app_sup.beam
  460. $t test ! -e $(APP)/apps/my_app/ebin/my_server.beam
  461. $i "Distclean the application"
  462. $t $(MAKE) -C $(APP) distclean $v
  463. $i "Check that all relevant files were removed"
  464. $t test ! -e $(APP)/deps
  465. core-apps-toplevel-local-deps: init
  466. $i "Bootstrap a new OTP library named $(APP)"
  467. $t mkdir $(APP)/
  468. $t cp ../erlang.mk $(APP)/
  469. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  470. $i "Create a new application my_app_1"
  471. $t $(MAKE) -C $(APP) new-app in=my_app_1 $v
  472. $i "Add my_app_1 to the list of toplevel local dependencies"
  473. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_1\n"}' $(APP)/Makefile
  474. $i "Create a new application my_app_2"
  475. $t $(MAKE) -C $(APP) new-app in=my_app_2 $v
  476. $i "Build the application"
  477. $t $(MAKE) -C $(APP) $v
  478. $i "Check that all compiled files exist"
  479. $t test -f $(APP)/$(APP).d
  480. $t test -f $(APP)/ebin/$(APP).app
  481. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  482. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  483. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  484. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  485. $i "Check that my_app_2 compiled files DO NOT exist"
  486. $t test ! -e $(APP)/apps/my_app_2/my_app_2.d
  487. $t test ! -e $(APP)/apps/my_app_2/ebin/my_app_2.app
  488. $t test ! -e $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  489. $t test ! -e $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  490. $i "Add my_app_2 to the list of local dependencies of my_app_1"
  491. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_2\n"}' $(APP)/apps/my_app_1/Makefile
  492. $i "Rebuild the application"
  493. $t $(MAKE) -C $(APP) $v
  494. $i "Check that my_app_2 compiled files exist"
  495. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  496. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  497. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  498. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam