core_deps.mk 46 KB

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