core_apps.mk 23 KB

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