core_deps.mk 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  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. ifneq ($(PLATFORM),msys2)
  6. core-deps-build-c-8cc: init
  7. $i "Bootstrap a new OTP library named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  11. $i "Add 8cc to the list of build dependencies"
  12. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = 8cc\ndep_8cc = git https://github.com/rui314/8cc master\n"}' $(APP)/Makefile
  13. $i "Build the application"
  14. $t $(MAKE) -C $(APP) $v
  15. $i "Check that all dependencies were fetched"
  16. $t test -d $(APP)/deps/8cc
  17. $i "Check that 8cc can be started"
  18. $t $(APP)/deps/8cc/8cc -h $v
  19. $i "Check that the application was compiled correctly"
  20. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  21. [ok = application:load(App) || App <- [$(APP)]], \
  22. {ok, Deps} = application:get_key($(APP), applications), \
  23. false = lists:member('8cc', Deps), \
  24. halt()"
  25. endif
  26. core-deps-build-c-lz4: init
  27. $i "Bootstrap a new OTP library named $(APP)"
  28. $t mkdir $(APP)/
  29. $t cp ../erlang.mk $(APP)/
  30. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  31. $i "Add lz4 to the list of build dependencies"
  32. $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
  33. $i "Build the application"
  34. $t $(MAKE) -C $(APP) $v
  35. $i "Check that all dependencies were fetched"
  36. $t test -d $(APP)/deps/lz4_src
  37. $i "Check that lz4 was compiled"
  38. $t test -f $(APP)/deps/lz4_src/lib/liblz4.a
  39. $i "Check that the application was compiled correctly"
  40. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  41. [ok = application:load(App) || App <- [$(APP)]], \
  42. {ok, Deps} = application:get_key($(APP), applications), \
  43. false = lists:member(lz4, Deps), \
  44. halt()"
  45. core-deps-build-erl: init
  46. $i "Bootstrap a new OTP library named $(APP)"
  47. $t mkdir $(APP)/
  48. $t cp ../erlang.mk $(APP)/
  49. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  50. $i "Add cowlib to the list of build dependencies"
  51. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = cowlib\n"}' $(APP)/Makefile
  52. $i "Build the application"
  53. $t $(MAKE) -C $(APP) $v
  54. $i "Check that all dependencies were fetched"
  55. $t test -d $(APP)/deps/cowlib
  56. $i "Check that the application was compiled correctly"
  57. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  58. [ok = application:load(App) || App <- [$(APP), cowlib]], \
  59. {ok, Deps} = application:get_key($(APP), applications), \
  60. false = lists:member(cowlib, Deps), \
  61. halt()"
  62. core-deps-build-js: init
  63. $i "Bootstrap a new OTP library named $(APP)"
  64. $t mkdir $(APP)/
  65. $t cp ../erlang.mk $(APP)/
  66. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  67. $i "Add jquery to the list of build dependencies"
  68. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = jquery\ndep_jquery = git https://github.com/jquery/jquery master\n"}' $(APP)/Makefile
  69. $i "Build the application"
  70. $t $(MAKE) -C $(APP) $v
  71. $i "Check that all dependencies were fetched"
  72. $t test -d $(APP)/deps/jquery
  73. $i "Check that the application was compiled correctly"
  74. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  75. [ok = application:load(App) || App <- [$(APP)]], \
  76. {ok, Deps} = application:get_key($(APP), applications), \
  77. false = lists:member(jquery, Deps), \
  78. halt()"
  79. core-deps-dep-built: init
  80. $i "Bootstrap a new OTP library named $(APP)"
  81. $t mkdir $(APP)/
  82. $t cp ../erlang.mk $(APP)/
  83. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  84. $i "Add cowlib to the list of dependencies"
  85. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  86. $i "Build the application"
  87. $t $(MAKE) -C $(APP) $v
  88. $i "Touch one cowlib file to mark it for recompilation"
  89. $t $(SLEEP)
  90. $t touch $(APP)/deps/cowlib/src/cow_http.erl
  91. $i "Check that cowlib is not rebuilt"
  92. $t touch $(APP)/EXPECT
  93. $t $(SLEEP)
  94. $t $(MAKE) -C $(APP) $v
  95. $t find $(APP)/deps/cowlib -type f -newer $(APP)/EXPECT | sort | diff $(APP)/EXPECT -
  96. $t rm $(APP)/EXPECT
  97. $i "Delete the dep_built file"
  98. $t rm $(APP)/deps/cowlib/ebin/dep_built
  99. $i "Check that cowlib was rebuilt"
  100. $t printf "%s\n" \
  101. $(APP)/deps/cowlib/cowlib.d \
  102. $(APP)/deps/cowlib/ebin/cowlib.app \
  103. $(APP)/deps/cowlib/ebin/cow_http.beam \
  104. $(APP)/deps/cowlib/ebin/dep_built | sort > $(APP)/EXPECT
  105. $t $(SLEEP)
  106. $t $(MAKE) -C $(APP) $v
  107. # Files in .git might end up modified due to the id generation in the .app file.
  108. $t find $(APP)/deps/cowlib -type f -newer $(APP)/EXPECT | grep -v ".git" | sort | diff $(APP)/EXPECT -
  109. $t rm $(APP)/EXPECT
  110. core-deps-dep-built-full: init
  111. $i "Bootstrap a new OTP library named $(APP)"
  112. $t mkdir $(APP)/
  113. $t cp ../erlang.mk $(APP)/
  114. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  115. $i "Add cowlib to the list of dependencies"
  116. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  117. $i "Build the application"
  118. $t $(MAKE) -C $(APP) $v
  119. $i "Touch one cowlib file to mark it for recompilation"
  120. $t $(SLEEP)
  121. $t touch $(APP)/deps/cowlib/src/cow_http.erl
  122. $i "Check that cowlib is rebuilt with FULL=1"
  123. $t printf "%s\n" \
  124. $(APP)/deps/cowlib/cowlib.d \
  125. $(APP)/deps/cowlib/ebin/cowlib.app \
  126. $(APP)/deps/cowlib/ebin/cow_http.beam \
  127. $(APP)/deps/cowlib/ebin/dep_built | sort > $(APP)/EXPECT
  128. $t $(SLEEP)
  129. $t $(MAKE) -C $(APP) FULL=1 $v
  130. # Files in .git might end up modified due to the id generation in the .app file.
  131. $t find $(APP)/deps/cowlib -type f -newer $(APP)/EXPECT | grep -v ".git" | sort | diff $(APP)/EXPECT -
  132. $t rm $(APP)/EXPECT
  133. core-deps-dep-built-ln: init
  134. $i "Bootstrap a new OTP library named $(APP)"
  135. $t mkdir $(APP)/
  136. $t cp ../erlang.mk $(APP)/
  137. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  138. $i "Add cowlib to the list of dependencies"
  139. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  140. $i "Clone cowlib manually inside $(APP)"
  141. $t git clone -q https://github.com/ninenines/cowlib $(APP)/cowlib
  142. $i "Link to cowlib instead of fetching the dependency"
  143. $t mkdir -p $(APP)/deps
  144. $t ln -s ../cowlib $(APP)/deps/cowlib
  145. $i "Build the application"
  146. $t $(MAKE) -C $(APP) $v
  147. # On MSYS2 "ln" will by default not create symbolic links because
  148. # it requires an option to be enabled and administrative privileges.
  149. # The "rebuild" part of the test is therefore skipped on Windows.
  150. ifneq ($(PLATFORM),msys2)
  151. $i "Touch one cowlib file to mark it for recompilation"
  152. $t $(SLEEP)
  153. $t touch $(APP)/deps/cowlib/src/cow_http.erl
  154. $i "Check that cowlib is rebuilt; symlinked deps don't create dep_built"
  155. $t printf "%s\n" \
  156. $(APP)/cowlib/cowlib.d \
  157. $(APP)/cowlib/ebin/cowlib.app \
  158. $(APP)/cowlib/ebin/cow_http.beam | sort > $(APP)/EXPECT
  159. $t $(SLEEP)
  160. $t $(MAKE) -C $(APP) $v
  161. # Files in .git might end up modified due to the id generation in the .app file.
  162. $t find $(APP)/cowlib -type f -newer $(APP)/EXPECT | grep -v ".git" | sort | diff $(APP)/EXPECT -
  163. $t rm $(APP)/EXPECT
  164. endif
  165. core-deps-dep-commit: init
  166. $i "Bootstrap a new OTP library named $(APP)"
  167. $t mkdir $(APP)/
  168. $t cp ../erlang.mk $(APP)/
  169. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  170. $i "Add Cowboy 1.0.0 to the list of dependencies"
  171. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy_commit = 1.0.0\n"}' $(APP)/Makefile
  172. ifdef LEGACY
  173. $i "Add Cowboy to the applications key in the .app.src file"
  174. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  175. endif
  176. $i "Build the application"
  177. $t $(MAKE) -C $(APP) $v
  178. $i "Check that all dependencies were fetched"
  179. $t test -d $(APP)/deps/cowboy
  180. $t test -d $(APP)/deps/cowlib
  181. $t test -d $(APP)/deps/ranch
  182. $i "Check that the application was compiled correctly"
  183. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  184. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  185. {ok, Deps} = application:get_key($(APP), applications), \
  186. true = lists:member(cowboy, Deps), \
  187. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  188. halt()"
  189. core-deps-dir: init
  190. $i "Bootstrap a new OTP library named $(APP)"
  191. $t mkdir $(APP)/
  192. $t cp ../erlang.mk $(APP)/
  193. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  194. $i "Add Cowboy to the list of dependencies with a custom DEPS_DIR"
  195. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nDEPS_DIR ?= \$$(CURDIR)/deep/libs\n"}' $(APP)/Makefile
  196. ifdef LEGACY
  197. $i "Add Cowboy to the applications key in the .app.src file"
  198. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  199. endif
  200. $i "Build the application"
  201. $t $(MAKE) -C $(APP) $v
  202. $i "Check that all dependencies were fetched in the custom DEPS_DIR"
  203. $t test -d $(APP)/deep/libs/cowboy
  204. $t test -d $(APP)/deep/libs/cowlib
  205. $t test -d $(APP)/deep/libs/ranch
  206. $i "Check that the application was compiled correctly"
  207. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deep/libs/*/ebin/ -eval " \
  208. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  209. {ok, Deps} = application:get_key($(APP), applications), \
  210. true = lists:member(cowboy, Deps), \
  211. halt()"
  212. core-deps-doc: init
  213. $i "Bootstrap a new OTP library named $(APP)"
  214. $t mkdir $(APP)/
  215. $t cp ../erlang.mk $(APP)/
  216. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  217. $i "Generate .erl files"
  218. $t echo "-module(boy)." > $(APP)/src/boy.erl
  219. $t echo "-module(girl)." > $(APP)/src/girl.erl
  220. $i "Add Edown as a documentation building dependency"
  221. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = edown\nEDOC_OPTS = {doclet, edown_doclet}\n"}' $(APP)/Makefile
  222. $i "Build the application"
  223. $t $(MAKE) -C $(APP) $v
  224. $i "Check that no dependencies were fetched"
  225. $t test ! -e $(APP)/deps
  226. $i "Check that the application was compiled correctly"
  227. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  228. [ok = application:load(App) || App <- [$(APP)]], \
  229. {ok, Deps} = application:get_key($(APP), applications), \
  230. false = lists:member(edown, Deps), \
  231. halt()"
  232. $i "Build the application documentation"
  233. $t $(MAKE) -C $(APP) edoc $v
  234. $i "Check that documentation dependencies were fetched"
  235. $t test -d $(APP)/deps/edown
  236. $i "Check the Edown generated Markdown documentation"
  237. $t test -f $(APP)/doc/boy.md
  238. $t test -f $(APP)/doc/girl.md
  239. core-deps-fetch-cp: init
  240. $i "Bootstrap a new OTP library named $(APP)"
  241. $t mkdir $(APP)/
  242. $t cp ../erlang.mk $(APP)/
  243. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  244. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  245. $t mkdir $(APP)/my_dep
  246. $t cp ../erlang.mk $(APP)/my_dep/
  247. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  248. $i "Add my_dep to the list of dependencies"
  249. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  250. ifdef LEGACY
  251. $i "Add my_dep to the applications key in the .app.src file"
  252. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  253. endif
  254. $i "Build the application"
  255. $t $(MAKE) -C $(APP) $v
  256. $i "Check that all dependencies were fetched"
  257. $t test -d $(APP)/deps/my_dep
  258. $i "Check that the application was compiled correctly"
  259. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  260. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  261. {ok, Deps} = application:get_key($(APP), applications), \
  262. true = lists:member(my_dep, Deps), \
  263. halt()"
  264. core-deps-fetch-custom: init
  265. $i "Bootstrap a new OTP library named $(APP)"
  266. $t mkdir $(APP)/
  267. $t cp ../erlang.mk $(APP)/
  268. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  269. $i "Add dependency boop using custom fetch method beep to the list of dependencies"
  270. $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
  271. ifdef LEGACY
  272. $i "Add boop to the applications key in the .app.src file"
  273. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tboop,\n"}' $(APP)/src/$(APP).app.src
  274. endif
  275. $i "Build the application"
  276. $t $(MAKE) -C $(APP) $v
  277. $i "Check that all dependencies were fetched"
  278. $t test -d $(APP)/deps/boop
  279. $i "Check that the application was compiled correctly"
  280. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  281. ok = application:load($(APP)), \
  282. {ok, Deps} = application:get_key($(APP), applications), \
  283. true = lists:member(boop, Deps), \
  284. halt()"
  285. core-deps-fetch-fail-bad: init
  286. $i "Bootstrap a new OTP library named $(APP)"
  287. $t mkdir $(APP)/
  288. $t cp ../erlang.mk $(APP)/
  289. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  290. $i "Add Cowlib as a dependency using a non-existing fetch method named oops"
  291. $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
  292. $i "Check that building the application fails"
  293. $t ! $(MAKE) -C $(APP) $v
  294. core-deps-fetch-fail-unknown: init
  295. $i "Bootstrap a new OTP library named $(APP)"
  296. $t mkdir $(APP)/
  297. $t cp ../erlang.mk $(APP)/
  298. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  299. $i "Add an unknown application as a dependency"
  300. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = unknown\n"}' $(APP)/Makefile
  301. $i "Check that building the application fails"
  302. $t ! $(MAKE) -C $(APP) $v
  303. core-deps-fetch-git: init
  304. $i "Bootstrap a new OTP library named $(APP)"
  305. $t mkdir $(APP)/
  306. $t cp ../erlang.mk $(APP)/
  307. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  308. $i "Add Cowboy 1.0.0 to the list of dependencies"
  309. $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
  310. ifdef LEGACY
  311. $i "Add Cowboy to the applications key in the .app.src file"
  312. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  313. endif
  314. $i "Build the application"
  315. $t $(MAKE) -C $(APP) $v
  316. $i "Check that all dependencies were fetched"
  317. $t test -d $(APP)/deps/cowboy
  318. $t test -d $(APP)/deps/cowlib
  319. $t test -d $(APP)/deps/ranch
  320. $i "Check that the application was compiled correctly"
  321. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  322. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  323. {ok, Deps} = application:get_key($(APP), applications), \
  324. true = lists:member(cowboy, Deps), \
  325. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  326. halt()"
  327. core-deps-fetch-git-subfolder: init
  328. $i "Bootstrap a new OTP library named $(APP)"
  329. $t mkdir $(APP)/
  330. $t cp ../erlang.mk $(APP)/
  331. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  332. $i "Bootstrap a new OTP library named my_dep as a subfolder inside $(APP)"
  333. $t mkdir -p $(APP)/git_repo/my_dep
  334. $t cp ../erlang.mk $(APP)/git_repo/my_dep/
  335. $t $(MAKE) -C $(APP)/git_repo/my_dep/ -f erlang.mk bootstrap-lib $v
  336. # Create an empty file so src/ gets committed.
  337. $t touch $(APP)/git_repo/my_dep/src/README
  338. $t cd $(APP)/git_repo && \
  339. git init -q && \
  340. git config user.email "testsuite@erlang.mk" && \
  341. git config user.name "test suite" && \
  342. git add . && \
  343. git commit -q --no-gpg-sign -m "Tests"
  344. $i "Add my_dep to the list of dependencies"
  345. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = git-subfolder file://$(abspath $(APP)/git_repo) master my_dep\n"}' $(APP)/Makefile
  346. ifdef LEGACY
  347. $i "Add my_dep to the applications key in the .app.src file"
  348. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  349. endif
  350. $i "Build the application"
  351. $t $(MAKE) -C $(APP) $v
  352. $i "Check that the dependency was fetched"
  353. $t test -d $(APP)/deps/my_dep
  354. $i "Check that the application was compiled correctly"
  355. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  356. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  357. {ok, Deps} = application:get_key($(APP), applications), \
  358. true = lists:member(my_dep, Deps), \
  359. halt()"
  360. core-deps-fetch-git-submodule: init
  361. $i "Bootstrap a new OTP library named $(APP)"
  362. $t mkdir $(APP)/
  363. $t cp ../erlang.mk $(APP)/
  364. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  365. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  366. $t mkdir $(APP)/my_dep
  367. $t cp ../erlang.mk $(APP)/my_dep/
  368. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  369. # Create an empty file so src/ gets committed.
  370. $t touch $(APP)/my_dep/src/README
  371. $t cd $(APP)/my_dep && \
  372. git init -q && \
  373. git config user.email "testsuite@erlang.mk" && \
  374. git config user.name "test suite" && \
  375. git add . && \
  376. git commit -q --no-gpg-sign -m "Tests"
  377. $i "Add the submodule to my_dep"
  378. $t mkdir $(APP)/deps
  379. $t cd $(APP) && \
  380. git init -q && \
  381. git submodule -q add file://$(abspath $(APP)/my_dep) deps/my_dep && \
  382. git config user.email "testsuite@erlang.mk" && \
  383. git config user.name "test suite" && \
  384. git add . && \
  385. git commit -q --no-gpg-sign -m "Tests"
  386. $i "Distclean the application"
  387. $t $(MAKE) -C $(APP) distclean $v
  388. $i "Add my_dep to the list of dependencies"
  389. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = git-submodule\n"}' $(APP)/Makefile
  390. ifdef LEGACY
  391. $i "Add my_dep to the applications key in the .app.src file"
  392. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  393. endif
  394. $i "Build the application"
  395. $t $(MAKE) -C $(APP) $v
  396. $i "Check that all dependencies were fetched"
  397. $t test -d $(APP)/deps/my_dep
  398. $i "Check that the application was compiled correctly"
  399. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  400. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  401. {ok, Deps} = application:get_key($(APP), applications), \
  402. true = lists:member(my_dep, Deps), \
  403. halt()"
  404. core-deps-fetch-hex: init
  405. $i "Bootstrap a new OTP library named $(APP)"
  406. $t mkdir $(APP)/
  407. $t cp ../erlang.mk $(APP)/
  408. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  409. $i "Add Cowboy 1.0.0 to the list of dependencies"
  410. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = hex 1.0.0\n"}' $(APP)/Makefile
  411. ifdef LEGACY
  412. $i "Add Cowboy to the applications key in the .app.src file"
  413. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  414. endif
  415. $i "Build the application"
  416. $t $(MAKE) -C $(APP) $v
  417. $i "Check that all dependencies were fetched"
  418. $t test -d $(APP)/deps/cowboy
  419. $t test -d $(APP)/deps/cowlib
  420. $t test -d $(APP)/deps/ranch
  421. $i "Check that the application was compiled correctly"
  422. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  423. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  424. {ok, Deps} = application:get_key($(APP), applications), \
  425. true = lists:member(cowboy, Deps), \
  426. {ok, \"1.0.0\"} = application:get_key(cowboy, vsn), \
  427. halt()"
  428. core-deps-fetch-hg: init
  429. $i "Bootstrap a new OTP library named $(APP)"
  430. $t mkdir $(APP)/
  431. $t cp ../erlang.mk $(APP)/
  432. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  433. $i "Add Ehsa 4.0.3 to the list of dependencies"
  434. $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
  435. ifdef LEGACY
  436. $i "Add ehsa to the applications key in the .app.src file"
  437. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tehsa,\n"}' $(APP)/src/$(APP).app.src
  438. endif
  439. $i "Build the application"
  440. $t $(MAKE) -C $(APP) $v
  441. $i "Check that all dependencies were fetched"
  442. $t test -d $(APP)/deps/ehsa
  443. $i "Check that the application was compiled correctly"
  444. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  445. [ok = application:load(App) || App <- [$(APP), ehsa]], \
  446. {ok, Deps} = application:get_key($(APP), applications), \
  447. true = lists:member(ehsa, Deps), \
  448. {ok, \"4.0.3\"} = application:get_key(ehsa, vsn), \
  449. halt()"
  450. # Legacy must fail for the top-level application, but work for dependencies.
  451. core-deps-fetch-legacy: init
  452. $i "Bootstrap a new OTP library named $(APP)"
  453. $t mkdir $(APP)/
  454. $t cp ../erlang.mk $(APP)/
  455. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  456. $i "Add Cowlib as a dependency using a non-existing fetch method named oops"
  457. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib = https://github.com/ninenines/cowlib 1.0.0\n"}' $(APP)/Makefile
  458. $i "Check that building the application fails"
  459. $t ! $(MAKE) -C $(APP) $v
  460. $i "Check that building the application works with IS_DEP=1"
  461. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  462. core-deps-fetch-ln: init
  463. $i "Bootstrap a new OTP library named $(APP)"
  464. $t mkdir $(APP)/
  465. $t cp ../erlang.mk $(APP)/
  466. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  467. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  468. $t mkdir $(APP)/my_dep
  469. $t cp ../erlang.mk $(APP)/my_dep/
  470. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  471. $i "Add my_dep to the list of dependencies"
  472. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = ln $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  473. ifdef LEGACY
  474. $i "Add my_dep to the applications key in the .app.src file"
  475. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  476. endif
  477. $i "Build the application"
  478. $t $(MAKE) -C $(APP) $v
  479. $i "Check that all dependencies were fetched"
  480. $t test -d $(APP)/deps/my_dep
  481. $i "Check that the application was compiled correctly"
  482. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  483. [ok = application:load(App) || App <- [$(APP), my_dep]], \
  484. {ok, Deps} = application:get_key($(APP), applications), \
  485. true = lists:member(my_dep, Deps), \
  486. halt()"
  487. core-deps-fetch-svn: init
  488. $i "Bootstrap a new OTP library named $(APP)"
  489. $t mkdir $(APP)/
  490. $t cp ../erlang.mk $(APP)/
  491. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  492. $i "Add Cowlib 1.0.0 to the list of dependencies"
  493. $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
  494. ifdef LEGACY
  495. $i "Add Cowlib to the applications key in the .app.src file"
  496. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/src/$(APP).app.src
  497. endif
  498. $i "Build the application"
  499. $t $(MAKE) -C $(APP) $v
  500. $i "Check that all dependencies were fetched"
  501. $t test -d $(APP)/deps/cowlib
  502. $i "Check that the application was compiled correctly"
  503. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  504. [ok = application:load(App) || App <- [$(APP), cowlib]], \
  505. {ok, Deps} = application:get_key($(APP), applications), \
  506. true = lists:member(cowlib, Deps), \
  507. {ok, \"1.0.0\"} = application:get_key(cowlib, vsn), \
  508. halt()"
  509. core-deps-ignore: init
  510. $i "Bootstrap a new OTP library named $(APP)"
  511. $t mkdir $(APP)/
  512. $t cp ../erlang.mk $(APP)/
  513. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  514. $i "Add Cowboy to dependencies, Ranch to the ignore list and to test dependencies"
  515. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nIGNORE_DEPS = ranch\nTEST_DEPS = ranch\n"}' $(APP)/Makefile
  516. ifdef LEGACY
  517. $i "Add Cowboy to the applications key in the .app.src file"
  518. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  519. endif
  520. $i "Build the application"
  521. $t $(MAKE) -C $(APP) $v
  522. $i "Check that the correct dependencies were fetched"
  523. $t test -d $(APP)/deps/cowboy
  524. $t test -d $(APP)/deps/cowlib
  525. $t test ! -e $(APP)/deps/ranch
  526. $i "Build the test dependencies"
  527. $t $(MAKE) -C $(APP) test-deps $v
  528. $i "Check that the correct dependencies were fetched"
  529. $t test -d $(APP)/deps/ranch
  530. define add_dep_and_subdep
  531. $i "Bootstrap a new OTP library named $(APP)_$(1)subdep"
  532. $t mkdir $(APP)_$(1)subdep/
  533. $t cp ../erlang.mk $(APP)_$(1)subdep/
  534. $t $2 -C $(APP)_$(1)subdep --no-print-directory -f erlang.mk bootstrap-lib $$v
  535. $i "Create a Git repository for $(APP)_$(1)subdep"
  536. $t (cd $(APP)_$(1)subdep && \
  537. git init -q && \
  538. git config user.name "Testsuite" && \
  539. git config user.email "testsuite@erlang.mk" && \
  540. git add . && \
  541. git commit -q --no-gpg-sign -m "Initial commit")
  542. $i "Bootstrap a new OTP library named $(APP)_$(1)dep"
  543. $t mkdir $(APP)_$(1)dep/
  544. $t cp ../erlang.mk $(APP)_$(1)dep/
  545. $t $2 -C $(APP)_$(1)dep --no-print-directory -f erlang.mk bootstrap-lib $$v
  546. $i "Add $(APP)_$(1)subdep as a dependency"
  547. $t perl -ni.bak -e \
  548. 'print;if ($$.==1) {print "DEPS = $(1)subdep\ndep_$(1)subdep = git file://$(abspath $(APP)_$(1)subdep) master\n"}' \
  549. $(APP)_$(1)dep/Makefile
  550. $t rm $(APP)_$(1)dep/Makefile.bak
  551. $i "Create a Git repository for $(APP)_$(1)dep"
  552. $t (cd $(APP)_$(1)dep && \
  553. git init -q && \
  554. git config user.name "Testsuite" && \
  555. git config user.email "testsuite@erlang.mk" && \
  556. git add . && \
  557. git commit -q --no-gpg-sign -m "Initial commit")
  558. endef
  559. core-deps-list-deps: init
  560. # We pass $(MAKE) directly so that GNU Make can pass its context forward.
  561. # If we didn't then $(MAKE) would be expanded in the call without context.
  562. $(call add_dep_and_subdep,,$(MAKE))
  563. $(call add_dep_and_subdep,doc,$(MAKE))
  564. $(call add_dep_and_subdep,rel,$(MAKE))
  565. $(call add_dep_and_subdep,test,$(MAKE))
  566. $(call add_dep_and_subdep,shell,$(MAKE))
  567. $i "Bootstrap a new OTP library named $(APP)"
  568. $t mkdir $(APP)/
  569. $t cp ../erlang.mk $(APP)/
  570. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  571. $i "Add $(APP)-dep and $(APP)-testdep as a dependency"
  572. $t sed -i.bak '2i\
  573. DEPS = dep\
  574. DOC_DEPS = docdep\
  575. REL_DEPS = reldep\
  576. TEST_DEPS = testdep\
  577. SHELL_DEPS = shelldep\
  578. dep_dep = git file://$(abspath $(APP)_dep) master\
  579. dep_docdep = git file://$(abspath $(APP)_docdep) master\
  580. dep_reldep = git file://$(abspath $(APP)_reldep) master\
  581. dep_testdep = git file://$(abspath $(APP)_testdep) master\
  582. dep_shelldep = git file://$(abspath $(APP)_shelldep) master\
  583. ' $(APP)/Makefile
  584. $t rm $(APP)/Makefile.bak
  585. $i "Create a Git repository for $(APP)"
  586. $t (cd $(APP) && \
  587. git init -q && \
  588. git config user.name "Testsuite" && \
  589. git config user.email "testsuite@erlang.mk" && \
  590. git add . && \
  591. git commit -q --no-gpg-sign -m "Initial commit")
  592. $i "List application dependencies"
  593. $t $(MAKE) -C $(APP) --no-print-directory list-deps $v
  594. $t test -d $(APP)/deps/subdep
  595. $t printf "%s\n%s\n" $(abspath $(APP)/deps/dep $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  596. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  597. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  598. $i "List application doc dependencies"
  599. $t $(MAKE) -C $(APP) --no-print-directory list-doc-deps $v
  600. $t test -d $(APP)/deps/subdep
  601. $t test -d $(APP)/deps/docsubdep
  602. $t printf "%s\n%s\n%s\n%s\n" \
  603. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/docdep $(APP)/deps/docsubdep) \
  604. | sort > $(APP)/expected-doc-deps.txt
  605. $t cmp $(APP)/expected-doc-deps.txt $(APP)/.erlang.mk/recursive-doc-deps-list.log
  606. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  607. $i "List application rel dependencies"
  608. $t $(MAKE) -C $(APP) --no-print-directory list-rel-deps $v
  609. $t test -d $(APP)/deps/subdep
  610. $t test -d $(APP)/deps/relsubdep
  611. $t printf "%s\n%s\n%s\n%s\n" \
  612. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/reldep $(APP)/deps/relsubdep) \
  613. | sort > $(APP)/expected-rel-deps.txt
  614. $t cmp $(APP)/expected-rel-deps.txt $(APP)/.erlang.mk/recursive-rel-deps-list.log
  615. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  616. $i "List application test dependencies"
  617. $t $(MAKE) -C $(APP) --no-print-directory list-test-deps $v
  618. $t test -d $(APP)/deps/subdep
  619. $t test -d $(APP)/deps/testsubdep
  620. $t printf "%s\n%s\n%s\n%s\n" \
  621. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/testdep $(APP)/deps/testsubdep) \
  622. | sort > $(APP)/expected-test-deps.txt
  623. $t cmp $(APP)/expected-test-deps.txt $(APP)/.erlang.mk/recursive-test-deps-list.log
  624. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  625. $i "List application shell dependencies"
  626. $t $(MAKE) -C $(APP) --no-print-directory list-shell-deps $v
  627. $t test -d $(APP)/deps/subdep
  628. $t test -d $(APP)/deps/shellsubdep
  629. $t printf "%s\n%s\n%s\n%s\n" \
  630. $(abspath $(APP)/deps/dep $(APP)/deps/subdep $(APP)/deps/shelldep $(APP)/deps/shellsubdep) \
  631. | sort > $(APP)/expected-shell-deps.txt
  632. $t cmp $(APP)/expected-shell-deps.txt $(APP)/.erlang.mk/recursive-shell-deps-list.log
  633. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  634. $i "List application all dependencies (all kinds)"
  635. $t $(MAKE) -C $(APP) --no-print-directory list-deps DEP_TYPES='doc rel test shell' $v
  636. $t test -d $(APP)/deps/subdep
  637. $t test -d $(APP)/deps/docsubdep
  638. $t test -d $(APP)/deps/relsubdep
  639. $t test -d $(APP)/deps/testsubdep
  640. $t test -d $(APP)/deps/shellsubdep
  641. $t printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
  642. $(abspath \
  643. $(APP)/deps/dep $(APP)/deps/subdep \
  644. $(APP)/deps/docdep $(APP)/deps/docsubdep \
  645. $(APP)/deps/reldep $(APP)/deps/relsubdep \
  646. $(APP)/deps/testdep $(APP)/deps/testsubdep \
  647. $(APP)/deps/shelldep $(APP)/deps/shellsubdep) \
  648. | sort > $(APP)/expected-all-deps.txt
  649. $t cmp $(APP)/expected-all-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  650. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  651. core-deps-list-deps-with-apps: init
  652. # We pass $(MAKE) directly so that GNU Make can pass its context forward.
  653. # If we didn't then $(MAKE) would be expanded in the call without context.
  654. $(call add_dep_and_subdep,,$(MAKE))
  655. $i "Bootstrap a new OTP library named $(APP)"
  656. $t mkdir $(APP)/
  657. $t cp ../erlang.mk $(APP)/
  658. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  659. $i "Bootstrap another APP named $(APP)_app in $(APP) repository"
  660. $t $(MAKE) -C $(APP) --no-print-directory new-lib in=my_app $v
  661. $i "Bootstrap another APP named $(APP)_dep_app in $(APP)_dep repository"
  662. $t $(MAKE) -C $(APP)_dep --no-print-directory new-lib in=my_dep_app $v
  663. $t sed -i.bak '2i\
  664. APPS_DIR := $$(CURDIR)/apps\
  665. LOCAL_DEPS = my_dep_app ssl\
  666. ' $(APP)_dep/Makefile
  667. $t echo 'unexport APPS_DIR' >> $(APP)_dep/Makefile
  668. $t rm $(APP)_dep/Makefile.bak
  669. $t git -C $(APP)_dep add .
  670. $t git -C $(APP)_dep commit -q --no-gpg-sign -m "Add application"
  671. $i "Add $(APP)-dep as a dependency"
  672. $t sed -i.bak '2i\
  673. DEPS = dep\
  674. dep_dep = git file://$(abspath $(APP)_dep) master\
  675. ' $(APP)/Makefile
  676. $t rm $(APP)/Makefile.bak
  677. $i "Create a Git repository for $(APP)"
  678. $t (cd $(APP) && \
  679. git init -q && \
  680. git config user.name "Testsuite" && \
  681. git config user.email "testsuite@erlang.mk" && \
  682. git add . && \
  683. git commit -q --no-gpg-sign -m "Initial commit")
  684. $i "List application dependencies ($(APP)_app is missing)"
  685. $t $(MAKE) -C $(APP) --no-print-directory list-deps $v
  686. $t test -d $(APP)/deps/subdep
  687. $t printf "%s\n%s\n%s\n" $(abspath $(APP)/deps/dep $(APP)/deps/dep/apps/my_dep_app $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  688. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  689. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  690. $i "Add $(APP)_app as a dependency"
  691. $t sed -i.bak '3i\
  692. LOCAL_DEPS = my_app\
  693. ' $(APP)/Makefile
  694. $t rm $(APP)/Makefile.bak
  695. $i "List application dependencies ($(APP)_app is listed)"
  696. $t $(MAKE) -C $(APP) --no-print-directory list-deps $v
  697. $t test -d $(APP)/deps/subdep
  698. $t printf "%s\n%s\n%s\n%s\n" $(abspath $(APP)/apps/my_app $(APP)/deps/dep $(APP)/deps/dep/apps/my_dep_app $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  699. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  700. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  701. core-deps-list-deps-with-specified-full-var: init
  702. # We pass $(MAKE) directly so that GNU Make can pass its context forward.
  703. # If we didn't then $(MAKE) would be expanded in the call without context.
  704. $(call add_dep_and_subdep,,$(MAKE))
  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 $(APP)-dep as a dependency"
  710. $t sed -i.bak '2i\
  711. DEPS = dep\
  712. dep_dep = git file://$(abspath $(APP)_dep) master\
  713. ' $(APP)/Makefile
  714. $t rm $(APP)/Makefile.bak
  715. $i "Create a Git repository for $(APP)"
  716. $t (cd $(APP) && \
  717. git init -q && \
  718. git config user.name "Testsuite" && \
  719. git config user.email "testsuite@erlang.mk" && \
  720. git add . && \
  721. git commit -q --no-gpg-sign -m "Initial commit")
  722. $i "Build application"
  723. $t $(MAKE) -C $(APP) --no-print-directory $v
  724. $t test -d $(APP)/deps/subdep
  725. $i "List application dependencies without FULL"
  726. $t $(MAKE) -C $(APP) --no-print-directory list-deps $v
  727. $t printf "%s\n%s\n" $(abspath $(APP)/deps/dep $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  728. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  729. $i "List application dependencies with empty FULL"
  730. $t $(MAKE) -C $(APP) --no-print-directory list-deps FULL= $v
  731. $t printf "%s\n%s\n" $(abspath $(APP)/deps/dep $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  732. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  733. $i "List application dependencies with FULL=1"
  734. $t $(MAKE) -C $(APP) --no-print-directory list-deps FULL=1 $v
  735. $t printf "%s\n%s\n" $(abspath $(APP)/deps/dep $(APP)/deps/subdep) > $(APP)/expected-deps.txt
  736. $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/recursive-deps-list.log
  737. $t $(MAKE) -C $(APP) --no-print-directory distclean $v
  738. core-deps-makefile-change: init
  739. $i "Bootstrap a new OTP application named $(APP)"
  740. $t mkdir $(APP)/
  741. $t cp ../erlang.mk $(APP)/
  742. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  743. $i "Build the application"
  744. $t $(MAKE) -C $(APP) $v
  745. $i "Add Cowlib to the list of dependencies"
  746. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  747. ifdef LEGACY
  748. $i "Add Cowlib to the applications key in the .app.src file"
  749. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/src/$(APP).app.src
  750. endif
  751. $i "Build the application again"
  752. $t $(MAKE) -C $(APP) $v
  753. $i "Check that Cowlib was included in the .app file"
  754. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  755. ok = application:load($(APP)), \
  756. {ok, Apps} = application:get_key($(APP), applications), \
  757. true = lists:member(cowlib, Apps), \
  758. halt()."
  759. core-deps-dep-makefile-change: init
  760. $i "Bootstrap a new OTP application named $(APP)"
  761. $t mkdir $(APP)/
  762. $t cp ../erlang.mk $(APP)/
  763. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  764. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  765. $t mkdir $(APP)/my_dep
  766. $t cp ../erlang.mk $(APP)/my_dep/
  767. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  768. $i "Add my_dep to the list of dependencies"
  769. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = ln $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  770. ifdef LEGACY
  771. $i "Add my_dep to the applications key in the .app.src file"
  772. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  773. endif
  774. $i "Build the application"
  775. $t $(MAKE) -C $(APP) NO_AUTOPATCH=my_dep $v
  776. $i "Add Cowlib to the list of dependencies in my_dep"
  777. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/my_dep/Makefile
  778. ifdef LEGACY
  779. $i "Add Cowlib to the applications key in my_dep's .app.src file"
  780. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/my_dep/src/my_dep.app.src
  781. endif
  782. $i "Build the application again"
  783. $t $(MAKE) -C $(APP) $v
  784. $i "Check that Cowlib was included in my_dep's .app file"
  785. $t $(ERL) -pa $(APP)/my_dep/ebin/ -eval " \
  786. ok = application:load(my_dep), \
  787. {ok, Apps} = application:get_key(my_dep, applications), \
  788. true = lists:member(cowlib, Apps), \
  789. halt()."
  790. core-deps-mv: init
  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 Cowlib to the list of dependencies"
  796. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\n"}' $(APP)/Makefile
  797. $i "Build the application"
  798. $t $(MAKE) -C $(APP) $v
  799. $i "Check that all dependencies were fetched"
  800. $t test -d $(APP)/deps/cowlib
  801. $i "Move the application elsewhere"
  802. $t mv $(APP) $(APP)-moved
  803. $i "Build the application"
  804. $t $(MAKE) -C $(APP)-moved $v
  805. core-deps-mv-rebar: init
  806. $i "Bootstrap a new OTP library named $(APP)"
  807. $t mkdir $(APP)/
  808. $t cp ../erlang.mk $(APP)/
  809. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  810. $i "Add Lager to the list of dependencies"
  811. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\n"}' $(APP)/Makefile
  812. $i "Build the application"
  813. $t $(MAKE) -C $(APP) $v
  814. $i "Check that all dependencies were fetched"
  815. $t test -d $(APP)/deps/goldrush
  816. $t test -d $(APP)/deps/lager
  817. $i "Move the application elsewhere"
  818. $t mv $(APP) $(APP)-moved
  819. $i "Build the application"
  820. $t $(MAKE) -C $(APP)-moved $v
  821. # A lower-level dependency of the first dependency always
  822. # wins over a lower-level dependency of the second dependency.
  823. core-deps-order-first: init
  824. $i "Bootstrap a new OTP library named $(APP)"
  825. $t mkdir $(APP)/
  826. $t cp ../erlang.mk $(APP)/
  827. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  828. $i "Add Cowboy package and my_dep to the list of dependencies"
  829. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep cowboy\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  830. $i "Bootstrap a new OTP library named my_dep inside $(APP)"
  831. $t mkdir $(APP)/my_dep
  832. $t cp ../erlang.mk $(APP)/my_dep/
  833. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  834. $i "Add Cowlib 1.0.0 to the list of dependencies for my_dep"
  835. $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
  836. ifdef LEGACY
  837. $i "Add Cowboy and my_dep to the applications key in the .app.src file"
  838. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  839. endif
  840. $i "Build the application"
  841. $t $(MAKE) -C $(APP) $v
  842. $i "Check that all dependencies were fetched"
  843. $t test -d $(APP)/deps/cowboy
  844. $t test -d $(APP)/deps/cowlib
  845. $t test -d $(APP)/deps/my_dep
  846. $t test -d $(APP)/deps/ranch
  847. $i "Check that the application was compiled correctly"
  848. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  849. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, my_dep, ranch]], \
  850. {ok, Deps} = application:get_key($(APP), applications), \
  851. true = lists:member(cowboy, Deps), \
  852. {ok, \"1.0.0\"} = application:get_key(cowlib, vsn), \
  853. halt()"
  854. # A higher-level dependency always wins.
  855. core-deps-order-top: init
  856. $i "Bootstrap a new OTP library named $(APP)"
  857. $t mkdir $(APP)/
  858. $t cp ../erlang.mk $(APP)/
  859. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  860. $i "Add Cowboy package and Cowlib 1.0.0 to the list of dependencies"
  861. $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
  862. ifdef LEGACY
  863. $i "Add Cowboy to the applications key in the .app.src file"
  864. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  865. endif
  866. $i "Build the application"
  867. $t $(MAKE) -C $(APP) $v
  868. $i "Check that all dependencies were fetched"
  869. $t test -d $(APP)/deps/cowboy
  870. $t test -d $(APP)/deps/cowlib
  871. $t test -d $(APP)/deps/ranch
  872. $i "Check that the application was compiled correctly"
  873. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  874. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  875. {ok, Deps} = application:get_key($(APP), applications), \
  876. true = lists:member(cowboy, Deps), \
  877. {ok, \"1.0.0\"} = application:get_key(cowlib, vsn), \
  878. halt()"
  879. ifndef LEGACY
  880. core-deps-otp: init
  881. $i "Bootstrap a new OTP library named $(APP)"
  882. $t mkdir $(APP)/
  883. $t cp ../erlang.mk $(APP)/
  884. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  885. $i "Add Crypto to the list of OTP dependencies"
  886. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = crypto\n"}' $(APP)/Makefile
  887. $i "Build the application"
  888. $t $(MAKE) -C $(APP) $v
  889. $i "Check that no dependencies were fetched"
  890. $t test ! -e $(APP)/deps
  891. $i "Check that the application was compiled correctly"
  892. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  893. [ok = application:load(App) || App <- [$(APP), crypto]], \
  894. {ok, Deps} = application:get_key($(APP), applications), \
  895. true = lists:member(crypto, Deps), \
  896. halt()"
  897. endif
  898. core-deps-pkg: init
  899. $i "Bootstrap a new OTP library named $(APP)"
  900. $t mkdir $(APP)/
  901. $t cp ../erlang.mk $(APP)/
  902. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  903. $i "Add Cowboy to the list of dependencies"
  904. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
  905. ifdef LEGACY
  906. $i "Add Cowboy to the applications key in the .app.src file"
  907. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  908. endif
  909. $i "Build the application"
  910. $t $(MAKE) -C $(APP) $v
  911. $i "Check that all dependencies were fetched"
  912. $t test -d $(APP)/deps/cowboy
  913. $t test -d $(APP)/deps/cowlib
  914. $t test -d $(APP)/deps/ranch
  915. $i "Check that the application was compiled correctly"
  916. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  917. [ok = application:load(App) || App <- [$(APP), cowboy, cowlib, ranch]], \
  918. {ok, Deps} = application:get_key($(APP), applications), \
  919. true = lists:member(cowboy, Deps), \
  920. halt()"
  921. core-deps-rel: init
  922. $i "Bootstrap a new release-enabled OTP library named $(APP)"
  923. $t mkdir $(APP)/
  924. $t cp ../erlang.mk $(APP)/
  925. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib bootstrap-rel $v
  926. $i "Add Recon to the list of release dependencies"
  927. $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = recon\n"}' $(APP)/Makefile
  928. $i "Add Recon to the relx.config file"
  929. $t $(ERL) -eval " \
  930. {ok, Conf0} = file:consult(\"$(APP)/relx.config\"), \
  931. Conf = lists:keyreplace(release, 1, Conf0, {release, {$(APP)_release, \"1\"}, [$(APP), recon]}), \
  932. ok = file:write_file(\"$(APP)/relx.config\", \
  933. lists:map(fun(Term) -> io_lib:format(\"~p.~n\", [Term]) end, Conf)), \
  934. halt()"
  935. $i "Build the application and its dependencies"
  936. $t $(MAKE) -C $(APP) deps app $v
  937. $i "Check that no dependencies were fetched"
  938. $t test ! -e $(APP)/deps
  939. $i "Check that the application was compiled correctly"
  940. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  941. [ok = application:load(App) || App <- [$(APP)]], \
  942. {ok, Deps} = application:get_key($(APP), applications), \
  943. false = lists:member(recon, Deps), \
  944. halt()"
  945. $i "Build the release"
  946. $t $(MAKE) -C $(APP) $v
  947. $i "Check that all dependencies were fetched"
  948. $t test -d $(APP)/deps/recon
  949. $i "Check that the application was compiled correctly"
  950. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  951. [ok = application:load(App) || App <- [$(APP), recon]], \
  952. {ok, Deps} = application:get_key($(APP), applications), \
  953. false = lists:member(recon, Deps), \
  954. halt()"
  955. # @todo Add check for MSYS2 when releases under Windows become usable.
  956. # $i "Start the release and check that Recon is loaded"
  957. ifeq ($(PLATFORM),msys2)
  958. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd install $v
  959. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd start $v
  960. # $t test -n "`$(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd rpcterms \
  961. # application loaded_applications | grep recon`"
  962. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd stop $v
  963. # $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd uninstall $v
  964. else
  965. $i "Start the release and check that Recon is loaded"
  966. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  967. $t apps="Node is not running!"; \
  968. while test "$$apps" = "Node is not running!"; do \
  969. apps=$$($(APP)/_rel/$(APP)_release/bin/$(APP)_release \
  970. rpcterms \ application loaded_applications); \
  971. done; \
  972. echo "$$apps" | grep -q recon
  973. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  974. endif
  975. core-deps-search: init
  976. $i "Bootstrap a new OTP library named $(APP)"
  977. $t mkdir $(APP)/
  978. $t cp ../erlang.mk $(APP)/
  979. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  980. $i "Run 'make search' and check that it prints packages"
  981. $t test -n "`$(MAKE) -C $(APP) search`"
  982. $i "Run 'make search q=cowboy' and check that it prints packages"
  983. $t test -n "`$(MAKE) -C $(APP) search q=cowboy`"
  984. core-deps-shell: init
  985. $i "Bootstrap a new OTP library named $(APP)"
  986. $t mkdir $(APP)/
  987. $t cp ../erlang.mk $(APP)/
  988. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  989. $i "Add TDDReloader to the list of shell dependencies"
  990. $t perl -ni.bak -e 'print;if ($$.==1) {print "SHELL_DEPS = tddreloader\n"}' $(APP)/Makefile
  991. $i "Build the application and its dependencies"
  992. $t $(MAKE) -C $(APP) deps app $v
  993. $i "Check that no dependencies were fetched"
  994. $t test ! -e $(APP)/deps
  995. $i "Check that the application was compiled correctly"
  996. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  997. [ok = application:load(App) || App <- [$(APP)]], \
  998. {ok, Deps} = application:get_key($(APP), applications), \
  999. false = lists:member(tddreloader, Deps), \
  1000. halt()"
  1001. $i "Run the shell"
  1002. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval \" \
  1003. ok = application:load($(APP)), \
  1004. ok = application:load(tddreloader), \
  1005. halt()\"" $v
  1006. $i "Check that all dependencies were fetched"
  1007. $t test -d $(APP)/deps/tddreloader
  1008. $i "Check that the application was compiled correctly"
  1009. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1010. [ok = application:load(App) || App <- [$(APP), tddreloader]], \
  1011. {ok, Deps} = application:get_key($(APP), applications), \
  1012. false = lists:member(tddreloader, Deps), \
  1013. halt()"
  1014. core-deps-skip: init
  1015. $i "Bootstrap a new OTP library named $(APP)"
  1016. $t mkdir $(APP)/
  1017. $t cp ../erlang.mk $(APP)/
  1018. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1019. $i "Add Cowboy to the list of dependencies"
  1020. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
  1021. ifdef LEGACY
  1022. $i "Add Cowboy to the applications key in the .app.src file"
  1023. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  1024. endif
  1025. $i "Build the application with SKIP_DEPS=1"
  1026. $t $(MAKE) -C $(APP) SKIP_DEPS=1 $v
  1027. $i "Check that no dependencies were fetched"
  1028. $t test ! -e $(APP)/deps
  1029. $i "Build the application"
  1030. $t $(MAKE) -C $(APP) $v
  1031. $i "Check that all dependencies were fetched"
  1032. $t test -d $(APP)/deps/cowlib
  1033. $t test -d $(APP)/deps/cowboy
  1034. $t test -d $(APP)/deps/ranch
  1035. $i "Distclean with SKIP_DEPS=1"
  1036. $t $(MAKE) -C $(APP) distclean SKIP_DEPS=1 $v
  1037. $i "Check that no dependencies were removed"
  1038. $t test -d $(APP)/deps/cowlib
  1039. $t test -d $(APP)/deps/cowboy
  1040. $t test -d $(APP)/deps/ranch
  1041. core-deps-test: init
  1042. $i "Bootstrap a new OTP library named $(APP)"
  1043. $t mkdir $(APP)/
  1044. $t cp ../erlang.mk $(APP)/
  1045. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1046. $i "Generate .erl files"
  1047. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1048. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1049. $i "Add triq to the list of test dependencies"
  1050. $t perl -ni.bak -e 'print;if ($$.==1) {print "TEST_DEPS = triq\n"}' $(APP)/Makefile
  1051. $i "Build the application and its dependencies"
  1052. $t $(MAKE) -C $(APP) deps app $v
  1053. $i "Check that no dependencies were fetched"
  1054. $t test ! -e $(APP)/deps
  1055. $i "Check that the application was compiled correctly"
  1056. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1057. [ok = application:load(App) || App <- [$(APP)]], \
  1058. {ok, Deps} = application:get_key($(APP), applications), \
  1059. false = lists:member(triq, Deps), \
  1060. halt()"
  1061. $i "Run tests"
  1062. $t $(MAKE) -C $(APP) tests $v
  1063. $i "Check that all dependencies were fetched"
  1064. $t test -d $(APP)/deps/triq
  1065. $i "Check that the application was compiled correctly"
  1066. $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval " \
  1067. [ok = application:load(App) || App <- [$(APP), triq]], \
  1068. {ok, Deps} = application:get_key($(APP), applications), \
  1069. false = lists:member(triq, Deps), \
  1070. halt()"