core_deps.mk 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750
  1. # Core: Packages and dependencies.
  2. CORE_DEPS_TARGETS = $(call list_targets,core-deps)
  3. .PHONY: core-deps $(CORE_DEPS_TARGETS)
  4. core-deps: $(CORE_DEPS_TARGETS)
  5. core-deps-apps: 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-deps-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-deps-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-deps-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-deps-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-deps-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 "Generate .erl and .hrl files in apps with mutual include_lib()"
  212. $t echo '-module(boy). -include_lib("girl_app/include/girl.hrl").' > $(APP)/deep/libs/boy_app/src/boy.erl
  213. $t echo '-module(girl). -include_lib("boy_app/include/boy.hrl").' > $(APP)/deep/libs/girl_app/src/girl.erl
  214. $t mkdir -p $(APP)/deep/libs/boy_app/include
  215. $t echo '%% boy' > $(APP)/deep/libs/boy_app/include/boy.hrl
  216. $t mkdir -p $(APP)/deep/libs/girl_app/include
  217. $t echo '%% girl' > $(APP)/deep/libs/girl_app/include/girl.hrl
  218. $i "Build the application"
  219. $t $(MAKE) -C $(APP) $v
  220. $i "Check that all compiled files exist"
  221. $t test -f $(APP)/$(APP).d
  222. $t test -f $(APP)/ebin/$(APP).app
  223. $t test -f $(APP)/deep/libs/boy_app/boy_app.d
  224. $t test -f $(APP)/deep/libs/boy_app/ebin/boy_app.app
  225. $t test -f $(APP)/deep/libs/boy_app/ebin/boy.beam
  226. $t test -f $(APP)/deep/libs/girl_app/girl_app.d
  227. $t test -f $(APP)/deep/libs/girl_app/ebin/girl_app.app
  228. $t test -f $(APP)/deep/libs/girl_app/ebin/girl.beam
  229. $i "Distclean the application"
  230. $t $(MAKE) -C $(APP) distclean $v
  231. core-deps-apps-new-app: build clean
  232. $i "Bootstrap a new OTP library named $(APP)"
  233. $t mkdir $(APP)/
  234. $t cp ../erlang.mk $(APP)/
  235. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  236. $i "Create a new application my_app"
  237. $t $(MAKE) -C $(APP) new-app in=my_app $v
  238. $i "Check that all bootstrapped files exist"
  239. $t test -f $(APP)/apps/my_app/Makefile
  240. ifdef LEGACY
  241. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  242. endif
  243. $t test -f $(APP)/apps/my_app/src/my_app_app.erl
  244. $t test -f $(APP)/apps/my_app/src/my_app_sup.erl
  245. $i "Create a new module my_server in my_app"
  246. $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
  247. $i "Check that the file exists"
  248. $t test -f $(APP)/apps/my_app/src/my_server.erl
  249. $i "Build the application"
  250. $t $(MAKE) -C $(APP) $v
  251. $i "Check that all compiled files exist"
  252. $t test -f $(APP)/$(APP).d
  253. $t test -f $(APP)/ebin/$(APP).app
  254. $t test -f $(APP)/apps/my_app/my_app.d
  255. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  256. $t test -f $(APP)/apps/my_app/ebin/my_app_app.beam
  257. $t test -f $(APP)/apps/my_app/ebin/my_app_sup.beam
  258. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  259. $i "Check that the application was compiled correctly"
  260. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  261. ok = application:start(my_app), \
  262. {ok, [my_app_app, my_app_sup, my_server]} = application:get_key(my_app, modules), \
  263. {module, my_app_app} = code:load_file(my_app_app), \
  264. {module, my_app_sup} = code:load_file(my_app_sup), \
  265. {module, my_server} = code:load_file(my_server), \
  266. halt()"
  267. core-deps-apps-new-lib: build clean
  268. $i "Bootstrap a new OTP library named $(APP)"
  269. $t mkdir $(APP)/
  270. $t cp ../erlang.mk $(APP)/
  271. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  272. $i "Create a new application my_app"
  273. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  274. $i "Check that all bootstrapped files exist"
  275. $t test -f $(APP)/apps/my_app/Makefile
  276. ifdef LEGACY
  277. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  278. endif
  279. $i "Create a new module my_server in my_app"
  280. $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
  281. $i "Check that the file exists"
  282. $t test -f $(APP)/apps/my_app/src/my_server.erl
  283. $i "Build the application"
  284. $t $(MAKE) -C $(APP) $v
  285. $i "Check that all compiled files exist"
  286. $t test -f $(APP)/$(APP).d
  287. $t test -f $(APP)/ebin/$(APP).app
  288. $t test -f $(APP)/apps/my_app/my_app.d
  289. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  290. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  291. $i "Check that the application was compiled correctly"
  292. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  293. ok = application:start(my_app), \
  294. {ok, [my_server]} = application:get_key(my_app, modules), \
  295. {module, my_server} = code:load_file(my_server), \
  296. halt()"
  297. core-deps-apps-new-tpl: build clean
  298. $i "Bootstrap a new OTP library named $(APP)"
  299. $t mkdir $(APP)/
  300. $t cp ../erlang.mk $(APP)/
  301. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  302. $i "Create a new library my_app"
  303. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  304. $i "Generate one of each template"
  305. $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=gen_fsm n=my_fsm
  306. $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=gen_server n=my_server
  307. $t $(MAKE) -C $(APP) --no-print-directory new in=my_app t=supervisor n=my_sup
  308. # Here we disable warnings because templates contain missing behaviors.
  309. $i "Build the application"
  310. $t $(MAKE) -C $(APP)/apps/my_app ERLC_OPTS=+debug_info $v
  311. $i "Check that all compiled files exist"
  312. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  313. $t test -f $(APP)/apps/my_app/ebin/my_fsm.beam
  314. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  315. $t test -f $(APP)/apps/my_app/ebin/my_sup.beam
  316. $i "Check that all the modules can be loaded"
  317. $t $(ERL) -pa $(APP)/ebin/ $(APP)/apps/*/ebin/ -eval " \
  318. ok = application:start(my_app), \
  319. {ok, Mods = [my_fsm, my_server, my_sup]} = application:get_key(my_app, modules), \
  320. [{module, M} = code:load_file(M) || M <- Mods], \
  321. halt()"
  322. core-deps-apps-only: build clean
  323. $i "Create a multi application repository with no root application"
  324. $t mkdir $(APP)/
  325. $t cp ../erlang.mk $(APP)/
  326. $t echo "include erlang.mk" > $(APP)/Makefile
  327. $i "Create a new application my_app"
  328. $t $(MAKE) -C $(APP) new-app in=my_app $v
  329. $i "Create a module my_server from gen_server template in my_app"
  330. $t $(MAKE) -C $(APP) new t=gen_server n=my_server in=my_app $v
  331. $i "Add Cowlib to the list of dependencies"
  332. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/apps/my_app/Makefile
  333. $i "Build the application"
  334. $t $(MAKE) -C $(APP) $v
  335. $i "Check that all compiled files exist"
  336. $t test -f $(APP)/apps/my_app/my_app.d
  337. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  338. $t test -f $(APP)/apps/my_app/ebin/my_app_app.beam
  339. $t test -f $(APP)/apps/my_app/ebin/my_app_sup.beam
  340. $t test -f $(APP)/apps/my_app/ebin/my_server.beam
  341. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  342. $i "Check that the application was compiled correctly"
  343. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  344. ok = application:load(my_app), \
  345. {ok, Mods = [my_app_app, my_app_sup, my_server]} = application:get_key(my_app, modules), \
  346. [{module, M} = code:load_file(M) || M <- Mods], \
  347. halt()"
  348. $i "Clean Cowlib"
  349. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  350. $i "Check that Cowlib compiled files were removed"
  351. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  352. $i "Build the application again"
  353. $t $(MAKE) -C $(APP) $v
  354. $i "Check that Cowlib compiled files exist"
  355. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  356. $i "Clean the application"
  357. $t $(MAKE) -C $(APP) clean $v
  358. $i "Check that Cowlib is still here"
  359. $t test -d $(APP)/deps/cowlib
  360. $i "Check that all relevant files were removed"
  361. $t test ! -e $(APP)/apps/my_app/my_app.d
  362. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  363. $t test ! -e $(APP)/apps/my_app/ebin/my_app_app.beam
  364. $t test ! -e $(APP)/apps/my_app/ebin/my_app_sup.beam
  365. $t test ! -e $(APP)/apps/my_app/ebin/my_server.beam
  366. $i "Distclean the application"
  367. $t $(MAKE) -C $(APP) distclean $v
  368. $i "Check that all relevant files were removed"
  369. $t test ! -e $(APP)/deps
  370. core-deps-apps-local-deps: build clean
  371. $i "Bootstrap a new OTP library named $(APP)"
  372. $t mkdir $(APP)/
  373. $t cp ../erlang.mk $(APP)/
  374. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  375. $i "Create a new application my_app_1"
  376. $t $(MAKE) -C $(APP) new-app in=my_app_1 $v
  377. $i "Add Lager to the list of dependencies of my_app_1, and add the lager parse_transform"
  378. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nERLC_OPTS+=+{parse_transform,lager_transform}\n"}' $(APP)/apps/my_app_1/Makefile
  379. $i "Add a lager:error/2 call to my_app_1_app.erl that will fail if the parse_transform doesn't run"
  380. $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
  381. $i "Create a new application my_app_2"
  382. $t $(MAKE) -C $(APP) new-app in=my_app_2 $v
  383. $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)"
  384. $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
  385. $i "Add a lager:error/2 call to my_app_2_app.erl that will fail if the parse_transform doesn't run"
  386. $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
  387. $i "Build the application"
  388. $t $(MAKE) -C $(APP) $v
  389. $i "Check that all compiled files exist"
  390. $t test -f $(APP)/$(APP).d
  391. $t test -f $(APP)/ebin/$(APP).app
  392. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  393. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  394. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  395. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  396. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  397. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  398. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  399. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  400. $t test -f $(APP)/deps/lager/ebin/lager.app
  401. $i "Distclean the application"
  402. $t $(MAKE) -C $(APP) distclean $v
  403. $i "Test after swapping my_app_1 and my_app_2 to make sure lexical ordering didnt incidentally build the correct app first"
  404. $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)"
  405. $t mv $(APP)/apps/my_app_1/Makefile{.bak,}
  406. $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
  407. $i "Add Lager to the list of dependencies of my_app_2, and add the lager parse_transform"
  408. $t mv $(APP)/apps/my_app_2/Makefile{.bak,}
  409. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nERLC_OPTS+=+{parse_transform,lager_transform}\n"}' $(APP)/apps/my_app_2/Makefile
  410. $i "Build the application"
  411. $t $(MAKE) -C $(APP) $v
  412. $i "Check that all compiled files exist"
  413. $t test -f $(APP)/$(APP).d
  414. $t test -f $(APP)/ebin/$(APP).app
  415. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  416. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  417. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  418. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  419. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  420. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  421. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  422. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  423. $t test -f $(APP)/deps/lager/ebin/lager.app
  424. core-deps-apps-local-deps-circular: build clean
  425. $i "Bootstrap a new OTP library named $(APP)"
  426. $t mkdir $(APP)/
  427. $t cp ../erlang.mk $(APP)/
  428. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  429. $i "Create a new application my_app_1"
  430. $t $(MAKE) -C $(APP) new-app in=my_app_1 $v
  431. $i "Create a new application my_app_2"
  432. $t $(MAKE) -C $(APP) new-app in=my_app_2 $v
  433. $i "Add my_app_1 to the list of local dependencies of my_app_2"
  434. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_1\n"}' $(APP)/apps/my_app_2/Makefile
  435. $i "Add my_app_2 to the list of local dependencies of my_app_1"
  436. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_2\n"}' $(APP)/apps/my_app_1/Makefile
  437. $i "Build the application"
  438. $t $(MAKE) -C $(APP) $v
  439. $i "Check that all compiled files exist"
  440. $t test -f $(APP)/$(APP).d
  441. $t test -f $(APP)/ebin/$(APP).app
  442. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  443. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  444. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  445. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  446. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  447. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  448. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  449. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  450. core-deps-apps-toplevel-local-deps: build clean
  451. $i "Bootstrap a new OTP library named $(APP)"
  452. $t mkdir $(APP)/
  453. $t cp ../erlang.mk $(APP)/
  454. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  455. $i "Create a new application my_app_1"
  456. $t $(MAKE) -C $(APP) new-app in=my_app_1 $v
  457. $i "Add my_app_1 to the list of toplevel local dependencies"
  458. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_1\n"}' $(APP)/Makefile
  459. $i "Create a new application my_app_2"
  460. $t $(MAKE) -C $(APP) new-app in=my_app_2 $v
  461. $i "Build the application"
  462. $t $(MAKE) -C $(APP) $v
  463. $i "Check that all compiled files exist"
  464. $t test -f $(APP)/$(APP).d
  465. $t test -f $(APP)/ebin/$(APP).app
  466. $t test -f $(APP)/apps/my_app_1/my_app_1.d
  467. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1.app
  468. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_app.beam
  469. $t test -f $(APP)/apps/my_app_1/ebin/my_app_1_sup.beam
  470. $i "Check that my_app_2 compiled files DO NOT exist"
  471. $t test ! -e $(APP)/apps/my_app_2/my_app_2.d
  472. $t test ! -e $(APP)/apps/my_app_2/ebin/my_app_2.app
  473. $t test ! -e $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  474. $t test ! -e $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  475. $i "Add my_app_2 to the list of local dependencies of my_app_1"
  476. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = my_app_2\n"}' $(APP)/apps/my_app_1/Makefile
  477. $i "Rebuild the application"
  478. $t $(MAKE) -C $(APP) $v
  479. $i "Check that my_app_2 compiled files exist"
  480. $t test -f $(APP)/apps/my_app_2/my_app_2.d
  481. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2.app
  482. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_app.beam
  483. $t test -f $(APP)/apps/my_app_2/ebin/my_app_2_sup.beam
  484. core-deps-autopatch-rebar: build clean
  485. $i "Bootstrap a new OTP library named $(APP)"
  486. $t mkdir $(APP)/
  487. $t cp ../erlang.mk $(APP)/
  488. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  489. $i "Add erlsha2 to the list of dependencies"
  490. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlsha2\n"}' $(APP)/Makefile
  491. $i "Build the application"
  492. $t $(MAKE) -C $(APP) $v
  493. $i "Check that erlsha2 was fetched and built"
  494. $t test -d $(APP)/deps/erlsha2
  495. $t test -f $(APP)/deps/erlsha2/ebin/erlsha2.beam
  496. ifneq ($(PLATFORM),msys2)
  497. $t test -f $(APP)/deps/erlsha2/priv/erlsha2_nif.so
  498. endif
  499. ifneq ($(PLATFORM),msys2)
  500. core-deps-build-c-8cc: build clean
  501. $i "Bootstrap a new OTP library named $(APP)"
  502. $t mkdir $(APP)/
  503. $t cp ../erlang.mk $(APP)/
  504. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  505. $i "Add 8cc to the list of build dependencies"
  506. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = 8cc\ndep_8cc = git https://github.com/rui314/8cc master\n"}' $(APP)/Makefile
  507. $i "Build the application"
  508. $t $(MAKE) -C $(APP) $v
  509. $i "Check that all dependencies were fetched"
  510. $t test -d $(APP)/deps/8cc
  511. $i "Check that 8cc can be started"
  512. $t $(APP)/deps/8cc/8cc -h $v
  513. $i "Check that the application was compiled correctly"
  514. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  515. [ok = application:load(App) || App <- [$(APP)]], \
  516. {ok, Deps} = application:get_key($(APP), applications), \
  517. false = lists:member('8cc', Deps), \
  518. halt()"
  519. endif
  520. core-deps-build-c-lz4: build clean
  521. $i "Bootstrap a new OTP library named $(APP)"
  522. $t mkdir $(APP)/
  523. $t cp ../erlang.mk $(APP)/
  524. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  525. $i "Add lz4 to the list of build dependencies"
  526. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = lz4_src\ndep_lz4_src = git https://github.com/lz4/lz4 v1.8.2\n"}' $(APP)/Makefile
  527. $i "Build the application"
  528. $t $(MAKE) -C $(APP) $v
  529. $i "Check that all dependencies were fetched"
  530. $t test -d $(APP)/deps/lz4_src
  531. $i "Check that lz4 was compiled"
  532. $t test -f $(APP)/deps/lz4_src/lib/liblz4.a
  533. $i "Check that the application was compiled correctly"
  534. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  535. [ok = application:load(App) || App <- [$(APP)]], \
  536. {ok, Deps} = application:get_key($(APP), applications), \
  537. false = lists:member(lz4, Deps), \
  538. halt()"
  539. core-deps-build-erl: build clean
  540. $i "Bootstrap a new OTP library named $(APP)"
  541. $t mkdir $(APP)/
  542. $t cp ../erlang.mk $(APP)/
  543. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  544. $i "Add cowlib to the list of build dependencies"
  545. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = cowlib\n"}' $(APP)/Makefile
  546. $i "Build the application"
  547. $t $(MAKE) -C $(APP) $v
  548. $i "Check that all dependencies were fetched"
  549. $t test -d $(APP)/deps/cowlib
  550. $i "Check that the application was compiled correctly"
  551. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  552. [ok = application:load(App) || App <- [$(APP), cowlib]], \
  553. {ok, Deps} = application:get_key($(APP), applications), \
  554. false = lists:member(cowlib, Deps), \
  555. halt()"
  556. core-deps-build-js: build clean
  557. $i "Bootstrap a new OTP library named $(APP)"
  558. $t mkdir $(APP)/
  559. $t cp ../erlang.mk $(APP)/
  560. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  561. $i "Add jquery to the list of build dependencies"
  562. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = jquery\ndep_jquery = git https://github.com/jquery/jquery master\n"}' $(APP)/Makefile
  563. $i "Build the application"
  564. $t $(MAKE) -C $(APP) $v
  565. $i "Check that all dependencies were fetched"
  566. $t test -d $(APP)/deps/jquery
  567. $i "Check that the application was compiled correctly"
  568. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  569. [ok = application:load(App) || App <- [$(APP)]], \
  570. {ok, Deps} = application:get_key($(APP), applications), \
  571. false = lists:member(jquery, Deps), \
  572. halt()"
  573. core-deps-dep-commit: build clean
  574. $i "Bootstrap a new OTP library named $(APP)"
  575. $t mkdir $(APP)/
  576. $t cp ../erlang.mk $(APP)/
  577. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  578. $i "Add Cowboy 1.0.0 to the list of dependencies"
  579. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy_commit = 1.0.0\n"}' $(APP)/Makefile
  580. ifdef LEGACY
  581. $i "Add Cowboy to the applications key in the .app.src file"
  582. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  583. endif
  584. $i "Build the application"
  585. $t $(MAKE) -C $(APP) $v
  586. $i "Check that all dependencies were fetched"
  587. $t test -d $(APP)/deps/cowboy
  588. $t test -d $(APP)/deps/cowlib
  589. $t test -d $(APP)/deps/ranch
  590. $i "Check that the application was compiled correctly"
  591. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  592. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  593. {ok, Deps} = application:get_key($(APP), applications), \
  594. true = lists:member(cowboy, Deps), \
  595. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  596. halt()"
  597. core-deps-dir: build clean
  598. $i "Bootstrap a new OTP library named $(APP)"
  599. $t mkdir $(APP)/
  600. $t cp ../erlang.mk $(APP)/
  601. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  602. $i "Add Cowboy to the list of dependencies with a custom DEPS_DIR"
  603. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nDEPS_DIR ?= \$$(CURDIR)/deep/libs\n"}' $(APP)/Makefile
  604. ifdef LEGACY
  605. $i "Add Cowboy to the applications key in the .app.src file"
  606. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  607. endif
  608. $i "Build the application"
  609. $t $(MAKE) -C $(APP) $v
  610. $i "Check that all dependencies were fetched in the custom DEPS_DIR"
  611. $t test -d $(APP)/deep/libs/cowboy
  612. $t test -d $(APP)/deep/libs/cowlib
  613. $t test -d $(APP)/deep/libs/ranch
  614. $i "Check that the application was compiled correctly"
  615. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deep/libs/*/ebin/ -eval " \
  616. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  617. {ok, Deps} = application:get_key($(APP), applications), \
  618. true = lists:member(cowboy, Deps), \
  619. halt()"
  620. core-deps-doc: build clean
  621. $i "Bootstrap a new OTP library named $(APP)"
  622. $t mkdir $(APP)/
  623. $t cp ../erlang.mk $(APP)/
  624. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  625. $i "Generate .erl files"
  626. $t echo "-module(boy)." > $(APP)/src/boy.erl
  627. $t echo "-module(girl)." > $(APP)/src/girl.erl
  628. $i "Add Edown as a documentation building dependency"
  629. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = edown\nEDOC_OPTS = {doclet, edown_doclet}\n"}' $(APP)/Makefile
  630. $i "Build the application"
  631. $t $(MAKE) -C $(APP) $v
  632. $i "Check that no dependencies were fetched"
  633. $t test ! -e $(APP)/deps
  634. $i "Check that the application was compiled correctly"
  635. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  636. [ok = application:load(App) || App <- [$(APP)]], \
  637. {ok, Deps} = application:get_key($(APP), applications), \
  638. false = lists:member(edown, Deps), \
  639. halt()"
  640. $i "Build the application documentation"
  641. $t $(MAKE) -C $(APP) edoc $v
  642. $i "Check that documentation dependencies were fetched"
  643. $t test -d $(APP)/deps/edown
  644. $i "Check the Edown generated Markdown documentation"
  645. $t test -f $(APP)/doc/boy.md
  646. $t test -f $(APP)/doc/girl.md
  647. core-deps-fetch-cp: build clean
  648. $i "Bootstrap a new OTP library named $(APP)"
  649. $t mkdir $(APP)/
  650. $t cp ../erlang.mk $(APP)/
  651. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  652. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  653. $t mkdir $(APP)/my_dep
  654. $t cp ../erlang.mk $(APP)/my_dep/
  655. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  656. $i "Add my_dep to the list of dependencies"
  657. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  658. ifdef LEGACY
  659. $i "Add my_dep to the applications key in the .app.src file"
  660. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  661. endif
  662. $i "Build the application"
  663. $t $(MAKE) -C $(APP) $v
  664. $i "Check that all dependencies were fetched"
  665. $t test -d $(APP)/deps/my_dep
  666. $i "Check that the application was compiled correctly"
  667. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  668. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  669. {ok, Deps} = application:get_key($(APP), applications), \
  670. true = lists:member(my_dep, Deps), \
  671. halt()"
  672. core-deps-fetch-custom: build clean
  673. $i "Bootstrap a new OTP library named $(APP)"
  674. $t mkdir $(APP)/
  675. $t cp ../erlang.mk $(APP)/
  676. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  677. $i "Add dependency boop using custom fetch method beep to the list of dependencies"
  678. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = boop\ndep_boop = beep boop\ndep_fetch_beep = mkdir -p \$$(DEPS_DIR)/\$$1/ebin/\n"}' $(APP)/Makefile
  679. ifdef LEGACY
  680. $i "Add boop to the applications key in the .app.src file"
  681. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tboop,\n"}' $(APP)/src/$(APP).app.src
  682. endif
  683. $i "Build the application"
  684. $t $(MAKE) -C $(APP) $v
  685. $i "Check that all dependencies were fetched"
  686. $t test -d $(APP)/deps/boop
  687. $i "Check that the application was compiled correctly"
  688. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  689. ok = application:load($(APP)), \
  690. {ok, Deps} = application:get_key($(APP), applications), \
  691. true = lists:member(boop, Deps), \
  692. halt()"
  693. core-deps-fetch-fail-bad: build clean
  694. $i "Bootstrap a new OTP library named $(APP)"
  695. $t mkdir $(APP)/
  696. $t cp ../erlang.mk $(APP)/
  697. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  698. $i "Add Cowlib as a dependency using a non-existing fetch method named oops"
  699. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib = oops https://github.com/ninenines/cowlib 1.0.0\n"}' $(APP)/Makefile
  700. $i "Check that building the application fails"
  701. $t ! $(MAKE) -C $(APP) $v
  702. core-deps-fetch-fail-unknown: build clean
  703. $i "Bootstrap a new OTP library named $(APP)"
  704. $t mkdir $(APP)/
  705. $t cp ../erlang.mk $(APP)/
  706. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  707. $i "Add an unknown application as a dependency"
  708. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = unknown\n"}' $(APP)/Makefile
  709. $i "Check that building the application fails"
  710. $t ! $(MAKE) -C $(APP) $v
  711. core-deps-fetch-git: build clean
  712. $i "Bootstrap a new OTP library named $(APP)"
  713. $t mkdir $(APP)/
  714. $t cp ../erlang.mk $(APP)/
  715. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  716. $i "Add Cowboy 1.0.0 to the list of dependencies"
  717. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = git https://github.com/ninenines/cowboy 1.0.0\n"}' $(APP)/Makefile
  718. ifdef LEGACY
  719. $i "Add Cowboy to the applications key in the .app.src file"
  720. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  721. endif
  722. $i "Build the application"
  723. $t $(MAKE) -C $(APP) $v
  724. $i "Check that all dependencies were fetched"
  725. $t test -d $(APP)/deps/cowboy
  726. $t test -d $(APP)/deps/cowlib
  727. $t test -d $(APP)/deps/ranch
  728. $i "Check that the application was compiled correctly"
  729. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  730. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  731. {ok, Deps} = application:get_key($(APP), applications), \
  732. true = lists:member(cowboy, Deps), \
  733. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  734. halt()"
  735. core-deps-fetch-git-submodule: build clean
  736. $i "Bootstrap a new OTP library named $(APP)"
  737. $t mkdir $(APP)/
  738. $t cp ../erlang.mk $(APP)/
  739. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  740. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  741. $t mkdir $(APP)/my_dep
  742. $t cp ../erlang.mk $(APP)/my_dep/
  743. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  744. # Create an empty file so src/ gets committed.
  745. $t touch $(APP)/my_dep/src/README
  746. $t cd $(APP)/my_dep && \
  747. git init -q && \
  748. git config user.email "testsuite@erlang.mk" && \
  749. git config user.name "test suite" && \
  750. git add . && \
  751. git commit -q --no-gpg-sign -m "Tests"
  752. $i "Add the submodule to my_dep"
  753. $t mkdir $(APP)/deps
  754. $t cd $(APP) && \
  755. git init -q && \
  756. git submodule -q add file://$(abspath $(APP)/my_dep) deps/my_dep && \
  757. git config user.email "testsuite@erlang.mk" && \
  758. git config user.name "test suite" && \
  759. git add . && \
  760. git commit -q --no-gpg-sign -m "Tests"
  761. $i "Distclean the application"
  762. $t $(MAKE) -C $(APP) distclean $v
  763. $i "Add my_dep to the list of dependencies"
  764. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = git-submodule\n"}' $(APP)/Makefile
  765. ifdef LEGACY
  766. $i "Add my_dep to the applications key in the .app.src file"
  767. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  768. endif
  769. $i "Build the application"
  770. $t $(MAKE) -C $(APP) $v
  771. $i "Check that all dependencies were fetched"
  772. $t test -d $(APP)/deps/my_dep
  773. $i "Check that the application was compiled correctly"
  774. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  775. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  776. {ok, Deps} = application:get_key($(APP), applications), \
  777. true = lists:member(my_dep, Deps), \
  778. halt()"
  779. core-deps-fetch-hex: build clean
  780. $i "Bootstrap a new OTP library named $(APP)"
  781. $t mkdir $(APP)/
  782. $t cp ../erlang.mk $(APP)/
  783. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  784. $i "Add Cowboy 1.0.0 to the list of dependencies"
  785. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = hex 1.0.0\n"}' $(APP)/Makefile
  786. ifdef LEGACY
  787. $i "Add Cowboy to the applications key in the .app.src file"
  788. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  789. endif
  790. $i "Build the application"
  791. $t $(MAKE) -C $(APP) $v
  792. $i "Check that all dependencies were fetched"
  793. $t test -d $(APP)/deps/cowboy
  794. $t test -d $(APP)/deps/cowlib
  795. $t test -d $(APP)/deps/ranch
  796. $i "Check that the application was compiled correctly"
  797. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  798. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  799. {ok, Deps} = application:get_key($(APP), applications), \
  800. true = lists:member(cowboy, Deps), \
  801. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  802. halt()"
  803. core-deps-fetch-hg: build clean
  804. $i "Bootstrap a new OTP library named $(APP)"
  805. $t mkdir $(APP)/
  806. $t cp ../erlang.mk $(APP)/
  807. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  808. $i "Add Ehsa 4.0.3 to the list of dependencies"
  809. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = ehsa\ndep_ehsa = hg https://bitbucket.org/a12n/ehsa 4.0.3\n"}' $(APP)/Makefile
  810. ifdef LEGACY
  811. $i "Add ehsa to the applications key in the .app.src file"
  812. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tehsa,\n"}' $(APP)/src/$(APP).app.src
  813. endif
  814. $i "Build the application"
  815. $t $(MAKE) -C $(APP) $v
  816. $i "Check that all dependencies were fetched"
  817. $t test -d $(APP)/deps/ehsa
  818. $i "Check that the application was compiled correctly"
  819. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  820. [ok = application:load(App) || App <- [$(APP), ehsa]], \
  821. {ok, Deps} = application:get_key($(APP), applications), \
  822. true = lists:member(ehsa, Deps), \
  823. {ok, \"4.0.3\"} = application:get_key(ehsa, vsn), \
  824. halt()"
  825. # Legacy must fail for the top-level application, but work for dependencies.
  826. core-deps-fetch-legacy: build clean
  827. $i "Bootstrap a new OTP library named $(APP)"
  828. $t mkdir $(APP)/
  829. $t cp ../erlang.mk $(APP)/
  830. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  831. $i "Add Cowlib as a dependency using a non-existing fetch method named oops"
  832. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib = https://github.com/ninenines/cowlib 1.0.0\n"}' $(APP)/Makefile
  833. $i "Check that building the application fails"
  834. $t ! $(MAKE) -C $(APP) $v
  835. $i "Check that building the application works with IS_DEP=1"
  836. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  837. core-deps-fetch-ln: build clean
  838. $i "Bootstrap a new OTP library named $(APP)"
  839. $t mkdir $(APP)/
  840. $t cp ../erlang.mk $(APP)/
  841. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  842. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  843. $t mkdir $(APP)/my_dep
  844. $t cp ../erlang.mk $(APP)/my_dep/
  845. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  846. $i "Add my_dep to the list of dependencies"
  847. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = ln $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  848. ifdef LEGACY
  849. $i "Add my_dep to the applications key in the .app.src file"
  850. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  851. endif
  852. $i "Build the application"
  853. $t $(MAKE) -C $(APP) $v
  854. $i "Check that all dependencies were fetched"
  855. $t test -d $(APP)/deps/my_dep
  856. $i "Check that the application was compiled correctly"
  857. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  858. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  859. {ok, Deps} = application:get_key($(APP), applications), \
  860. true = lists:member(my_dep, Deps), \
  861. halt()"
  862. core-deps-fetch-svn: build clean
  863. $i "Bootstrap a new OTP library named $(APP)"
  864. $t mkdir $(APP)/
  865. $t cp ../erlang.mk $(APP)/
  866. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  867. $i "Add Cowlib 1.0.0 to the list of dependencies"
  868. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib = svn https://github.com/ninenines/cowlib/tags/1.0.0\n"}' $(APP)/Makefile
  869. ifdef LEGACY
  870. $i "Add Cowlib to the applications key in the .app.src file"
  871. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/src/$(APP).app.src
  872. endif
  873. $i "Build the application"
  874. $t $(MAKE) -C $(APP) $v
  875. $i "Check that all dependencies were fetched"
  876. $t test -d $(APP)/deps/cowlib
  877. $i "Check that the application was compiled correctly"
  878. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  879. [ok = application:load(App) || App <- [$(APP), cowlib]], \
  880. {ok, Deps} = application:get_key($(APP), applications), \
  881. true = lists:member(cowlib, Deps), \
  882. {ok, \"1.0.0\"} = application:get_key(cowlib, vsn), \
  883. halt()"
  884. core-deps-ignore: build clean
  885. $i "Bootstrap a new OTP library named $(APP)"
  886. $t mkdir $(APP)/
  887. $t cp ../erlang.mk $(APP)/
  888. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  889. $i "Add Cowboy to dependencies, Ranch to the ignore list and to test dependencies"
  890. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nIGNORE_DEPS = ranch\nTEST_DEPS = ranch\n"}' $(APP)/Makefile
  891. ifdef LEGACY
  892. $i "Add Cowboy to the applications key in the .app.src file"
  893. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  894. endif
  895. $i "Build the application"
  896. $t $(MAKE) -C $(APP) $v
  897. $i "Check that the correct dependencies were fetched"
  898. $t test -d $(APP)/deps/cowboy
  899. $t test -d $(APP)/deps/cowlib
  900. $t test ! -e $(APP)/deps/ranch
  901. $i "Build the test dependencies"
  902. $t $(MAKE) -C $(APP) test-deps $v
  903. $i "Check that the correct dependencies were fetched"
  904. $t test -d $(APP)/deps/ranch
  905. define add_dep_and_subdep
  906. $i "Bootstrap a new OTP library named $(APP)-$(1)subdep"
  907. $t mkdir $(APP)-$(1)subdep/
  908. $t cp ../erlang.mk $(APP)-$(1)subdep/
  909. $t $(MAKE) -C $(APP)-$(1)subdep --no-print-directory -f erlang.mk bootstrap-lib $$v
  910. $i "Create a Git repository for $(APP)-$(1)subdep"
  911. $t (cd $(APP)-$(1)subdep && \
  912. git init -q && \
  913. git config user.name "Testsuite" && \
  914. git config user.email "testsuite@erlang.mk" && \
  915. git add . && \
  916. git commit -q --no-gpg-sign -m "Initial commit")
  917. $i "Bootstrap a new OTP library named $(APP)-$(1)dep"
  918. $t mkdir $(APP)-$(1)dep/
  919. $t cp ../erlang.mk $(APP)-$(1)dep/
  920. $t $(MAKE) -C $(APP)-$(1)dep --no-print-directory -f erlang.mk bootstrap-lib $$v
  921. $i "Add $(APP)-$(1)subdep as a dependency"
  922. $t perl -ni.bak -e \
  923. 'print;if ($$.==1) {print "DEPS = $(1)subdep\ndep_$(1)subdep = git file://$(abspath $(APP)-$(1)subdep) master\n"}' \
  924. $(APP)-$(1)dep/Makefile
  925. $t rm $(APP)-$(1)dep/Makefile.bak
  926. $i "Create a Git repository for $(APP)-$(1)dep"
  927. $t (cd $(APP)-$(1)dep && \
  928. git init -q && \
  929. git config user.name "Testsuite" && \
  930. git config user.email "testsuite@erlang.mk" && \
  931. git add . && \
  932. git commit -q --no-gpg-sign -m "Initial commit")
  933. endef
  934. core-deps-list-deps: build clean
  935. $(call add_dep_and_subdep,)
  936. $(call add_dep_and_subdep,doc)
  937. $(call add_dep_and_subdep,rel)
  938. $(call add_dep_and_subdep,test)
  939. $(call add_dep_and_subdep,shell)
  940. $i "Bootstrap a new OTP library named $(APP)"
  941. $t mkdir $(APP)/
  942. $t cp ../erlang.mk $(APP)/
  943. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  944. $i "Add $(APP)-dep and $(APP)-testdep as a dependency"
  945. $t sed -i.bak '2i\
  946. DEPS = dep\
  947. DOC_DEPS = docdep\
  948. REL_DEPS = reldep\
  949. TEST_DEPS = testdep\
  950. SHELL_DEPS = shelldep\
  951. dep_dep = git file://$(abspath $(APP)-dep) master\
  952. dep_docdep = git file://$(abspath $(APP)-docdep) master\
  953. dep_reldep = git file://$(abspath $(APP)-reldep) master\
  954. dep_testdep = git file://$(abspath $(APP)-testdep) master\
  955. dep_shelldep = git file://$(abspath $(APP)-shelldep) master\
  956. ' $(APP)/Makefile
  957. $t rm $(APP)/Makefile.bak
  958. $i "Create a Git repository for $(APP)"
  959. $t (cd $(APP) && \
  960. git init -q && \
  961. git config user.name "Testsuite" && \
  962. git config user.email "testsuite@erlang.mk" && \
  963. git add . && \
  964. git commit -q --no-gpg-sign -m "Initial commit")
  965. $i "List application dependencies"
  966. $t $(MAKE) -C $(APP) --no-print-directory list-deps $v
  967. $t test -d $(APP)/deps/subdep
  968. $t printf "%s\n%s\n" $(abspath $(APP)/deps/dep $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  969. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  970. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  971. $i "List application doc dependencies"
  972. $t $(MAKE) -C $(APP) --no-print-directory list-doc-deps $v
  973. $t test -d $(APP)/deps/subdep
  974. $t test -d $(APP)/deps/docsubdep
  975. $t printf "%s\n%s\n%s\n%s\n" \
  976. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/docdep $(APP)/deps/docsubdep) \
  977. | sort > $(APP)/expected-doc-deps.txt
  978. $t cmp $(APP)/expected-doc-deps.txt $(APP)/.erlang.mk/recursive-doc-deps-list.log
  979. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  980. $i "List application rel dependencies"
  981. $t $(MAKE) -C $(APP) --no-print-directory list-rel-deps $v
  982. $t test -d $(APP)/deps/subdep
  983. $t test -d $(APP)/deps/relsubdep
  984. $t printf "%s\n%s\n%s\n%s\n" \
  985. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/reldep $(APP)/deps/relsubdep) \
  986. | sort > $(APP)/expected-rel-deps.txt
  987. $t cmp $(APP)/expected-rel-deps.txt $(APP)/.erlang.mk/recursive-rel-deps-list.log
  988. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  989. $i "List application test dependencies"
  990. $t $(MAKE) -C $(APP) --no-print-directory list-test-deps $v
  991. $t test -d $(APP)/deps/subdep
  992. $t test -d $(APP)/deps/testsubdep
  993. $t printf "%s\n%s\n%s\n%s\n" \
  994. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/testdep $(APP)/deps/testsubdep) \
  995. | sort > $(APP)/expected-test-deps.txt
  996. $t cmp $(APP)/expected-test-deps.txt $(APP)/.erlang.mk/recursive-test-deps-list.log
  997. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  998. $i "List application shell dependencies"
  999. $t $(MAKE) -C $(APP) --no-print-directory list-shell-deps $v
  1000. $t test -d $(APP)/deps/subdep
  1001. $t test -d $(APP)/deps/shellsubdep
  1002. $t printf "%s\n%s\n%s\n%s\n" \
  1003. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/shelldep $(APP)/deps/shellsubdep) \
  1004. | sort > $(APP)/expected-shell-deps.txt
  1005. $t cmp $(APP)/expected-shell-deps.txt $(APP)/.erlang.mk/recursive-shell-deps-list.log
  1006. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  1007. $i "List application all dependencies (all kinds)"
  1008. $t $(MAKE) -C $(APP) --no-print-directory list-deps DEP_TYPES='doc rel test shell' $v
  1009. $t test -d $(APP)/deps/subdep
  1010. $t test -d $(APP)/deps/docsubdep
  1011. $t test -d $(APP)/deps/relsubdep
  1012. $t test -d $(APP)/deps/testsubdep
  1013. $t test -d $(APP)/deps/shellsubdep
  1014. $t printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
  1015. $(abspath \
  1016. $(APP)/deps/dep $(APP)/deps/subdep \
  1017. $(APP)/deps/docdep $(APP)/deps/docsubdep \
  1018. $(APP)/deps/reldep $(APP)/deps/relsubdep \
  1019. $(APP)/deps/testdep $(APP)/deps/testsubdep \
  1020. $(APP)/deps/shelldep $(APP)/deps/shellsubdep) \
  1021. | sort > $(APP)/expected-all-deps.txt
  1022. $t cmp $(APP)/expected-all-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  1023. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  1024. core-deps-mv: build clean
  1025. $i "Bootstrap a new OTP library named $(APP)"
  1026. $t mkdir $(APP)/
  1027. $t cp ../erlang.mk $(APP)/
  1028. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1029. $i "Add Cowlib to the list of dependencies"
  1030. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  1031. $i "Build the application"
  1032. $t $(MAKE) -C $(APP) $v
  1033. $i "Check that all dependencies were fetched"
  1034. $t test -d $(APP)/deps/cowlib
  1035. $i "Move the application elsewhere"
  1036. $t mv $(APP) $(APP)-moved
  1037. $i "Build the application"
  1038. $t $(MAKE) -C $(APP)-moved $v
  1039. core-deps-mv-rebar: build clean
  1040. $i "Bootstrap a new OTP library named $(APP)"
  1041. $t mkdir $(APP)/
  1042. $t cp ../erlang.mk $(APP)/
  1043. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1044. $i "Add Lager to the list of dependencies"
  1045. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\n"}' $(APP)/Makefile
  1046. $i "Build the application"
  1047. $t $(MAKE) -C $(APP) $v
  1048. $i "Check that all dependencies were fetched"
  1049. $t test -d $(APP)/deps/goldrush
  1050. $t test -d $(APP)/deps/lager
  1051. $i "Move the application elsewhere"
  1052. $t mv $(APP) $(APP)-moved
  1053. $i "Build the application"
  1054. $t $(MAKE) -C $(APP)-moved $v
  1055. # A lower-level dependency of the first dependency always
  1056. # wins over a lower-level dependency of the second dependency.
  1057. core-deps-order-first: build clean
  1058. $i "Bootstrap a new OTP library named $(APP)"
  1059. $t mkdir $(APP)/
  1060. $t cp ../erlang.mk $(APP)/
  1061. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1062. $i "Add Cowboy package and my_dep to the list of dependencies"
  1063. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep cowboy\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  1064. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  1065. $t mkdir $(APP)/my_dep
  1066. $t cp ../erlang.mk $(APP)/my_dep/
  1067. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  1068. $i "Add Cowlib 1.0.0 to the list of dependencies for my_dep"
  1069. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib = git https://github.com/ninenines/cowlib 1.0.0\n"}' $(APP)/my_dep/Makefile
  1070. ifdef LEGACY
  1071. $i "Add Cowboy and my_dep to the applications key in the .app.src file"
  1072. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  1073. endif
  1074. $i "Build the application"
  1075. $t $(MAKE) -C $(APP) $v
  1076. $i "Check that all dependencies were fetched"
  1077. $t test -d $(APP)/deps/cowboy
  1078. $t test -d $(APP)/deps/cowlib
  1079. $t test -d $(APP)/deps/my_dep
  1080. $t test -d $(APP)/deps/ranch
  1081. $i "Check that the application was compiled correctly"
  1082. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1083. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, my_dep, ranch]], \
  1084. {ok, Deps} = application:get_key($(APP), applications), \
  1085. true = lists:member(cowboy, Deps), \
  1086. {ok, \"1.0.0\"} = application:get_key(cowlib, vsn), \
  1087. halt()"
  1088. # A higher-level dependency always wins.
  1089. core-deps-order-top: build clean
  1090. $i "Bootstrap a new OTP library named $(APP)"
  1091. $t mkdir $(APP)/
  1092. $t cp ../erlang.mk $(APP)/
  1093. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1094. $i "Add Cowboy package and Cowlib 1.0.0 to the list of dependencies"
  1095. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy cowlib\ndep_cowlib = git https://github.com/ninenines/cowlib 1.0.0\n"}' $(APP)/Makefile
  1096. ifdef LEGACY
  1097. $i "Add Cowboy to the applications key in the .app.src file"
  1098. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  1099. endif
  1100. $i "Build the application"
  1101. $t $(MAKE) -C $(APP) $v
  1102. $i "Check that all dependencies were fetched"
  1103. $t test -d $(APP)/deps/cowboy
  1104. $t test -d $(APP)/deps/cowlib
  1105. $t test -d $(APP)/deps/ranch
  1106. $i "Check that the application was compiled correctly"
  1107. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1108. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  1109. {ok, Deps} = application:get_key($(APP), applications), \
  1110. true = lists:member(cowboy, Deps), \
  1111. {ok, \"1.0.0\"} = application:get_key(cowlib, vsn), \
  1112. halt()"
  1113. core-deps-no-autopatch: build clean
  1114. $i "Bootstrap a new OTP library named $(APP)"
  1115. $t mkdir $(APP)/
  1116. $t cp ../erlang.mk $(APP)/
  1117. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1118. $i "Add Cowboy to the list of dependencies and Cowlib to the NO_AUTOPATCH list"
  1119. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nNO_AUTOPATCH = cowlib\n"}' $(APP)/Makefile
  1120. $i "Build the application"
  1121. $t $(MAKE) -C $(APP) $v
  1122. $i "Check that all dependencies were fetched"
  1123. $t test -d $(APP)/deps/cowboy
  1124. $t test -d $(APP)/deps/cowlib
  1125. $t test -d $(APP)/deps/ranch
  1126. $i "Check that Cowlib was not autopatched"
  1127. $t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
  1128. core-deps-no-autopatch-erlang-mk: build clean
  1129. $i "Bootstrap a new OTP library named $(APP)"
  1130. $t mkdir $(APP)/
  1131. $t cp ../erlang.mk $(APP)/
  1132. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1133. $i "Add Cowlib to the list of dependencies and set NO_AUTOPATCH_ERLANG_MK=1"
  1134. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\nNO_AUTOPATCH_ERLANG_MK = 1\n"}' $(APP)/Makefile
  1135. $i "Build the application"
  1136. $t $(MAKE) -C $(APP) $v
  1137. $i "Check that all dependencies were fetched"
  1138. $t test -d $(APP)/deps/cowlib
  1139. $i "Check that Erlang.mk was not autopatched"
  1140. $t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
  1141. core-deps-no-autopatch-rebar: build clean
  1142. $i "Bootstrap a new OTP library named $(APP)"
  1143. $t mkdir $(APP)/
  1144. $t cp ../erlang.mk $(APP)/
  1145. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1146. $i "Add Lager to the list of dependencies and to the NO_AUTOPATCH list"
  1147. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nNO_AUTOPATCH = lager\n"}' $(APP)/Makefile
  1148. $i "Build the application"
  1149. $t $(MAKE) -C $(APP) $v
  1150. $i "Check that all dependencies were fetched"
  1151. $t test -d $(APP)/deps/goldrush
  1152. $t test -d $(APP)/deps/lager
  1153. $i "Check that Lager was not autopatched"
  1154. $t if grep -q erlang\.mk $(APP)/deps/goldrush/Makefile; then false; fi
  1155. $t if grep -q erlang\.mk $(APP)/deps/lager/Makefile; then false; fi
  1156. ifndef LEGACY
  1157. core-deps-otp: build clean
  1158. $i "Bootstrap a new OTP library named $(APP)"
  1159. $t mkdir $(APP)/
  1160. $t cp ../erlang.mk $(APP)/
  1161. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1162. $i "Add Crypto to the list of OTP dependencies"
  1163. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = crypto\n"}' $(APP)/Makefile
  1164. $i "Build the application"
  1165. $t $(MAKE) -C $(APP) $v
  1166. $i "Check that no dependencies were fetched"
  1167. $t test ! -e $(APP)/deps
  1168. $i "Check that the application was compiled correctly"
  1169. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1170. [ok = application:load(App) || App <- [$(APP), crypto]], \
  1171. {ok, Deps} = application:get_key($(APP), applications), \
  1172. true = lists:member(crypto, Deps), \
  1173. halt()"
  1174. endif
  1175. core-deps-pkg: build clean
  1176. $i "Bootstrap a new OTP library named $(APP)"
  1177. $t mkdir $(APP)/
  1178. $t cp ../erlang.mk $(APP)/
  1179. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1180. $i "Add Cowboy to the list of dependencies"
  1181. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
  1182. ifdef LEGACY
  1183. $i "Add Cowboy to the applications key in the .app.src file"
  1184. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  1185. endif
  1186. $i "Build the application"
  1187. $t $(MAKE) -C $(APP) $v
  1188. $i "Check that all dependencies were fetched"
  1189. $t test -d $(APP)/deps/cowboy
  1190. $t test -d $(APP)/deps/cowlib
  1191. $t test -d $(APP)/deps/ranch
  1192. $i "Check that the application was compiled correctly"
  1193. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1194. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  1195. {ok, Deps} = application:get_key($(APP), applications), \
  1196. true = lists:member(cowboy, Deps), \
  1197. halt()"
  1198. core-deps-rel: build clean
  1199. $i "Bootstrap a new release-enabled OTP library named $(APP)"
  1200. $t mkdir $(APP)/
  1201. $t cp ../erlang.mk $(APP)/
  1202. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib bootstrap-rel $v
  1203. $i "Add Recon to the list of release dependencies"
  1204. $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = recon\n"}' $(APP)/Makefile
  1205. $i "Add Recon to the relx.config file"
  1206. $t $(ERL) -eval " \
  1207. {ok, Conf0} = file:consult(\"$(APP)/relx.config\"), \
  1208. Conf = lists:keyreplace(release, 1, Conf0, {release, {$(APP)_release, \"1\"}, [$(APP), recon]}), \
  1209. ok = file:write_file(\"$(APP)/relx.config\", \
  1210. lists:map(fun(Term) -> io_lib:format(\"~p.~n\", [Term]) end, Conf)), \
  1211. halt()"
  1212. $i "Build the application and its dependencies"
  1213. $t $(MAKE) -C $(APP) deps app $v
  1214. $i "Check that no dependencies were fetched"
  1215. $t test ! -e $(APP)/deps
  1216. $i "Check that the application was compiled correctly"
  1217. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1218. [ok = application:load(App) || App <- [$(APP)]], \
  1219. {ok, Deps} = application:get_key($(APP), applications), \
  1220. false = lists:member(recon, Deps), \
  1221. halt()"
  1222. $i "Build the release"
  1223. $t $(MAKE) -C $(APP) $v
  1224. $i "Check that all dependencies were fetched"
  1225. $t test -d $(APP)/deps/recon
  1226. $i "Check that the application was compiled correctly"
  1227. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1228. [ok = application:load(App) || App <- [$(APP), recon]], \
  1229. {ok, Deps} = application:get_key($(APP), applications), \
  1230. false = lists:member(recon, Deps), \
  1231. halt()"
  1232. # @todo Add check for MSYS2 when releases under Windows become usable.
  1233. # $i "Start the release and check that Recon is loaded"
  1234. ifeq ($(PLATFORM),msys2)
  1235. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd install $v
  1236. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd start $v
  1237. # $t test -n "`$(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd rpcterms \
  1238. # application loaded_applications | grep recon`"
  1239. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd stop $v
  1240. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd uninstall $v
  1241. else
  1242. $i "Start the release and check that Recon is loaded"
  1243. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  1244. $t apps="Node is not running!"; \
  1245. while test "$$apps" = "Node is not running!"; do \
  1246. apps=$$($(APP)/_rel/$(APP)_release/bin/$(APP)_release \
  1247. rpcterms \ application loaded_applications); \
  1248. done; \
  1249. echo "$$apps" | grep -q recon
  1250. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  1251. endif
  1252. core-deps-search: build clean
  1253. $i "Bootstrap a new OTP library named $(APP)"
  1254. $t mkdir $(APP)/
  1255. $t cp ../erlang.mk $(APP)/
  1256. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1257. $i "Run 'make search' and check that it prints packages"
  1258. $t test -n "`$(MAKE) -C $(APP) search`"
  1259. $i "Run 'make search q=cowboy' and check that it prints packages"
  1260. $t test -n "`$(MAKE) -C $(APP) search q=cowboy`"
  1261. core-deps-shell: build clean
  1262. $i "Bootstrap a new OTP library named $(APP)"
  1263. $t mkdir $(APP)/
  1264. $t cp ../erlang.mk $(APP)/
  1265. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1266. $i "Add TDDReloader to the list of shell dependencies"
  1267. $t perl -ni.bak -e 'print;if ($$.==1) {print "SHELL_DEPS = tddreloader\n"}' $(APP)/Makefile
  1268. $i "Build the application and its dependencies"
  1269. $t $(MAKE) -C $(APP) deps app $v
  1270. $i "Check that no dependencies were fetched"
  1271. $t test ! -e $(APP)/deps
  1272. $i "Check that the application was compiled correctly"
  1273. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1274. [ok = application:load(App) || App <- [$(APP)]], \
  1275. {ok, Deps} = application:get_key($(APP), applications), \
  1276. false = lists:member(tddreloader, Deps), \
  1277. halt()"
  1278. $i "Run the shell"
  1279. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval \" \
  1280. ok = application:load($(APP)), \
  1281. ok = application:load(tddreloader), \
  1282. halt()\"" $v
  1283. $i "Check that all dependencies were fetched"
  1284. $t test -d $(APP)/deps/tddreloader
  1285. $i "Check that the application was compiled correctly"
  1286. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1287. [ok = application:load(App) || App <- [$(APP), tddreloader]], \
  1288. {ok, Deps} = application:get_key($(APP), applications), \
  1289. false = lists:member(tddreloader, Deps), \
  1290. halt()"
  1291. core-deps-skip: build clean
  1292. $i "Bootstrap a new OTP library named $(APP)"
  1293. $t mkdir $(APP)/
  1294. $t cp ../erlang.mk $(APP)/
  1295. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1296. $i "Add Cowboy to the list of dependencies"
  1297. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
  1298. ifdef LEGACY
  1299. $i "Add Cowboy to the applications key in the .app.src file"
  1300. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  1301. endif
  1302. $i "Build the application with SKIP_DEPS=1"
  1303. $t $(MAKE) -C $(APP) SKIP_DEPS=1 $v
  1304. $i "Check that no dependencies were fetched"
  1305. $t test ! -e $(APP)/deps
  1306. $i "Build the application"
  1307. $t $(MAKE) -C $(APP) $v
  1308. $i "Check that all dependencies were fetched"
  1309. $t test -d $(APP)/deps/cowlib
  1310. $t test -d $(APP)/deps/cowboy
  1311. $t test -d $(APP)/deps/ranch
  1312. $i "Distclean with SKIP_DEPS=1"
  1313. $t $(MAKE) -C $(APP) distclean SKIP_DEPS=1 $v
  1314. $i "Check that no dependencies were removed"
  1315. $t test -d $(APP)/deps/cowlib
  1316. $t test -d $(APP)/deps/cowboy
  1317. $t test -d $(APP)/deps/ranch
  1318. core-deps-test: build clean
  1319. $i "Bootstrap a new OTP library named $(APP)"
  1320. $t mkdir $(APP)/
  1321. $t cp ../erlang.mk $(APP)/
  1322. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1323. $i "Generate .erl files"
  1324. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1325. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1326. $i "Add triq to the list of test dependencies"
  1327. $t perl -ni.bak -e 'print;if ($$.==1) {print "TEST_DEPS = triq\n"}' $(APP)/Makefile
  1328. $i "Build the application and its dependencies"
  1329. $t $(MAKE) -C $(APP) deps app $v
  1330. $i "Check that no dependencies were fetched"
  1331. $t test ! -e $(APP)/deps
  1332. $i "Check that the application was compiled correctly"
  1333. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1334. [ok = application:load(App) || App <- [$(APP)]], \
  1335. {ok, Deps} = application:get_key($(APP), applications), \
  1336. false = lists:member(triq, Deps), \
  1337. halt()"
  1338. $i "Run tests"
  1339. $t $(MAKE) -C $(APP) tests $v
  1340. $i "Check that all dependencies were fetched"
  1341. $t test -d $(APP)/deps/triq
  1342. $i "Check that the application was compiled correctly"
  1343. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1344. [ok = application:load(App) || App <- [$(APP), triq]], \
  1345. {ok, Deps} = application:get_key($(APP), applications), \
  1346. false = lists:member(triq, Deps), \
  1347. halt()"