core_deps.mk 60 KB

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