core_app.mk 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684
  1. # Core: Building applications.
  2. CORE_APP_TARGETS = $(call list_targets,core-app)
  3. .PHONY: core-app $(CORE_APP_TARGETS)
  4. core-app: $(CORE_APP_TARGETS)
  5. ifdef LEGACY
  6. core-app-appsrc-change: build clean
  7. $i "Bootstrap a new OTP application named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  11. $i "Build the application"
  12. $t $(MAKE) -C $(APP) $v
  13. $i "Touch the .app.src file; check that only the .app file gets rebuilt"
  14. $t printf "%s\n" $(APP)/ebin/$(APP).app > $(APP)/EXPECT
  15. $t $(SLEEP)
  16. $t touch $(APP)/src/$(APP).app.src
  17. $t $(SLEEP)
  18. $t $(MAKE) -C $(APP) $v
  19. $t find $(APP) -type f -newer $(APP)/src/$(APP).app.src | sort | diff $(APP)/EXPECT -
  20. $t rm $(APP)/EXPECT
  21. endif
  22. core-app-asn1: build clean
  23. $i "Bootstrap a new OTP library named $(APP)"
  24. $t mkdir $(APP)/
  25. $t cp ../erlang.mk $(APP)/
  26. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  27. $i "Download .asn1 files from Erlang/OTP"
  28. $t mkdir $(APP)/asn1/
  29. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  30. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  31. $i "Generate .erl files dependent from headers generated by .asn1 files"
  32. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  33. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  34. $i "Generate an unrelated .hrl file"
  35. $t mkdir $(APP)/include/
  36. $t touch $(APP)/include/unrelated.hrl
  37. $i "Build the application"
  38. $t $(MAKE) -C $(APP) $v
  39. $i "Check that all compiled files exist"
  40. $t test -f $(APP)/$(APP).d
  41. $t test -f $(APP)/ebin/$(APP).app
  42. $t test -f $(APP)/ebin/CAP.beam
  43. $t test -f $(APP)/ebin/Def.beam
  44. $t test -f $(APP)/ebin/use_cap.beam
  45. $t test -f $(APP)/ebin/use_def.beam
  46. $t test -f $(APP)/include/CAP.asn1db
  47. $t test -f $(APP)/include/CAP.hrl
  48. $t test -f $(APP)/include/Def.asn1db
  49. $t test -f $(APP)/include/Def.hrl
  50. $t test -f $(APP)/src/CAP.erl
  51. $t test -f $(APP)/src/Def.erl
  52. $i "Check that the application was compiled correctly"
  53. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  54. ok = application:start($(APP)), \
  55. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  56. = application:get_key($(APP), modules), \
  57. [{module, M} = code:load_file(M) || M <- Mods], \
  58. halt()"
  59. $i "Touch one .asn1 file; check that only required files are rebuilt"
  60. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  61. $t printf "%s\n" \
  62. $(APP)/$(APP).d \
  63. $(APP)/ebin/$(APP).app \
  64. $(APP)/ebin/CAP.beam \
  65. $(APP)/ebin/use_cap.beam \
  66. $(APP)/include/CAP.asn1db \
  67. $(APP)/include/CAP.hrl \
  68. $(APP)/src/CAP.erl \
  69. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  70. $t $(SLEEP)
  71. $t touch $(APP)/asn1/CAP.asn1
  72. $t $(SLEEP)
  73. $t $(MAKE) -C $(APP) $v
  74. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  75. $t rm $(APP)/EXPECT
  76. $i "Check that the application was compiled correctly"
  77. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  78. ok = application:start($(APP)), \
  79. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  80. = application:get_key($(APP), modules), \
  81. [{module, M} = code:load_file(M) || M <- Mods], \
  82. halt()"
  83. $i "Clean the application"
  84. $t $(MAKE) -C $(APP) clean $v
  85. $i "Check that source files still exist"
  86. $t test -f $(APP)/Makefile
  87. $t test -f $(APP)/erlang.mk
  88. $t test -f $(APP)/asn1/CAP.asn1
  89. $t test -f $(APP)/asn1/Def.asn1
  90. $t test -f $(APP)/include/unrelated.hrl
  91. ifdef LEGACY
  92. $t test -f $(APP)/src/$(APP).app.src
  93. endif
  94. $t test -f $(APP)/src/use_cap.erl
  95. $t test -f $(APP)/src/use_def.erl
  96. $i "Check that all build artifacts are removed, including intermediates"
  97. $t test ! -e $(APP)/$(APP).d
  98. $t test ! -e $(APP)/ebin/
  99. $t test ! -e $(APP)/include/CAP.asn1db
  100. $t test ! -e $(APP)/include/CAP.hrl
  101. $t test ! -e $(APP)/include/Def.asn1db
  102. $t test ! -e $(APP)/include/Def.hrl
  103. $t test ! -e $(APP)/src/CAP.erl
  104. $t test ! -e $(APP)/src/Def.erl
  105. $i "Build the application again"
  106. $t $(MAKE) -C $(APP) $v
  107. $i "Check that all compiled files exist"
  108. $t test -f $(APP)/$(APP).d
  109. $t test -f $(APP)/ebin/$(APP).app
  110. $t test -f $(APP)/ebin/CAP.beam
  111. $t test -f $(APP)/ebin/Def.beam
  112. $t test -f $(APP)/ebin/use_cap.beam
  113. $t test -f $(APP)/ebin/use_def.beam
  114. $t test -f $(APP)/include/CAP.asn1db
  115. $t test -f $(APP)/include/CAP.hrl
  116. $t test -f $(APP)/include/Def.asn1db
  117. $t test -f $(APP)/include/Def.hrl
  118. $t test -f $(APP)/src/CAP.erl
  119. $t test -f $(APP)/src/Def.erl
  120. $i "Check that the application was compiled correctly"
  121. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  122. ok = application:start($(APP)), \
  123. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  124. = application:get_key($(APP), modules), \
  125. [{module, M} = code:load_file(M) || M <- Mods], \
  126. halt()"
  127. $i "Clean the application"
  128. $t $(MAKE) -C $(APP) clean $v
  129. $i "Build the application with ERLC_ASN1_OPTS set"
  130. $t echo "ERLC_ASN1_OPTS += +'{record_name_prefix,\"FOO-\"}'" >> $(APP)/Makefile
  131. $t $(MAKE) -C $(APP) $v
  132. $i "Check that the application was built with ERLC_ASN1_OPTS set"
  133. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  134. Attrs = 'Def':module_info(attributes), \
  135. Asn1Info = proplists:get_value(asn1_info, Attrs), \
  136. Opts = proplists:get_value(options, Asn1Info), \
  137. true = lists:member({record_name_prefix, \"FOO-\"}, Opts), \
  138. halt()"
  139. core-app-asn1-maps: build clean
  140. $i "Bootstrap a new OTP library named $(APP)"
  141. $t mkdir $(APP)/
  142. $t cp ../erlang.mk $(APP)/
  143. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  144. $i "Set ERLC_ASN1_OPTS = +maps in the Makefile"
  145. $t perl -ni.bak -e 'print;if ($$.==1) {print "ERLC_ASN1_OPTS = +maps\n"}' $(APP)/Makefile
  146. $i "Download .asn1 files from Erlang/OTP"
  147. $t mkdir $(APP)/asn1/
  148. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  149. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  150. $i "Build the application"
  151. $t $(MAKE) -C $(APP) $v
  152. $i "Check that all compiled files exist"
  153. $t test -f $(APP)/$(APP).d
  154. $t test -f $(APP)/ebin/$(APP).app
  155. $t test -f $(APP)/ebin/CAP.beam
  156. $t test -f $(APP)/ebin/Def.beam
  157. $t test -f $(APP)/include/CAP.asn1db
  158. $t ! test -e $(APP)/include/CAP.hrl
  159. $t test -f $(APP)/include/Def.asn1db
  160. $t ! test -e $(APP)/include/Def.hrl
  161. $t test -f $(APP)/src/CAP.erl
  162. $t test -f $(APP)/src/Def.erl
  163. $i "Check that the application was compiled correctly"
  164. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  165. ok = application:start($(APP)), \
  166. {ok, Mods = ['CAP', 'Def']} \
  167. = application:get_key($(APP), modules), \
  168. [{module, M} = code:load_file(M) || M <- Mods], \
  169. halt()"
  170. core-app-auto-git-id: build clean
  171. $i "Bootstrap a new OTP library named $(APP)"
  172. $t mkdir $(APP)/
  173. $t cp ../erlang.mk $(APP)/
  174. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  175. $i "Make it a git repository"
  176. $t cd $(APP) && \
  177. git init -q && \
  178. git config user.email "testsuite@erlang.mk" && \
  179. git config user.name "test suite" && \
  180. git add . && \
  181. git commit -q --no-gpg-sign -m "Tests"
  182. $i "Build the application"
  183. $t $(MAKE) -C $(APP) $v
  184. ifdef LEGACY
  185. # Legacy replaces {id, "git"} always regardless of built as a dependency.
  186. $i "Check that the generated .app file has an id key"
  187. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  188. ok = application:start($(APP)), \
  189. {ok, ID} = application:get_key($(APP), id), \
  190. true = ID =/= [], \
  191. halt()"
  192. else
  193. # If there is no .app.src though, only fill in id when built as a dependency.
  194. $i "Check that the generated .app file has no id key"
  195. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  196. ok = application:start($(APP)), \
  197. {ok, []} = application:get_key($(APP), id), \
  198. halt()"
  199. endif
  200. $i "Clean the application"
  201. $t $(MAKE) -C $(APP) clean $v
  202. $i "Build the application with IS_DEP=1"
  203. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  204. $i "Check that the generated .app file has an id key"
  205. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  206. ok = application:start($(APP)), \
  207. {ok, ID} = application:get_key($(APP), id), \
  208. true = ID =/= [], \
  209. halt()"
  210. ifndef LEGACY
  211. core-app-env: build clean
  212. $i "Bootstrap a new OTP library named $(APP)"
  213. $t mkdir $(APP)/
  214. $t cp ../erlang.mk $(APP)/
  215. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  216. $i "Define PROJECT_ENV"
  217. $t echo "PROJECT_ENV = [{test_key, test_value}]" >> $(APP)/Makefile
  218. $i "Build the application"
  219. $t $(MAKE) -C $(APP) $v
  220. $i "Check that the application was compiled correctly"
  221. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  222. ok = application:load($(APP)), \
  223. {ok, test_value} = application:get_env($(APP), test_key), \
  224. halt()"
  225. $i "Define PROJECT_ENV with escape in string, special char"
  226. $t echo "PROJECT_ENV = [{test_atom, '\\\$$\$$test'}, {test_key, \"\\\"test_\\tvalue\\\"\"}]" >> $(APP)/Makefile
  227. $i "Build the application"
  228. $t $(MAKE) -C $(APP) $v
  229. $i "Check that the application was compiled correctly"
  230. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  231. ok = application:load($(APP)), \
  232. {ok, \"\\\"test_\\tvalue\\\"\"} = application:get_env($(APP), test_key), \
  233. {ok, '\\\$$test'} = application:get_env($(APP), test_atom), \
  234. halt()"
  235. endif
  236. core-app-erlc-exclude: build clean
  237. $i "Bootstrap a new OTP library named $(APP)"
  238. $t mkdir $(APP)/
  239. $t cp ../erlang.mk $(APP)/
  240. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  241. $i "Generate .erl files"
  242. $t echo "-module(boy)." > $(APP)/src/boy.erl
  243. $t echo "-module(girl)." > $(APP)/src/girl.erl
  244. $i "Exclude boy.erl from the compilation"
  245. $t echo "ERLC_EXCLUDE = boy" >> $(APP)/Makefile
  246. $i "Build the application"
  247. $t $(MAKE) -C $(APP) $v
  248. $i "Check that boy.erl was not compiled"
  249. $t test ! -e $(APP)/ebin/boy.beam
  250. $i "Check that the application was compiled correctly (without boy.erl)"
  251. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  252. ok = application:start($(APP)), \
  253. {ok, Mods = [girl]} \
  254. = application:get_key($(APP), modules), \
  255. [{module, M} = code:load_file(M) || M <- Mods], \
  256. halt()"
  257. core-app-erlc-opts: build clean
  258. $i "Bootstrap a new OTP library named $(APP)"
  259. $t mkdir $(APP)/
  260. $t cp ../erlang.mk $(APP)/
  261. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  262. $i "Define an empty ERLC_OPTS (without debug_info)"
  263. $t echo "ERLC_OPTS =" >> $(APP)/Makefile
  264. $i "Generate .erl files"
  265. $t echo "-module(boy)." > $(APP)/src/boy.erl
  266. $t echo "-module(girl)." > $(APP)/src/girl.erl
  267. $i "Build the application"
  268. $t $(MAKE) -C $(APP) $v
  269. $i "Check that the application was compiled correctly (without debug_info)"
  270. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  271. ok = application:start($(APP)), \
  272. {ok, Mods = [boy, girl]} \
  273. = application:get_key($(APP), modules), \
  274. [{module, M} = code:load_file(M) || M <- Mods], \
  275. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  276. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  277. halt()"
  278. core-app-erlc-opts-filter: build clean
  279. $i "Bootstrap a new OTP library named $(APP)"
  280. $t mkdir $(APP)/
  281. $t cp ../erlang.mk $(APP)/
  282. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  283. $i "Define ERLC_OPTS filtering out debug_info"
  284. $t echo "ERLC_OPTS := \$$(filter-out +debug_info,\$$(ERLC_OPTS))" >> $(APP)/Makefile
  285. $i "Generate .erl files"
  286. $t echo "-module(boy)." > $(APP)/src/boy.erl
  287. $t echo "-module(girl)." > $(APP)/src/girl.erl
  288. $i "Build the application"
  289. $t $(MAKE) -C $(APP) $v
  290. $i "Check that the application was compiled correctly (without debug_info)"
  291. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  292. ok = application:start($(APP)), \
  293. {ok, Mods = [boy, girl]} \
  294. = application:get_key($(APP), modules), \
  295. [{module, M} = code:load_file(M) || M <- Mods], \
  296. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  297. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  298. halt()"
  299. core-app-error: build clean
  300. $i "Bootstrap a new OTP library named $(APP)"
  301. $t mkdir $(APP)/
  302. $t cp ../erlang.mk $(APP)/
  303. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  304. $i "Generate a bad .erl files"
  305. $t touch $(APP)/src/breaking.erl
  306. $i "Generate unrelated .erl files"
  307. $t echo "-module(boy)." > $(APP)/src/boy.erl
  308. $t echo "-module(girl)." > $(APP)/src/girl.erl
  309. $i "Check that trying to build returns non-zero"
  310. $t ! $(MAKE) -C $(APP) $v
  311. ifndef LEGACY
  312. core-app-extra-keys: build clean
  313. $i "Bootstrap a new OTP library named $(APP)"
  314. $t mkdir $(APP)/
  315. $t cp ../erlang.mk $(APP)/
  316. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  317. $i "Define PROJECT_APP_EXTRA_KEYS"
  318. $t printf "define PROJECT_APP_EXTRA_KEYS\n\t{maxT, 10000},\n\t{non_standard_key, test_value}\nendef\n" >> $(APP)/Makefile
  319. $i "Build the application"
  320. $t $(MAKE) -C $(APP) $v
  321. $i "Check that the application was compiled correctly"
  322. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  323. ok = application:load($(APP)), \
  324. {ok, 10000} = application:get_key($(APP), maxT), \
  325. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  326. {ok, [App]} = file:consult(AppFile), \
  327. {application, $(APP), Props} = App, \
  328. test_value = proplists:get_value(non_standard_key, Props),\
  329. halt()"
  330. $i "Define PROJECT_APP_EXTRA_KEYS with escape in string, special char"
  331. $t echo "PROJECT_APP_EXTRA_KEYS = {non_standard_atom, '\\\$$\$$my_app'}, {non_standard_string, \"\\\"test_\\tvalue\\\"\"}" >> $(APP)/Makefile
  332. $i "Build the application"
  333. $t $(MAKE) -C $(APP) $v
  334. $i "Check that the application was compiled correctly"
  335. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  336. ok = application:load($(APP)), \
  337. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  338. {ok, [App]} = file:consult(AppFile), \
  339. {application, $(APP), Props} = App, \
  340. '\\\$$my_app' = proplists:get_value(non_standard_atom, Props),\
  341. \"\\\"test_\\tvalue\\\"\" = proplists:get_value(non_standard_string, Props),\
  342. halt()"
  343. endif
  344. core-app-generate-erl: build clean
  345. $i "Bootstrap a new OTP library named $(APP)"
  346. $t mkdir $(APP)/
  347. $t cp ../erlang.mk $(APP)/
  348. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  349. $i "Create a fake script file to be used as dependency"
  350. $t touch $(APP)/script.sh
  351. $i "Append rules to the Makefile to generate a .erl module"
  352. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  353. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  354. $i "Generate unrelated .erl files"
  355. $t echo "-module(boy)." > $(APP)/src/boy.erl
  356. $t echo "-module(girl)." > $(APP)/src/girl.erl
  357. $i "Build the application"
  358. $t $(MAKE) -C $(APP) $v
  359. $i "Check that all compiled files exist"
  360. $t test -f $(APP)/$(APP).d
  361. $t test -f $(APP)/ebin/$(APP).app
  362. $t test -f $(APP)/ebin/boy.beam
  363. $t test -f $(APP)/ebin/generated.beam
  364. $t test -f $(APP)/ebin/girl.beam
  365. $t test -f $(APP)/src/generated.erl
  366. $i "Check that the application was compiled correctly"
  367. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  368. ok = application:start($(APP)), \
  369. {ok, Mods = [boy, generated, girl]} \
  370. = application:get_key($(APP), modules), \
  371. [{module, M} = code:load_file(M) || M <- Mods], \
  372. halt()"
  373. $i "Touch the script file; check that only required files are rebuilt"
  374. $t printf "%s\n" \
  375. $(APP)/$(APP).d \
  376. $(APP)/ebin/$(APP).app \
  377. $(APP)/ebin/generated.beam \
  378. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  379. $t $(SLEEP)
  380. $t touch $(APP)/script.sh
  381. $t $(SLEEP)
  382. $t $(MAKE) -C $(APP) $v
  383. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  384. $t rm $(APP)/EXPECT
  385. $i "Check that the application was compiled correctly"
  386. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  387. ok = application:start($(APP)), \
  388. {ok, Mods = [boy, generated, girl]} \
  389. = application:get_key($(APP), modules), \
  390. [{module, M} = code:load_file(M) || M <- Mods], \
  391. halt()"
  392. $i "Clean the application"
  393. $t $(MAKE) -C $(APP) clean $v
  394. $i "Check that source files still exist"
  395. $t test -f $(APP)/Makefile
  396. $t test -f $(APP)/erlang.mk
  397. $t test -f $(APP)/script.sh
  398. ifdef LEGACY
  399. $t test -f $(APP)/src/$(APP).app.src
  400. endif
  401. $t test -f $(APP)/src/boy.erl
  402. $t test -f $(APP)/src/girl.erl
  403. $i "Check that the generated .erl file still exists"
  404. $t test -f $(APP)/src/generated.erl
  405. $i "Check that all build artifacts are removed"
  406. $t test ! -e $(APP)/$(APP).d
  407. $t test ! -e $(APP)/ebin/
  408. $i "Add a rule to remove the generated .erl file on clean"
  409. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  410. $i "Clean the application again"
  411. $t $(MAKE) -C $(APP) clean $v
  412. $i "Check that the generated .erl file was removed"
  413. $t test ! -e $(APP)/src/generated.erl
  414. $i "Build the application again"
  415. $t $(MAKE) -C $(APP) $v
  416. $i "Check that all compiled files exist"
  417. $t test -f $(APP)/$(APP).d
  418. $t test -f $(APP)/ebin/$(APP).app
  419. $t test -f $(APP)/ebin/boy.beam
  420. $t test -f $(APP)/ebin/generated.beam
  421. $t test -f $(APP)/ebin/girl.beam
  422. $t test -f $(APP)/src/generated.erl
  423. $i "Check that the application was compiled correctly"
  424. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  425. ok = application:start($(APP)), \
  426. {ok, Mods = [boy, generated, girl]} \
  427. = application:get_key($(APP), modules), \
  428. [{module, M} = code:load_file(M) || M <- Mods], \
  429. halt()"
  430. core-app-generate-erl-include: build clean
  431. $i "Bootstrap a new OTP library named $(APP)"
  432. $t mkdir $(APP)/
  433. $t cp ../erlang.mk $(APP)/
  434. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  435. $i "Create a fake script file to be used as dependency"
  436. $t touch $(APP)/script.sh
  437. $i "Append rules to the Makefile to generate a .erl module"
  438. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  439. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  440. $i "Generate the .hrl file"
  441. $t mkdir $(APP)/include/
  442. $t touch $(APP)/include/included.hrl
  443. $i "Generate unrelated .erl files"
  444. $t echo "-module(boy)." > $(APP)/src/boy.erl
  445. $t echo "-module(girl)." > $(APP)/src/girl.erl
  446. $i "Build the application"
  447. $t $(MAKE) -C $(APP) $v
  448. $i "Check that all compiled files exist"
  449. $t test -f $(APP)/$(APP).d
  450. $t test -f $(APP)/ebin/$(APP).app
  451. $t test -f $(APP)/ebin/boy.beam
  452. $t test -f $(APP)/ebin/generated.beam
  453. $t test -f $(APP)/ebin/girl.beam
  454. $t test -f $(APP)/src/generated.erl
  455. $i "Check that the application was compiled correctly"
  456. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  457. ok = application:start($(APP)), \
  458. {ok, Mods = [boy, generated, girl]} \
  459. = application:get_key($(APP), modules), \
  460. [{module, M} = code:load_file(M) || M <- Mods], \
  461. halt()"
  462. $i "Touch the .hrl file; check that only required files are rebuilt"
  463. $t printf "%s\n" \
  464. $(APP)/$(APP).d \
  465. $(APP)/ebin/$(APP).app \
  466. $(APP)/ebin/generated.beam \
  467. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  468. $t $(SLEEP)
  469. $t touch $(APP)/include/included.hrl
  470. $t $(SLEEP)
  471. $t $(MAKE) -C $(APP) $v
  472. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  473. $t rm $(APP)/EXPECT
  474. $i "Check that the application was compiled correctly"
  475. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  476. ok = application:start($(APP)), \
  477. {ok, Mods = [boy, generated, girl]} \
  478. = application:get_key($(APP), modules), \
  479. [{module, M} = code:load_file(M) || M <- Mods], \
  480. halt()"
  481. core-app-generate-erl-prepend: build clean
  482. $i "Bootstrap a new OTP library named $(APP)"
  483. $t mkdir $(APP)/
  484. $t cp ../erlang.mk $(APP)/
  485. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  486. $i "Create a fake script file to be used as dependency"
  487. $t touch $(APP)/script.sh
  488. $i "Generate a Makefile and prepend rules that generate a .erl module"
  489. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  490. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  491. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  492. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  493. $t echo "include erlang.mk" >> $(APP)/Makefile
  494. $i "Generate unrelated .erl files"
  495. $t echo "-module(boy)." > $(APP)/src/boy.erl
  496. $t echo "-module(girl)." > $(APP)/src/girl.erl
  497. $i "Build the application"
  498. $t $(MAKE) -C $(APP) $v
  499. $i "Check that all compiled files exist"
  500. $t test -f $(APP)/$(APP).d
  501. $t test -f $(APP)/ebin/$(APP).app
  502. $t test -f $(APP)/ebin/boy.beam
  503. $t test -f $(APP)/ebin/generated.beam
  504. $t test -f $(APP)/ebin/girl.beam
  505. $t test -f $(APP)/src/generated.erl
  506. $i "Check that the application was compiled correctly"
  507. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  508. ok = application:start($(APP)), \
  509. {ok, Mods = [boy, generated, girl]} \
  510. = application:get_key($(APP), modules), \
  511. [{module, M} = code:load_file(M) || M <- Mods], \
  512. halt()"
  513. $i "Touch the script file; check that only required files are rebuilt"
  514. $t printf "%s\n" \
  515. $(APP)/$(APP).d \
  516. $(APP)/ebin/$(APP).app \
  517. $(APP)/ebin/generated.beam \
  518. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  519. $t $(SLEEP)
  520. $t touch $(APP)/script.sh
  521. $t $(SLEEP)
  522. $t $(MAKE) -C $(APP) $v
  523. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  524. $t rm $(APP)/EXPECT
  525. $i "Check that the application was compiled correctly"
  526. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  527. ok = application:start($(APP)), \
  528. {ok, Mods = [boy, generated, girl]} \
  529. = application:get_key($(APP), modules), \
  530. [{module, M} = code:load_file(M) || M <- Mods], \
  531. halt()"
  532. $i "Clean the application"
  533. $t $(MAKE) -C $(APP) clean $v
  534. $i "Check that source files still exist"
  535. $t test -f $(APP)/Makefile
  536. $t test -f $(APP)/erlang.mk
  537. $t test -f $(APP)/script.sh
  538. ifdef LEGACY
  539. $t test -f $(APP)/src/$(APP).app.src
  540. endif
  541. $t test -f $(APP)/src/boy.erl
  542. $t test -f $(APP)/src/girl.erl
  543. $i "Check that the generated .erl file still exists"
  544. $t test -f $(APP)/src/generated.erl
  545. $i "Check that all build artifacts are removed"
  546. $t test ! -e $(APP)/$(APP).d
  547. $t test ! -e $(APP)/ebin/
  548. $i "Add a rule to remove the generated .erl file on clean"
  549. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  550. $i "Clean the application again"
  551. $t $(MAKE) -C $(APP) clean $v
  552. $i "Check that the generated .erl file was removed"
  553. $t test ! -e $(APP)/src/generated.erl
  554. $i "Build the application again"
  555. $t $(MAKE) -C $(APP) $v
  556. $i "Check that all compiled files exist"
  557. $t test -f $(APP)/$(APP).d
  558. $t test -f $(APP)/ebin/$(APP).app
  559. $t test -f $(APP)/ebin/boy.beam
  560. $t test -f $(APP)/ebin/generated.beam
  561. $t test -f $(APP)/ebin/girl.beam
  562. $t test -f $(APP)/src/generated.erl
  563. $i "Check that the application was compiled correctly"
  564. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  565. ok = application:start($(APP)), \
  566. {ok, Mods = [boy, generated, girl]} \
  567. = application:get_key($(APP), modules), \
  568. [{module, M} = code:load_file(M) || M <- Mods], \
  569. halt()"
  570. core-app-hrl: build clean
  571. $i "Bootstrap a new OTP library named $(APP)"
  572. $t mkdir $(APP)/
  573. $t cp ../erlang.mk $(APP)/
  574. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  575. $i "Generate .hrl files"
  576. $t mkdir $(APP)/include/
  577. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  578. $i "Generate .erl files dependent from headers"
  579. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  580. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  581. $i "Build the application"
  582. $t $(MAKE) -C $(APP) $v
  583. $i "Check that all compiled files exist"
  584. $t test -f $(APP)/$(APP).d
  585. $t test -f $(APP)/ebin/$(APP).app
  586. $t test -f $(APP)/ebin/use_blue.beam
  587. $t test -f $(APP)/ebin/use_red.beam
  588. $i "Check that the application was compiled correctly"
  589. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  590. ok = application:start($(APP)), \
  591. {ok, Mods = [use_blue, use_red]} \
  592. = application:get_key($(APP), modules), \
  593. [{module, M} = code:load_file(M) || M <- Mods], \
  594. halt()"
  595. $i "Touch one .hrl file; check that only required files are rebuilt"
  596. # The use_red.erl gets touched because of its dependency to red.hrl.
  597. $t printf "%s\n" \
  598. $(APP)/$(APP).d \
  599. $(APP)/ebin/$(APP).app \
  600. $(APP)/ebin/use_red.beam \
  601. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  602. $t $(SLEEP)
  603. $t touch $(APP)/include/red.hrl
  604. $t $(SLEEP)
  605. $t $(MAKE) -C $(APP) $v
  606. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  607. $t rm $(APP)/EXPECT
  608. $i "Check that the application was compiled correctly"
  609. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  610. ok = application:start($(APP)), \
  611. {ok, Mods = [use_blue, use_red]} \
  612. = application:get_key($(APP), modules), \
  613. [{module, M} = code:load_file(M) || M <- Mods], \
  614. halt()"
  615. $i "Clean the application"
  616. $t $(MAKE) -C $(APP) clean $v
  617. $i "Check that source files still exist"
  618. $t test -f $(APP)/Makefile
  619. $t test -f $(APP)/erlang.mk
  620. $t test -f $(APP)/include/blue.hrl
  621. $t test -f $(APP)/include/red.hrl
  622. ifdef LEGACY
  623. $t test -f $(APP)/src/$(APP).app.src
  624. endif
  625. $t test -f $(APP)/src/use_blue.erl
  626. $t test -f $(APP)/src/use_red.erl
  627. $i "Check that all build artifacts are removed"
  628. $t test ! -e $(APP)/$(APP).d
  629. $t test ! -e $(APP)/ebin/
  630. $i "Build the application again"
  631. $t $(MAKE) -C $(APP) $v
  632. $i "Check that all compiled files exist"
  633. $t test -f $(APP)/$(APP).d
  634. $t test -f $(APP)/ebin/$(APP).app
  635. $t test -f $(APP)/ebin/use_blue.beam
  636. $t test -f $(APP)/ebin/use_red.beam
  637. $i "Check that the application was compiled correctly"
  638. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  639. ok = application:start($(APP)), \
  640. {ok, Mods = [use_blue, use_red]} \
  641. = application:get_key($(APP), modules), \
  642. [{module, M} = code:load_file(M) || M <- Mods], \
  643. halt()"
  644. core-app-hrl-recursive: build clean
  645. $i "Bootstrap a new OTP library named $(APP)"
  646. $t mkdir $(APP)/
  647. $t cp ../erlang.mk $(APP)/
  648. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  649. $i "Generate .hrl files"
  650. $t mkdir $(APP)/include/
  651. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  652. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  653. $i "Generate .erl files dependent from headers"
  654. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  655. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  656. $i "Build the application"
  657. $t $(MAKE) -C $(APP) $v
  658. $i "Check that all compiled files exist"
  659. $t test -f $(APP)/$(APP).d
  660. $t test -f $(APP)/ebin/$(APP).app
  661. $t test -f $(APP)/ebin/use_blue.beam
  662. $t test -f $(APP)/ebin/use_red.beam
  663. $i "Check that the application was compiled correctly"
  664. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  665. ok = application:start($(APP)), \
  666. {ok, Mods = [use_blue, use_red]} \
  667. = application:get_key($(APP), modules), \
  668. [{module, M} = code:load_file(M) || M <- Mods], \
  669. halt()"
  670. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  671. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  672. $t printf "%s\n" \
  673. $(APP)/$(APP).d \
  674. $(APP)/ebin/$(APP).app \
  675. $(APP)/ebin/use_red.beam \
  676. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  677. $t $(SLEEP)
  678. $t touch $(APP)/include/pill.hrl
  679. $t $(SLEEP)
  680. $t $(MAKE) -C $(APP) $v
  681. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  682. $t rm $(APP)/EXPECT
  683. $i "Check that the application was compiled correctly"
  684. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  685. ok = application:start($(APP)), \
  686. {ok, Mods = [use_blue, use_red]} \
  687. = application:get_key($(APP), modules), \
  688. [{module, M} = code:load_file(M) || M <- Mods], \
  689. halt()"
  690. $i "Clean the application"
  691. $t $(MAKE) -C $(APP) clean $v
  692. $i "Check that source files still exist"
  693. $t test -f $(APP)/Makefile
  694. $t test -f $(APP)/erlang.mk
  695. $t test -f $(APP)/include/blue.hrl
  696. $t test -f $(APP)/include/pill.hrl
  697. $t test -f $(APP)/include/red.hrl
  698. ifdef LEGACY
  699. $t test -f $(APP)/src/$(APP).app.src
  700. endif
  701. $t test -f $(APP)/src/use_blue.erl
  702. $t test -f $(APP)/src/use_red.erl
  703. $i "Check that all build artifacts are removed"
  704. $t test ! -e $(APP)/$(APP).d
  705. $t test ! -e $(APP)/ebin/
  706. $i "Build the application again"
  707. $t $(MAKE) -C $(APP) $v
  708. $i "Check that all compiled files exist"
  709. $t test -f $(APP)/$(APP).d
  710. $t test -f $(APP)/ebin/$(APP).app
  711. $t test -f $(APP)/ebin/use_blue.beam
  712. $t test -f $(APP)/ebin/use_red.beam
  713. $i "Check that the application was compiled correctly"
  714. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  715. ok = application:start($(APP)), \
  716. {ok, Mods = [use_blue, use_red]} \
  717. = application:get_key($(APP), modules), \
  718. [{module, M} = code:load_file(M) || M <- Mods], \
  719. halt()"
  720. core-app-makefile-change: build clean
  721. $i "Bootstrap a new OTP application named $(APP)"
  722. $t mkdir $(APP)/
  723. $t cp ../erlang.mk $(APP)/
  724. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  725. $i "Build the application"
  726. $t $(MAKE) -C $(APP) $v
  727. $i "Touch the Makefile; check that all files get rebuilt"
  728. $t printf "%s\n" \
  729. $(APP)/$(APP).d \
  730. $(APP)/ebin/$(APP).app \
  731. $(APP)/ebin/$(APP)_app.beam \
  732. $(APP)/ebin/$(APP)_sup.beam \
  733. $(APP)/src/$(APP)_app.erl \
  734. $(APP)/src/$(APP)_sup.erl | sort > $(APP)/EXPECT
  735. $t $(SLEEP)
  736. $t touch $(APP)/Makefile
  737. $t $(SLEEP)
  738. $t $(MAKE) -C $(APP) $v
  739. $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT -
  740. $t rm $(APP)/EXPECT
  741. core-app-mib: build clean
  742. $i "Bootstrap a new OTP library named $(APP)"
  743. $t mkdir $(APP)/
  744. $t cp ../erlang.mk $(APP)/
  745. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  746. $i "Download .mib files from Erlang/OTP"
  747. $t mkdir $(APP)/mibs/
  748. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  749. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/snmp/mibs/OTP-REG.mib
  750. $i "Generate .erl files dependent from headers generated by .mib files"
  751. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  752. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  753. $i "Generate an unrelated .hrl file"
  754. $t mkdir $(APP)/include/
  755. $t touch $(APP)/include/unrelated.hrl
  756. $i "Build the application"
  757. $t $(MAKE) -C $(APP) $v
  758. $i "Check that all compiled files exist"
  759. $t test -f $(APP)/$(APP).d
  760. $t test -f $(APP)/ebin/$(APP).app
  761. $t test -f $(APP)/ebin/use_v1.beam
  762. $t test -f $(APP)/ebin/use_v2.beam
  763. $t test -f $(APP)/include/EX1-MIB.hrl
  764. $t test -f $(APP)/include/OTP-REG.hrl
  765. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  766. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  767. $i "Check that the application was compiled correctly"
  768. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  769. ok = application:start($(APP)), \
  770. {ok, Mods = [use_v1, use_v2]} \
  771. = application:get_key($(APP), modules), \
  772. [{module, M} = code:load_file(M) || M <- Mods], \
  773. halt()"
  774. $i "Touch one .mib file; check that only required files are rebuilt"
  775. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  776. $t printf "%s\n" \
  777. $(APP)/$(APP).d \
  778. $(APP)/ebin/$(APP).app \
  779. $(APP)/ebin/use_v1.beam \
  780. $(APP)/include/EX1-MIB.hrl \
  781. $(APP)/priv/mibs/EX1-MIB.bin \
  782. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  783. $t $(SLEEP)
  784. $t touch $(APP)/mibs/EX1-MIB.mib
  785. $t $(SLEEP)
  786. $t $(MAKE) -C $(APP) $v
  787. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  788. $t rm $(APP)/EXPECT
  789. $i "Check that the application was compiled correctly"
  790. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  791. ok = application:start($(APP)), \
  792. {ok, Mods = [use_v1, use_v2]} \
  793. = application:get_key($(APP), modules), \
  794. [{module, M} = code:load_file(M) || M <- Mods], \
  795. halt()"
  796. $i "Clean the application"
  797. $t $(MAKE) -C $(APP) clean $v
  798. $i "Check that source files still exist"
  799. $t test -f $(APP)/Makefile
  800. $t test -f $(APP)/erlang.mk
  801. $t test -f $(APP)/include/unrelated.hrl
  802. $t test -f $(APP)/mibs/EX1-MIB.mib
  803. $t test -f $(APP)/mibs/OTP-REG.mib
  804. ifdef LEGACY
  805. $t test -f $(APP)/src/$(APP).app.src
  806. endif
  807. $t test -f $(APP)/src/use_v1.erl
  808. $t test -f $(APP)/src/use_v2.erl
  809. $i "Check that all build artifacts are removed, including intermediates"
  810. $t test ! -e $(APP)/$(APP).d
  811. $t test ! -e $(APP)/ebin/
  812. $t test ! -e $(APP)/include/EX1-MIB.hrl
  813. $t test ! -e $(APP)/include/OTP-REG.hrl
  814. $t test ! -e $(APP)/priv/mibs/
  815. $i "Build the application again"
  816. $t $(MAKE) -C $(APP) $v
  817. $i "Check that all compiled files exist"
  818. $t test -f $(APP)/$(APP).d
  819. $t test -f $(APP)/ebin/$(APP).app
  820. $t test -f $(APP)/ebin/use_v1.beam
  821. $t test -f $(APP)/ebin/use_v2.beam
  822. $t test -f $(APP)/include/EX1-MIB.hrl
  823. $t test -f $(APP)/include/OTP-REG.hrl
  824. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  825. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  826. $i "Check that the application was compiled correctly"
  827. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  828. ok = application:start($(APP)), \
  829. {ok, Mods = [use_v1, use_v2]} \
  830. = application:get_key($(APP), modules), \
  831. [{module, M} = code:load_file(M) || M <- Mods], \
  832. halt()"
  833. ifndef LEGACY
  834. core-app-name-special-char: build clean
  835. $i "Bootstrap a new OTP library named $(APP)"
  836. $t mkdir $(APP)/
  837. $t cp ../erlang.mk $(APP)/
  838. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  839. $i "Set PROJECT_DESCRIPTION = test % in the Makefile"
  840. $t echo "PROJECT_DESCRIPTION = test %" >> $(APP)/Makefile
  841. $i "Build the application"
  842. $t $(MAKE) -C $(APP) $v
  843. $i "Check that the application was compiled correctly"
  844. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  845. ok = application:load($(APP)), \
  846. {ok,\"test %\"} = application:get_key($(APP), description), \
  847. halt()"
  848. endif
  849. core-app-no-app: build clean
  850. $i "Bootstrap a project without an OTP library"
  851. $t mkdir $(APP)/
  852. $t cp ../erlang.mk $(APP)/
  853. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  854. $t rm -rf $(APP)/src
  855. $i "Build the project"
  856. $t $(MAKE) -C $(APP) $v
  857. core-app-no-makedep: build clean
  858. $i "Bootstrap a new OTP library named $(APP)"
  859. $t mkdir $(APP)/
  860. $t cp ../erlang.mk $(APP)/
  861. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  862. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  863. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  864. $i "Generate .hrl files"
  865. $t mkdir $(APP)/include/
  866. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  867. $i "Generate .erl files dependent from headers"
  868. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  869. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  870. $i "Build the application"
  871. $t $(MAKE) -C $(APP) $v
  872. $i "Check that all compiled files exist"
  873. $t test -f $(APP)/$(APP).d
  874. $t test -f $(APP)/ebin/$(APP).app
  875. $t test -f $(APP)/ebin/use_blue.beam
  876. $t test -f $(APP)/ebin/use_red.beam
  877. $i "Check that the application was compiled correctly"
  878. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  879. ok = application:start($(APP)), \
  880. {ok, Mods = [use_blue, use_red]} \
  881. = application:get_key($(APP), modules), \
  882. [{module, M} = code:load_file(M) || M <- Mods], \
  883. halt()"
  884. $i "Touch one .hrl file; check that only required files are rebuilt"
  885. # The use_red.erl gets touched because of its dependency to red.hrl.
  886. $t printf "%s\n" \
  887. $(APP)/ebin/$(APP).app \
  888. $(APP)/ebin/use_red.beam \
  889. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  890. $t $(SLEEP)
  891. $t touch $(APP)/include/red.hrl
  892. $t $(SLEEP)
  893. $t $(MAKE) -C $(APP) $v
  894. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  895. $t rm $(APP)/EXPECT
  896. $i "Check that the application was compiled correctly"
  897. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  898. ok = application:start($(APP)), \
  899. {ok, Mods = [use_blue, use_red]} \
  900. = application:get_key($(APP), modules), \
  901. [{module, M} = code:load_file(M) || M <- Mods], \
  902. halt()"
  903. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  904. # The use_red.erl gets touched because of its dependency to red.hrl.
  905. $t printf "%s\n" \
  906. $(APP)/$(APP).d \
  907. $(APP)/ebin/$(APP).app \
  908. $(APP)/ebin/use_red.beam \
  909. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  910. $t $(SLEEP)
  911. $t touch $(APP)/include/red.hrl
  912. $t $(SLEEP)
  913. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  914. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  915. $t rm $(APP)/EXPECT
  916. $i "Check that the application was compiled correctly"
  917. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  918. ok = application:start($(APP)), \
  919. {ok, Mods = [use_blue, use_red]} \
  920. = application:get_key($(APP), modules), \
  921. [{module, M} = code:load_file(M) || M <- Mods], \
  922. halt()"
  923. $i "Clean the application"
  924. $t $(MAKE) -C $(APP) clean $v
  925. $i "Check that source files still exist"
  926. $t test -f $(APP)/Makefile
  927. $t test -f $(APP)/erlang.mk
  928. $t test -f $(APP)/include/blue.hrl
  929. $t test -f $(APP)/include/red.hrl
  930. ifdef LEGACY
  931. $t test -f $(APP)/src/$(APP).app.src
  932. endif
  933. $t test -f $(APP)/src/use_blue.erl
  934. $t test -f $(APP)/src/use_red.erl
  935. $i "Check that all build artifacts are removed"
  936. $t test ! -e $(APP)/$(APP).d
  937. $t test ! -e $(APP)/ebin/
  938. $i "Build the application again"
  939. $t $(MAKE) -C $(APP) $v
  940. $i "Check that all compiled files exist"
  941. $t test -f $(APP)/$(APP).d
  942. $t test -f $(APP)/ebin/$(APP).app
  943. $t test -f $(APP)/ebin/use_blue.beam
  944. $t test -f $(APP)/ebin/use_red.beam
  945. $i "Check that the application was compiled correctly"
  946. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  947. ok = application:start($(APP)), \
  948. {ok, Mods = [use_blue, use_red]} \
  949. = application:get_key($(APP), modules), \
  950. [{module, M} = code:load_file(M) || M <- Mods], \
  951. halt()"
  952. core-app-project-mod: build clean
  953. $i "Bootstrap a new OTP library named $(APP)"
  954. $t mkdir $(APP)/
  955. $t cp ../erlang.mk $(APP)/
  956. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  957. $i "Generate an application module"
  958. $t printf "%s\n" \
  959. "-module(app_mod)." \
  960. "-export([start/2, stop/1])." \
  961. "start(_StartType, _StartArgs) -> {ok, self()}." \
  962. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  963. $i "Build the application with PROJECT_MOD"
  964. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  965. $i "Check that the application starts correctly"
  966. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  967. core-app-pt: build clean
  968. $i "Bootstrap a new OTP library named $(APP)"
  969. $t mkdir $(APP)/
  970. $t cp ../erlang.mk $(APP)/
  971. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  972. $i "Generate a parse_transform module"
  973. $t printf "%s\n" \
  974. "-module(my_pt)." \
  975. "-export([parse_transform/2])." \
  976. "parse_transform(Forms, _) ->" \
  977. " io:format(\"# Running my_pt parse_transform.~n\")," \
  978. " Forms." > $(APP)/src/my_pt.erl
  979. $i "Generate a .erl file that uses the my_pt parse_transform"
  980. $t printf "%s\n" \
  981. "-module(my_user)." \
  982. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  983. $i "Compile my_pt first"
  984. $t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
  985. $i "Build the application; confirm the parse_transform is used"
  986. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  987. $i "Check that the application was compiled correctly"
  988. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  989. ok = application:start($(APP)), \
  990. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  991. [{module, M} = code:load_file(M) || M <- Mods], \
  992. halt()"
  993. core-app-pt-erlc-opts: build clean
  994. $i "Bootstrap a new OTP library named $(APP)"
  995. $t mkdir $(APP)/
  996. $t cp ../erlang.mk $(APP)/
  997. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  998. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  999. $t mkdir -p $(APP)/deps/my_pt_dep/
  1000. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  1001. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  1002. $i "Generate a parse_transform module in my_pt_dep"
  1003. $t printf "%s\n" \
  1004. "-module(my_pt)." \
  1005. "-export([parse_transform/2])." \
  1006. "parse_transform(Forms, _) ->" \
  1007. " io:format(\"# Running my_pt parse_transform.~n\")," \
  1008. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  1009. $i "Add my_pt_dep to the list of dependencies"
  1010. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  1011. $i "Generate .erl files"
  1012. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1013. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1014. $i "Add the my_pt parse_transform to ERLC_OPTS"
  1015. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  1016. $i "Build the application; confirm the parse_transform is used"
  1017. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  1018. $i "Check that the application was compiled correctly"
  1019. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1020. ok = application:start($(APP)), \
  1021. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  1022. [{module, M} = code:load_file(M) || M <- Mods], \
  1023. halt()"
  1024. core-app-xrl: build clean
  1025. $i "Bootstrap a new OTP library named $(APP)"
  1026. $t mkdir $(APP)/
  1027. $t cp ../erlang.mk $(APP)/
  1028. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1029. $i "Download .xrl files from Robert"
  1030. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  1031. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  1032. $i "Generate unrelated .erl files"
  1033. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1034. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1035. $i "Disable warnings; our test .xrl files aren't perfect"
  1036. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1037. $i "Build the application"
  1038. $t $(MAKE) -C $(APP) $v
  1039. $i "Check that all compiled files exist"
  1040. $t test -f $(APP)/$(APP).d
  1041. $t test -f $(APP)/ebin/$(APP).app
  1042. $t test -f $(APP)/ebin/boy.beam
  1043. $t test -f $(APP)/ebin/erlang_scan.beam
  1044. $t test -f $(APP)/ebin/girl.beam
  1045. $t test -f $(APP)/ebin/lfe_scan.beam
  1046. $t test -f $(APP)/src/erlang_scan.erl
  1047. $t test -f $(APP)/src/lfe_scan.erl
  1048. $i "Check that the application was compiled correctly"
  1049. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1050. ok = application:start($(APP)), \
  1051. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1052. = application:get_key($(APP), modules), \
  1053. [{module, M} = code:load_file(M) || M <- Mods], \
  1054. halt()"
  1055. $i "Touch one .xrl file; check that only required files are rebuilt"
  1056. $t printf "%s\n" \
  1057. $(APP)/$(APP).d \
  1058. $(APP)/ebin/$(APP).app \
  1059. $(APP)/ebin/erlang_scan.beam \
  1060. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  1061. $t $(SLEEP)
  1062. $t touch $(APP)/src/erlang_scan.xrl
  1063. $t $(SLEEP)
  1064. $t $(MAKE) -C $(APP) $v
  1065. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  1066. $t rm $(APP)/EXPECT
  1067. $i "Check that the application was compiled correctly"
  1068. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1069. ok = application:start($(APP)), \
  1070. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1071. = application:get_key($(APP), modules), \
  1072. [{module, M} = code:load_file(M) || M <- Mods], \
  1073. halt()"
  1074. $i "Clean the application"
  1075. $t $(MAKE) -C $(APP) clean $v
  1076. $i "Check that source files still exist"
  1077. $t test -f $(APP)/Makefile
  1078. $t test -f $(APP)/erlang.mk
  1079. ifdef LEGACY
  1080. $t test -f $(APP)/src/$(APP).app.src
  1081. endif
  1082. $t test -f $(APP)/src/boy.erl
  1083. $t test -f $(APP)/src/erlang_scan.xrl
  1084. $t test -f $(APP)/src/girl.erl
  1085. $t test -f $(APP)/src/lfe_scan.xrl
  1086. $i "Check that all build artifacts are removed, including intermediates"
  1087. $t test ! -e $(APP)/$(APP).d
  1088. $t test ! -e $(APP)/ebin/
  1089. $t test ! -e $(APP)/src/erlang_scan.erl
  1090. $t test ! -e $(APP)/src/lfe_scan.erl
  1091. $i "Build the application again"
  1092. $t $(MAKE) -C $(APP) $v
  1093. $i "Check that all compiled files exist"
  1094. $t test -f $(APP)/$(APP).d
  1095. $t test -f $(APP)/ebin/$(APP).app
  1096. $t test -f $(APP)/ebin/boy.beam
  1097. $t test -f $(APP)/ebin/erlang_scan.beam
  1098. $t test -f $(APP)/ebin/girl.beam
  1099. $t test -f $(APP)/ebin/lfe_scan.beam
  1100. $t test -f $(APP)/src/erlang_scan.erl
  1101. $t test -f $(APP)/src/lfe_scan.erl
  1102. $i "Check that the application was compiled correctly"
  1103. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1104. ok = application:start($(APP)), \
  1105. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1106. = application:get_key($(APP), modules), \
  1107. [{module, M} = code:load_file(M) || M <- Mods], \
  1108. halt()"
  1109. core-app-xrl-help: build clean
  1110. $i "Bootstrap a new OTP library named $(APP)"
  1111. $t mkdir $(APP)/
  1112. $t cp ../erlang.mk $(APP)/
  1113. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1114. $i "Download an .xrl file from Robert"
  1115. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  1116. $i "Disable warnings; our test .xrl files aren't perfect"
  1117. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1118. $i "Run 'make help'"
  1119. $t $(MAKE) -C $(APP) help $v
  1120. $i "Check that no files were compiled"
  1121. $t test ! -e $(APP)/$(APP).d
  1122. $t test ! -e $(APP)/ebin/$(APP).app
  1123. $t test ! -e $(APP)/ebin/erlang_scan.beam
  1124. $t test ! -e $(APP)/src/erlang_scan.erl
  1125. core-app-xrl-include: build clean
  1126. $i "Bootstrap a new OTP library named $(APP)"
  1127. $t mkdir $(APP)/
  1128. $t cp ../erlang.mk $(APP)/
  1129. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1130. $i "Download a .xrl file with numerous includes from Gordon"
  1131. $t curl -s -o $(APP)/src/xfl_lexer.xrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/formula_engine-1.0/priv/xfl_lexer.xrl
  1132. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1133. $t curl -s -o $(APP)/src/muin_proc_dict.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_proc_dict.hrl
  1134. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1135. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  1136. $i "Generate unrelated .erl files"
  1137. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1138. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1139. $i "Disable warnings; our test .xrl files aren't perfect"
  1140. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1141. $i "Build the application"
  1142. $t $(MAKE) -C $(APP) $v
  1143. $i "Check that all compiled files exist"
  1144. $t test -f $(APP)/$(APP).d
  1145. $t test -f $(APP)/ebin/$(APP).app
  1146. $t test -f $(APP)/ebin/boy.beam
  1147. $t test -f $(APP)/ebin/girl.beam
  1148. $t test -f $(APP)/ebin/xfl_lexer.beam
  1149. $t test -f $(APP)/src/xfl_lexer.erl
  1150. $i "Check that the application was compiled correctly"
  1151. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1152. ok = application:start($(APP)), \
  1153. {ok, Mods = [boy, girl, xfl_lexer]} \
  1154. = application:get_key($(APP), modules), \
  1155. [{module, M} = code:load_file(M) || M <- Mods], \
  1156. halt()"
  1157. $i "Touch the .xrl file; check that only required files are rebuilt"
  1158. $t printf "%s\n" \
  1159. $(APP)/$(APP).d \
  1160. $(APP)/ebin/$(APP).app \
  1161. $(APP)/ebin/xfl_lexer.beam \
  1162. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1163. $t $(SLEEP)
  1164. $t touch $(APP)/src/xfl_lexer.xrl
  1165. $t $(SLEEP)
  1166. $t $(MAKE) -C $(APP) $v
  1167. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1168. $t rm $(APP)/EXPECT
  1169. $i "Check that the application was compiled correctly"
  1170. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1171. ok = application:start($(APP)), \
  1172. {ok, Mods = [boy, girl, xfl_lexer]} \
  1173. = application:get_key($(APP), modules), \
  1174. [{module, M} = code:load_file(M) || M <- Mods], \
  1175. halt()"
  1176. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1177. $t printf "%s\n" \
  1178. $(APP)/$(APP).d \
  1179. $(APP)/ebin/$(APP).app \
  1180. $(APP)/ebin/xfl_lexer.beam \
  1181. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1182. $t $(SLEEP)
  1183. $t touch $(APP)/src/typechecks.hrl
  1184. $t $(SLEEP)
  1185. $t $(MAKE) -C $(APP) $v
  1186. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  1187. $t rm $(APP)/EXPECT
  1188. $i "Check that the application was compiled correctly"
  1189. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1190. ok = application:start($(APP)), \
  1191. {ok, Mods = [boy, girl, xfl_lexer]} \
  1192. = application:get_key($(APP), modules), \
  1193. [{module, M} = code:load_file(M) || M <- Mods], \
  1194. halt()"
  1195. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1196. $t printf "%s\n" \
  1197. $(APP)/$(APP).d \
  1198. $(APP)/ebin/$(APP).app \
  1199. $(APP)/ebin/xfl_lexer.beam \
  1200. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1201. $t $(SLEEP)
  1202. $t touch $(APP)/src/errvals.hrl
  1203. $t $(SLEEP)
  1204. $t $(MAKE) -C $(APP) $v
  1205. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1206. $t rm $(APP)/EXPECT
  1207. $i "Check that the application was compiled correctly"
  1208. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1209. ok = application:start($(APP)), \
  1210. {ok, Mods = [boy, girl, xfl_lexer]} \
  1211. = application:get_key($(APP), modules), \
  1212. [{module, M} = code:load_file(M) || M <- Mods], \
  1213. halt()"
  1214. $i "Clean the application"
  1215. $t $(MAKE) -C $(APP) clean $v
  1216. $i "Check that source files still exist"
  1217. $t test -f $(APP)/Makefile
  1218. $t test -f $(APP)/erlang.mk
  1219. ifdef LEGACY
  1220. $t test -f $(APP)/src/$(APP).app.src
  1221. endif
  1222. $t test -f $(APP)/src/boy.erl
  1223. $t test -f $(APP)/src/girl.erl
  1224. $t test -f $(APP)/src/errvals.hrl
  1225. $t test -f $(APP)/src/muin_proc_dict.hrl
  1226. $t test -f $(APP)/src/muin_records.hrl
  1227. $t test -f $(APP)/src/typechecks.hrl
  1228. $t test -f $(APP)/src/xfl_lexer.xrl
  1229. $i "Check that all build artifacts are removed, including intermediates"
  1230. $t test ! -e $(APP)/$(APP).d
  1231. $t test ! -e $(APP)/ebin/
  1232. $t test ! -e $(APP)/src/xfl_lexer.erl
  1233. $i "Build the application again"
  1234. $t $(MAKE) -C $(APP) $v
  1235. $i "Check that all compiled files exist"
  1236. $t test -f $(APP)/$(APP).d
  1237. $t test -f $(APP)/ebin/$(APP).app
  1238. $t test -f $(APP)/ebin/boy.beam
  1239. $t test -f $(APP)/ebin/girl.beam
  1240. $t test -f $(APP)/ebin/xfl_lexer.beam
  1241. $t test -f $(APP)/src/xfl_lexer.erl
  1242. $i "Check that the application was compiled correctly"
  1243. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1244. ok = application:start($(APP)), \
  1245. {ok, Mods = [boy, girl, xfl_lexer]} \
  1246. = application:get_key($(APP), modules), \
  1247. [{module, M} = code:load_file(M) || M <- Mods], \
  1248. halt()"
  1249. core-app-yrl: build clean
  1250. $i "Bootstrap a new OTP library named $(APP)"
  1251. $t mkdir $(APP)/
  1252. $t cp ../erlang.mk $(APP)/
  1253. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1254. $i "Download .yrl files from Erlang/OTP"
  1255. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1256. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1257. $i "Generate unrelated .erl files"
  1258. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1259. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1260. $i "Build the application"
  1261. $t $(MAKE) -C $(APP) $v
  1262. $i "Check that all compiled files exist"
  1263. $t test -f $(APP)/$(APP).d
  1264. $t test -f $(APP)/ebin/$(APP).app
  1265. $t test -f $(APP)/ebin/boy.beam
  1266. $t test -f $(APP)/ebin/girl.beam
  1267. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1268. $t test -f $(APP)/ebin/xref_parser.beam
  1269. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1270. $t test -f $(APP)/src/xref_parser.erl
  1271. $i "Check that the application was compiled correctly"
  1272. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1273. ok = application:start($(APP)), \
  1274. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1275. = application:get_key($(APP), modules), \
  1276. [{module, M} = code:load_file(M) || M <- Mods], \
  1277. halt()"
  1278. $i "Touch one .yrl file; check that only required files are rebuilt"
  1279. $t printf "%s\n" \
  1280. $(APP)/$(APP).d \
  1281. $(APP)/ebin/$(APP).app \
  1282. $(APP)/ebin/xref_parser.beam \
  1283. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1284. $t $(SLEEP)
  1285. $t touch $(APP)/src/xref_parser.yrl
  1286. $t $(SLEEP)
  1287. $t $(MAKE) -C $(APP) $v
  1288. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1289. $t rm $(APP)/EXPECT
  1290. $i "Check that the application was compiled correctly"
  1291. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1292. ok = application:start($(APP)), \
  1293. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1294. = application:get_key($(APP), modules), \
  1295. [{module, M} = code:load_file(M) || M <- Mods], \
  1296. halt()"
  1297. $i "Clean the application"
  1298. $t $(MAKE) -C $(APP) clean $v
  1299. $i "Check that source files still exist"
  1300. $t test -f $(APP)/Makefile
  1301. $t test -f $(APP)/erlang.mk
  1302. ifdef LEGACY
  1303. $t test -f $(APP)/src/$(APP).app.src
  1304. endif
  1305. $t test -f $(APP)/src/boy.erl
  1306. $t test -f $(APP)/src/girl.erl
  1307. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1308. $t test -f $(APP)/src/xref_parser.yrl
  1309. $i "Check that all build artifacts are removed, including intermediates"
  1310. $t test ! -e $(APP)/$(APP).d
  1311. $t test ! -e $(APP)/ebin/
  1312. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1313. $t test ! -e $(APP)/src/xref_parser.erl
  1314. $i "Build the application again"
  1315. $t $(MAKE) -C $(APP) $v
  1316. $i "Check that all compiled files exist"
  1317. $t test -f $(APP)/$(APP).d
  1318. $t test -f $(APP)/ebin/$(APP).app
  1319. $t test -f $(APP)/ebin/boy.beam
  1320. $t test -f $(APP)/ebin/girl.beam
  1321. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1322. $t test -f $(APP)/ebin/xref_parser.beam
  1323. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1324. $t test -f $(APP)/src/xref_parser.erl
  1325. $i "Check that the application was compiled correctly"
  1326. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1327. ok = application:start($(APP)), \
  1328. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1329. = application:get_key($(APP), modules), \
  1330. [{module, M} = code:load_file(M) || M <- Mods], \
  1331. halt()"
  1332. core-app-yrl-header: build clean
  1333. $i "Bootstrap a new OTP library named $(APP)"
  1334. $t mkdir $(APP)/
  1335. $t cp ../erlang.mk $(APP)/
  1336. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1337. $i "Create a .yrl file"
  1338. $t echo "Nonterminals E T F." > $(APP)/src/y_parse.yrl
  1339. $t echo "Terminals '+' '*' '(' ')' number." >> $(APP)/src/y_parse.yrl
  1340. $t echo "Rootsymbol E." >> $(APP)/src/y_parse.yrl
  1341. $t echo "E -> E '+' T: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1342. $t echo "E -> T : '\$$1'." >> $(APP)/src/y_parse.yrl
  1343. $t echo "T -> T '*' F: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1344. $t echo "T -> F : '\$$1'." >> $(APP)/src/y_parse.yrl
  1345. $t echo "F -> '(' E ')' : '\$$2'." >> $(APP)/src/y_parse.yrl
  1346. $t echo "F -> number : '\$$1'. " >> $(APP)/src/y_parse.yrl
  1347. $i "Create the yrl header file"
  1348. $t mkdir $(APP)/include
  1349. $t echo "-export([forty_two/0])." > $(APP)/include/yecc_header.hrl
  1350. # A bunch of gobbldygook we don't actually care about, they just
  1351. # need to exist so we don't get errors.
  1352. $t echo "-export([yeccpars1/5, yeccerror/1, yeccpars2/7, yeccpars2_0/7, yeccpars2_1/7, yeccpars2_2/7, yeccpars2_3/7, yeccpars2_5/7, yeccpars2_6/7, yeccpars2_7/7, yeccpars2_9/7, yeccpars2_11/7, 'yeccgoto_\'E\''/7, 'yeccgoto_\'F\''/7, 'yeccgoto_\'T\''/7, yeccpars2_9_/1, yeccpars2_11_/1, yeccpars2_7_/1])." >> $(APP)/include/yecc_header.hrl
  1353. $t echo "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1354. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1355. # Required bits done, now part we'll actually test for.
  1356. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1357. $i "Generate unrelated .erl files"
  1358. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1359. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1360. $i "Build the application"
  1361. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1362. $i "Check that all compiled files exist"
  1363. $t test -f $(APP)/$(APP).d
  1364. $t test -f $(APP)/ebin/$(APP).app
  1365. $t test -f $(APP)/ebin/boy.beam
  1366. $t test -f $(APP)/ebin/girl.beam
  1367. $t test -f $(APP)/ebin/y_parse.beam
  1368. $t test -f $(APP)/src/y_parse.erl
  1369. $i "Check that the application was compiled correctly"
  1370. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1371. ok = application:start($(APP)), \
  1372. {ok, Mods = [boy, girl, y_parse]} \
  1373. = application:get_key($(APP), modules), \
  1374. [{module, M} = code:load_file(M) || M <- Mods], \
  1375. halt()"
  1376. $i "Check the built yecc module used the header"
  1377. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1378. {module, y_parse} = code:load_file(y_parse), \
  1379. 42 = y_parse:forty_two(), \
  1380. halt()"
  1381. $i "Check that the application was compiled correctly"
  1382. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1383. ok = application:start($(APP)), \
  1384. {ok, Mods = [boy, girl, y_parse]} \
  1385. = application:get_key($(APP), modules), \
  1386. [{module, M} = code:load_file(M) || M <- Mods], \
  1387. halt()"
  1388. core-app-yrl-include: build clean
  1389. $i "Bootstrap a new OTP library named $(APP)"
  1390. $t mkdir $(APP)/
  1391. $t cp ../erlang.mk $(APP)/
  1392. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1393. $i "Download a .yrl file with includes from Erlang/OTP"
  1394. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1395. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1396. $i "Generate unrelated .erl files"
  1397. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1398. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1399. $i "Build the application"
  1400. $t $(MAKE) -C $(APP) $v
  1401. $i "Check that all compiled files exist"
  1402. $t test -f $(APP)/$(APP).d
  1403. $t test -f $(APP)/ebin/$(APP).app
  1404. $t test -f $(APP)/ebin/boy.beam
  1405. $t test -f $(APP)/ebin/core_parse.beam
  1406. $t test -f $(APP)/ebin/girl.beam
  1407. $t test -f $(APP)/src/core_parse.erl
  1408. $i "Check that the application was compiled correctly"
  1409. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1410. ok = application:start($(APP)), \
  1411. {ok, Mods = [boy, core_parse, girl]} \
  1412. = application:get_key($(APP), modules), \
  1413. [{module, M} = code:load_file(M) || M <- Mods], \
  1414. halt()"
  1415. $i "Touch the .yrl file; check that only required files are rebuilt"
  1416. $t printf "%s\n" \
  1417. $(APP)/$(APP).d \
  1418. $(APP)/ebin/$(APP).app \
  1419. $(APP)/ebin/core_parse.beam \
  1420. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1421. $t $(SLEEP)
  1422. $t touch $(APP)/src/core_parse.yrl
  1423. $t $(SLEEP)
  1424. $t $(MAKE) -C $(APP) $v
  1425. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1426. $t rm $(APP)/EXPECT
  1427. $i "Check that the application was compiled correctly"
  1428. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1429. ok = application:start($(APP)), \
  1430. {ok, Mods = [boy, core_parse, girl]} \
  1431. = application:get_key($(APP), modules), \
  1432. [{module, M} = code:load_file(M) || M <- Mods], \
  1433. halt()"
  1434. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1435. $t printf "%s\n" \
  1436. $(APP)/$(APP).d \
  1437. $(APP)/ebin/$(APP).app \
  1438. $(APP)/ebin/core_parse.beam \
  1439. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1440. $t $(SLEEP)
  1441. $t touch $(APP)/src/core_parse.hrl
  1442. $t $(SLEEP)
  1443. $t $(MAKE) -C $(APP) $v
  1444. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1445. $t rm $(APP)/EXPECT
  1446. $i "Check that the application was compiled correctly"
  1447. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1448. ok = application:start($(APP)), \
  1449. {ok, Mods = [boy, core_parse, girl]} \
  1450. = application:get_key($(APP), modules), \
  1451. [{module, M} = code:load_file(M) || M <- Mods], \
  1452. halt()"
  1453. $i "Clean the application"
  1454. $t $(MAKE) -C $(APP) clean $v
  1455. $i "Check that source files still exist"
  1456. $t test -f $(APP)/Makefile
  1457. $t test -f $(APP)/erlang.mk
  1458. ifdef LEGACY
  1459. $t test -f $(APP)/src/$(APP).app.src
  1460. endif
  1461. $t test -f $(APP)/src/boy.erl
  1462. $t test -f $(APP)/src/core_parse.hrl
  1463. $t test -f $(APP)/src/core_parse.yrl
  1464. $t test -f $(APP)/src/girl.erl
  1465. $i "Check that all build artifacts are removed, including intermediates"
  1466. $t test ! -e $(APP)/$(APP).d
  1467. $t test ! -e $(APP)/ebin/
  1468. $t test ! -e $(APP)/src/core_parse.erl
  1469. $i "Build the application again"
  1470. $t $(MAKE) -C $(APP) $v
  1471. $i "Check that all compiled files exist"
  1472. $t test -f $(APP)/$(APP).d
  1473. $t test -f $(APP)/ebin/$(APP).app
  1474. $t test -f $(APP)/ebin/boy.beam
  1475. $t test -f $(APP)/ebin/core_parse.beam
  1476. $t test -f $(APP)/ebin/girl.beam
  1477. $t test -f $(APP)/src/core_parse.erl
  1478. $i "Check that the application was compiled correctly"
  1479. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1480. ok = application:start($(APP)), \
  1481. {ok, Mods = [boy, core_parse, girl]} \
  1482. = application:get_key($(APP), modules), \
  1483. [{module, M} = code:load_file(M) || M <- Mods], \
  1484. halt()"
  1485. core-app-yrl-test-build-then-normal-build: build clean
  1486. $i "Bootstrap a new OTP library named $(APP)"
  1487. $t mkdir $(APP)/
  1488. $t cp ../erlang.mk $(APP)/
  1489. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1490. $i "Create the parser .yrl file"
  1491. $t printf "%s\n" \
  1492. "Nonterminals top." \
  1493. "Terminals plus num." \
  1494. "Rootsymbol top." \
  1495. "top -> num plus num : {'$1', '$3'}." > $(APP)/src/$(APP)_parser.yrl
  1496. $i "Create the test suite"
  1497. $t mkdir $(APP)/test
  1498. $t printf "%s\n" \
  1499. "-module(test_SUITE)." \
  1500. "-export([all/0, test/1])." \
  1501. "all() -> [test]." \
  1502. "test(_) -> 0=0." > $(APP)/test/test_SUITE.erl
  1503. $i "Build the application in test mode"
  1504. $t $(MAKE) -C $(APP) ct $v
  1505. $i "Build the application in normal mode"
  1506. $t $(MAKE) -C $(APP) $v
  1507. core-app-hrl-include-lib: build clean
  1508. $i "Bootstrap a new OTP library named $(APP)"
  1509. $t mkdir $(APP)/
  1510. $t cp ../erlang.mk $(APP)/
  1511. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1512. $i "Generate .hrl files"
  1513. $t mkdir $(APP)/include/
  1514. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  1515. $i "Generate .erl files dependent from headers"
  1516. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1517. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1518. $i "Build the application"
  1519. $t $(MAKE) -C $(APP) $v
  1520. $i "Check that all compiled files exist"
  1521. $t test -f $(APP)/$(APP).d
  1522. $t test -f $(APP)/ebin/$(APP).app
  1523. $t test -f $(APP)/ebin/use_blue.beam
  1524. $t test -f $(APP)/ebin/use_red.beam
  1525. $i "Check that the application was compiled correctly"
  1526. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1527. ok = application:start($(APP)), \
  1528. {ok, Mods = [use_blue, use_red]} \
  1529. = application:get_key($(APP), modules), \
  1530. [{module, M} = code:load_file(M) || M <- Mods], \
  1531. halt()"
  1532. $i "Touch one .hrl file; check that only required files are rebuilt"
  1533. # The use_red.erl gets touched because of its dependency to red.hrl.
  1534. $t printf "%s\n" \
  1535. $(APP)/$(APP).d \
  1536. $(APP)/ebin/$(APP).app \
  1537. $(APP)/ebin/use_red.beam \
  1538. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1539. $t $(SLEEP)
  1540. $t touch $(APP)/include/red.hrl
  1541. $t $(SLEEP)
  1542. $t $(MAKE) -C $(APP) $v
  1543. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  1544. $t rm $(APP)/EXPECT
  1545. $i "Check that the application was compiled correctly"
  1546. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1547. ok = application:start($(APP)), \
  1548. {ok, Mods = [use_blue, use_red]} \
  1549. = application:get_key($(APP), modules), \
  1550. [{module, M} = code:load_file(M) || M <- Mods], \
  1551. halt()"
  1552. $i "Clean the application"
  1553. $t $(MAKE) -C $(APP) clean $v
  1554. $i "Check that source files still exist"
  1555. $t test -f $(APP)/Makefile
  1556. $t test -f $(APP)/erlang.mk
  1557. $t test -f $(APP)/include/blue.hrl
  1558. $t test -f $(APP)/include/red.hrl
  1559. ifdef LEGACY
  1560. $t test -f $(APP)/src/$(APP).app.src
  1561. endif
  1562. $t test -f $(APP)/src/use_blue.erl
  1563. $t test -f $(APP)/src/use_red.erl
  1564. $i "Check that all build artifacts are removed"
  1565. $t test ! -e $(APP)/$(APP).d
  1566. $t test ! -e $(APP)/ebin/
  1567. $i "Build the application again"
  1568. $t $(MAKE) -C $(APP) $v
  1569. $i "Check that all compiled files exist"
  1570. $t test -f $(APP)/$(APP).d
  1571. $t test -f $(APP)/ebin/$(APP).app
  1572. $t test -f $(APP)/ebin/use_blue.beam
  1573. $t test -f $(APP)/ebin/use_red.beam
  1574. $i "Check that the application was compiled correctly"
  1575. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1576. ok = application:start($(APP)), \
  1577. {ok, Mods = [use_blue, use_red]} \
  1578. = application:get_key($(APP), modules), \
  1579. [{module, M} = code:load_file(M) || M <- Mods], \
  1580. halt()"
  1581. core-app-hrl-include-lib-recursive: build clean
  1582. $i "Bootstrap a new OTP library named $(APP)"
  1583. $t mkdir $(APP)/
  1584. $t cp ../erlang.mk $(APP)/
  1585. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1586. $i "Generate .hrl files"
  1587. $t mkdir $(APP)/include/
  1588. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  1589. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/include/red.hrl
  1590. $i "Generate .erl files dependent from headers"
  1591. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1592. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1593. $i "Build the application"
  1594. $t $(MAKE) -C $(APP) $v
  1595. $i "Check that all compiled files exist"
  1596. $t test -f $(APP)/$(APP).d
  1597. $t test -f $(APP)/ebin/$(APP).app
  1598. $t test -f $(APP)/ebin/use_blue.beam
  1599. $t test -f $(APP)/ebin/use_red.beam
  1600. $i "Check that the application was compiled correctly"
  1601. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1602. ok = application:start($(APP)), \
  1603. {ok, Mods = [use_blue, use_red]} \
  1604. = application:get_key($(APP), modules), \
  1605. [{module, M} = code:load_file(M) || M <- Mods], \
  1606. halt()"
  1607. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1608. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1609. $t printf "%s\n" \
  1610. $(APP)/$(APP).d \
  1611. $(APP)/ebin/$(APP).app \
  1612. $(APP)/ebin/use_red.beam \
  1613. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1614. $t $(SLEEP)
  1615. $t touch $(APP)/include/pill.hrl
  1616. $t $(SLEEP)
  1617. $t $(MAKE) -C $(APP) $v
  1618. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1619. $t rm $(APP)/EXPECT
  1620. $i "Check that the application was compiled correctly"
  1621. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1622. ok = application:start($(APP)), \
  1623. {ok, Mods = [use_blue, use_red]} \
  1624. = application:get_key($(APP), modules), \
  1625. [{module, M} = code:load_file(M) || M <- Mods], \
  1626. halt()"
  1627. $i "Clean the application"
  1628. $t $(MAKE) -C $(APP) clean $v
  1629. $i "Check that source files still exist"
  1630. $t test -f $(APP)/Makefile
  1631. $t test -f $(APP)/erlang.mk
  1632. $t test -f $(APP)/include/blue.hrl
  1633. $t test -f $(APP)/include/pill.hrl
  1634. $t test -f $(APP)/include/red.hrl
  1635. ifdef LEGACY
  1636. $t test -f $(APP)/src/$(APP).app.src
  1637. endif
  1638. $t test -f $(APP)/src/use_blue.erl
  1639. $t test -f $(APP)/src/use_red.erl
  1640. $i "Check that all build artifacts are removed"
  1641. $t test ! -e $(APP)/$(APP).d
  1642. $t test ! -e $(APP)/ebin/
  1643. $i "Build the application again"
  1644. $t $(MAKE) -C $(APP) $v
  1645. $i "Check that all compiled files exist"
  1646. $t test -f $(APP)/$(APP).d
  1647. $t test -f $(APP)/ebin/$(APP).app
  1648. $t test -f $(APP)/ebin/use_blue.beam
  1649. $t test -f $(APP)/ebin/use_red.beam
  1650. $i "Check that the application was compiled correctly"
  1651. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1652. ok = application:start($(APP)), \
  1653. {ok, Mods = [use_blue, use_red]} \
  1654. = application:get_key($(APP), modules), \
  1655. [{module, M} = code:load_file(M) || M <- Mods], \
  1656. halt()"
  1657. core-app-hrl-multiapps-include-lib: build clean
  1658. $i "Create a multi application repository with no root application"
  1659. $t mkdir $(APP)/
  1660. $t cp ../erlang.mk $(APP)/
  1661. $t echo "include erlang.mk" > $(APP)/Makefile
  1662. $i "Create a new application named my_app"
  1663. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1664. $i "Create a new library named my_lib"
  1665. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1666. $i "Add my_lib as LOCAL_DEPS of my_app"
  1667. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1668. $i "Generate .hrl files"
  1669. $t mkdir $(APP)/apps/my_lib/include/
  1670. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl
  1671. $i "Generate .erl files dependent from headers"
  1672. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1673. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1674. $i "Build the application"
  1675. $t $(MAKE) -C $(APP) $v
  1676. $i "Check that all compiled files exist"
  1677. $t test -f $(APP)/apps/my_app/my_app.d
  1678. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1679. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1680. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1681. $i "Check that the application was compiled correctly"
  1682. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1683. {ok, _Apps } = application:ensure_all_started(my_app), \
  1684. {ok, Mods = [use_blue, use_red]} \
  1685. = application:get_key(my_app, modules), \
  1686. [{module, M} = code:load_file(M) || M <- Mods], \
  1687. halt()"
  1688. $i "Touch one .hrl file; check that only required files are rebuilt"
  1689. # The use_red.erl gets touched because of its dependency to red.hrl.
  1690. $t printf "%s\n" \
  1691. $(APP)/apps/my_app/my_app.d \
  1692. $(APP)/apps/my_app/ebin/my_app.app \
  1693. $(APP)/apps/my_app/ebin/use_red.beam \
  1694. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1695. $t $(SLEEP)
  1696. $t touch $(APP)/apps/my_lib/include/red.hrl
  1697. $t $(SLEEP)
  1698. $t $(MAKE) -C $(APP) $v
  1699. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  1700. $t rm $(APP)/EXPECT
  1701. $i "Check that the application was compiled correctly"
  1702. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1703. {ok, _Apps } = application:ensure_all_started(my_app), \
  1704. {ok, Mods = [use_blue, use_red]} \
  1705. = application:get_key(my_app, modules), \
  1706. [{module, M} = code:load_file(M) || M <- Mods], \
  1707. halt()"
  1708. $i "Clean the application"
  1709. $t $(MAKE) -C $(APP) clean $v
  1710. $i "Check that source files still exist"
  1711. $t test -f $(APP)/Makefile
  1712. $t test -f $(APP)/erlang.mk
  1713. $t test -f $(APP)/apps/my_lib/Makefile
  1714. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1715. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1716. $t test -f $(APP)/apps/my_app/Makefile
  1717. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1718. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1719. ifdef LEGACY
  1720. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  1721. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  1722. endif
  1723. $i "Check that all build artifacts are removed"
  1724. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1725. $t test ! -e $(APP)/apps/my_lib/ebin/
  1726. $t test ! -e $(APP)/apps/my_app/my_app.d
  1727. $t test ! -e $(APP)/apps/my_app/ebin/
  1728. $i "Build the application again"
  1729. $t $(MAKE) -C $(APP) $v
  1730. $i "Check that all compiled files exist"
  1731. $t test -f $(APP)/apps/my_app/my_app.d
  1732. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1733. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1734. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1735. $i "Check that the application was compiled correctly"
  1736. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1737. {ok, _Apps } = application:ensure_all_started(my_app), \
  1738. {ok, Mods = [use_blue, use_red]} \
  1739. = application:get_key(my_app, modules), \
  1740. [{module, M} = code:load_file(M) || M <- Mods], \
  1741. halt()"
  1742. core-app-hrl-multiapps-include-lib-recursive: build clean
  1743. $i "Create a multi application repository with no root application"
  1744. $t mkdir $(APP)/
  1745. $t cp ../erlang.mk $(APP)/
  1746. $t echo "include erlang.mk" > $(APP)/Makefile
  1747. $i "Create a new application named my_app"
  1748. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1749. $i "Create a new library named my_lib"
  1750. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1751. $i "Add my_lib as LOCAL_DEPS of my_app"
  1752. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1753. $i "Generate .hrl files"
  1754. $t mkdir $(APP)/apps/my_lib/include/
  1755. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl $(APP)/apps/my_lib/include/pill.hrl
  1756. $t echo "-include(\"pill.hrl\")." > $(APP)/apps/my_lib/include/red.hrl
  1757. $i "Generate .erl files dependent from headers"
  1758. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1759. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1760. $i "Build the application"
  1761. $t $(MAKE) -C $(APP) $v
  1762. $i "Check that all compiled files exist"
  1763. $t test -f $(APP)/apps/my_app/my_app.d
  1764. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1765. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1766. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1767. $i "Check that the application was compiled correctly"
  1768. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1769. {ok, _Apps } = application:ensure_all_started(my_app), \
  1770. {ok, Mods = [use_blue, use_red]} \
  1771. = application:get_key(my_app, modules), \
  1772. [{module, M} = code:load_file(M) || M <- Mods], \
  1773. halt()"
  1774. $i "Touch one .hrl file; check that only required files are rebuilt"
  1775. # The use_red.erl gets touched because of its dependency to red.hrl.
  1776. $t printf "%s\n" \
  1777. $(APP)/apps/my_app/my_app.d \
  1778. $(APP)/apps/my_app/ebin/my_app.app \
  1779. $(APP)/apps/my_app/ebin/use_red.beam \
  1780. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1781. $t $(SLEEP)
  1782. $t touch $(APP)/apps/my_lib/include/pill.hrl
  1783. $t $(SLEEP)
  1784. $t $(MAKE) -C $(APP) $v
  1785. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1786. $t rm $(APP)/EXPECT
  1787. $i "Check that the application was compiled correctly"
  1788. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1789. {ok, _Apps } = application:ensure_all_started(my_app), \
  1790. {ok, Mods = [use_blue, use_red]} \
  1791. = application:get_key(my_app, modules), \
  1792. [{module, M} = code:load_file(M) || M <- Mods], \
  1793. halt()"
  1794. $i "Clean the application"
  1795. $t $(MAKE) -C $(APP) clean $v
  1796. $i "Check that source files still exist"
  1797. $t test -f $(APP)/Makefile
  1798. $t test -f $(APP)/erlang.mk
  1799. $t test -f $(APP)/apps/my_lib/Makefile
  1800. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1801. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1802. $t test -f $(APP)/apps/my_lib/include/pill.hrl
  1803. $t test -f $(APP)/apps/my_app/Makefile
  1804. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1805. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1806. ifdef LEGACY
  1807. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  1808. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  1809. endif
  1810. $i "Check that all build artifacts are removed"
  1811. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1812. $t test ! -e $(APP)/apps/my_lib/ebin/
  1813. $t test ! -e $(APP)/apps/my_app/my_app.d
  1814. $t test ! -e $(APP)/apps/my_app/ebin/
  1815. $i "Build the application again"
  1816. $t $(MAKE) -C $(APP) $v
  1817. $i "Check that all compiled files exist"
  1818. $t test -f $(APP)/apps/my_app/my_app.d
  1819. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1820. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1821. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1822. $i "Check that the application was compiled correctly"
  1823. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1824. {ok, _Apps } = application:ensure_all_started(my_app), \
  1825. {ok, Mods = [use_blue, use_red]} \
  1826. = application:get_key(my_app, modules), \
  1827. [{module, M} = code:load_file(M) || M <- Mods], \
  1828. halt()"
  1829. core-app-hrl-include-lib-src: build clean
  1830. $i "Bootstrap a new OTP library named $(APP)"
  1831. $t mkdir $(APP)/
  1832. $t cp ../erlang.mk $(APP)/
  1833. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1834. $t touch $(APP)/src/blue.hrl $(APP)/src/red.hrl
  1835. $i "Generate .erl files dependent from headers"
  1836. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1837. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1838. $i "Build the application"
  1839. $t $(MAKE) -C $(APP) $v
  1840. $i "Check that all compiled files exist"
  1841. $t test -f $(APP)/$(APP).d
  1842. $t test -f $(APP)/ebin/$(APP).app
  1843. $t test -f $(APP)/ebin/use_blue.beam
  1844. $t test -f $(APP)/ebin/use_red.beam
  1845. $i "Check that the application was compiled correctly"
  1846. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1847. ok = application:start($(APP)), \
  1848. {ok, Mods = [use_blue, use_red]} \
  1849. = application:get_key($(APP), modules), \
  1850. [{module, M} = code:load_file(M) || M <- Mods], \
  1851. halt()"
  1852. $i "Touch one .hrl file; check that only required files are rebuilt"
  1853. # The use_red.erl gets touched because of its dependency to red.hrl.
  1854. $t printf "%s\n" \
  1855. $(APP)/$(APP).d \
  1856. $(APP)/ebin/$(APP).app \
  1857. $(APP)/ebin/use_red.beam \
  1858. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1859. $t $(SLEEP)
  1860. $t touch $(APP)/src/red.hrl
  1861. $t $(SLEEP)
  1862. $t $(MAKE) -C $(APP) $v
  1863. $t find $(APP) -type f -newer $(APP)/src/red.hrl | sort | diff $(APP)/EXPECT -
  1864. $t rm $(APP)/EXPECT
  1865. $i "Check that the application was compiled correctly"
  1866. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1867. ok = application:start($(APP)), \
  1868. {ok, Mods = [use_blue, use_red]} \
  1869. = application:get_key($(APP), modules), \
  1870. [{module, M} = code:load_file(M) || M <- Mods], \
  1871. halt()"
  1872. $i "Clean the application"
  1873. $t $(MAKE) -C $(APP) clean $v
  1874. $i "Check that source files still exist"
  1875. $t test -f $(APP)/Makefile
  1876. $t test -f $(APP)/erlang.mk
  1877. $t test -f $(APP)/src/blue.hrl
  1878. $t test -f $(APP)/src/red.hrl
  1879. ifdef LEGACY
  1880. $t test -f $(APP)/src/$(APP).app.src
  1881. endif
  1882. $t test -f $(APP)/src/use_blue.erl
  1883. $t test -f $(APP)/src/use_red.erl
  1884. $i "Check that all build artifacts are removed"
  1885. $t test ! -e $(APP)/$(APP).d
  1886. $t test ! -e $(APP)/ebin/
  1887. $i "Build the application again"
  1888. $t $(MAKE) -C $(APP) $v
  1889. $i "Check that all compiled files exist"
  1890. $t test -f $(APP)/$(APP).d
  1891. $t test -f $(APP)/ebin/$(APP).app
  1892. $t test -f $(APP)/ebin/use_blue.beam
  1893. $t test -f $(APP)/ebin/use_red.beam
  1894. $i "Check that the application was compiled correctly"
  1895. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1896. ok = application:start($(APP)), \
  1897. {ok, Mods = [use_blue, use_red]} \
  1898. = application:get_key($(APP), modules), \
  1899. [{module, M} = code:load_file(M) || M <- Mods], \
  1900. halt()"
  1901. core-app-hrl-include-lib-src-recursive: build clean
  1902. $i "Bootstrap a new OTP library named $(APP)"
  1903. $t mkdir $(APP)/
  1904. $t cp ../erlang.mk $(APP)/
  1905. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1906. $i "Generate .hrl files"
  1907. $t touch $(APP)/src/blue.hrl $(APP)/src/pill.hrl
  1908. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/src/red.hrl
  1909. $i "Generate .erl files dependent from headers"
  1910. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1911. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1912. $i "Build the application"
  1913. $t $(MAKE) -C $(APP) $v
  1914. $i "Check that all compiled files exist"
  1915. $t test -f $(APP)/$(APP).d
  1916. $t test -f $(APP)/ebin/$(APP).app
  1917. $t test -f $(APP)/ebin/use_blue.beam
  1918. $t test -f $(APP)/ebin/use_red.beam
  1919. $i "Check that the application was compiled correctly"
  1920. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1921. ok = application:start($(APP)), \
  1922. {ok, Mods = [use_blue, use_red]} \
  1923. = application:get_key($(APP), modules), \
  1924. [{module, M} = code:load_file(M) || M <- Mods], \
  1925. halt()"
  1926. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1927. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1928. $t printf "%s\n" \
  1929. $(APP)/$(APP).d \
  1930. $(APP)/ebin/$(APP).app \
  1931. $(APP)/ebin/use_red.beam \
  1932. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1933. $t $(SLEEP)
  1934. $t touch $(APP)/src/pill.hrl
  1935. $t $(SLEEP)
  1936. $t $(MAKE) -C $(APP) $v
  1937. $t find $(APP) -type f -newer $(APP)/src/pill.hrl | sort | diff $(APP)/EXPECT -
  1938. $t rm $(APP)/EXPECT
  1939. $i "Check that the application was compiled correctly"
  1940. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1941. ok = application:start($(APP)), \
  1942. {ok, Mods = [use_blue, use_red]} \
  1943. = application:get_key($(APP), modules), \
  1944. [{module, M} = code:load_file(M) || M <- Mods], \
  1945. halt()"
  1946. $i "Clean the application"
  1947. $t $(MAKE) -C $(APP) clean $v
  1948. $i "Check that source files still exist"
  1949. $t test -f $(APP)/Makefile
  1950. $t test -f $(APP)/erlang.mk
  1951. $t test -f $(APP)/src/blue.hrl
  1952. $t test -f $(APP)/src/pill.hrl
  1953. $t test -f $(APP)/src/red.hrl
  1954. ifdef LEGACY
  1955. $t test -f $(APP)/src/$(APP).app.src
  1956. endif
  1957. $t test -f $(APP)/src/use_blue.erl
  1958. $t test -f $(APP)/src/use_red.erl
  1959. $i "Check that all build artifacts are removed"
  1960. $t test ! -e $(APP)/$(APP).d
  1961. $t test ! -e $(APP)/ebin/
  1962. $i "Build the application again"
  1963. $t $(MAKE) -C $(APP) $v
  1964. $i "Check that all compiled files exist"
  1965. $t test -f $(APP)/$(APP).d
  1966. $t test -f $(APP)/ebin/$(APP).app
  1967. $t test -f $(APP)/ebin/use_blue.beam
  1968. $t test -f $(APP)/ebin/use_red.beam
  1969. $i "Check that the application was compiled correctly"
  1970. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1971. ok = application:start($(APP)), \
  1972. {ok, Mods = [use_blue, use_red]} \
  1973. = application:get_key($(APP), modules), \
  1974. [{module, M} = code:load_file(M) || M <- Mods], \
  1975. halt()"
  1976. core-app-hrl-deps: build clean
  1977. $i "Create a multi application repository with no root application"
  1978. $t mkdir $(APP)/
  1979. $t cp ../erlang.mk $(APP)/
  1980. $t echo "include erlang.mk" > $(APP)/Makefile
  1981. $i "Create a new application named my_app"
  1982. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1983. $t echo "DEPS = cowlib" > $(APP)/apps/my_app/Makefile
  1984. $t echo "include ../../erlang.mk" >> $(APP)/apps/my_app/Makefile
  1985. $t printf "%s\n" "-module(boy)." "-include_lib(\"cowlib/include/cow_inline.hrl\")." > $(APP)/apps/my_app/src/boy.erl
  1986. $t printf "%s\n" "-module(girl)." > $(APP)/apps/my_app/src/girl.erl
  1987. $i "Build the application"
  1988. $t $(MAKE) -C $(APP) $v
  1989. $i "Check that all compiled files exist"
  1990. $t test -f $(APP)/apps/my_app/my_app.d
  1991. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1992. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  1993. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  1994. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  1995. ifndef LEGACY
  1996. $i "Check that the application was compiled correctly"
  1997. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  1998. ok = application:load(my_app), \
  1999. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  2000. true = lists:member(cowlib, MyAppDeps), \
  2001. halt()"
  2002. endif
  2003. $i "Touch cowlib .hrl file; check that only required files are rebuilt"
  2004. $t printf "%s\n" \
  2005. $(APP)/apps/my_app/my_app.d \
  2006. $(APP)/apps/my_app/ebin/my_app.app \
  2007. $(APP)/apps/my_app/ebin/boy.beam \
  2008. $(APP)/apps/my_app/src/boy.erl | sort > $(APP)/EXPECT
  2009. $t $(SLEEP)
  2010. $t touch $(APP)/deps/cowlib/include/cow_inline.hrl
  2011. $t $(SLEEP)
  2012. $t $(MAKE) -C $(APP) $v
  2013. $t find $(APP)/apps/my_app -type f -newer $(APP)/deps/cowlib/include/cow_inline.hrl | sort | diff $(APP)/EXPECT -
  2014. $t rm $(APP)/EXPECT
  2015. $i "Clean Cowlib"
  2016. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  2017. $i "Check that Cowlib compiled files were removed"
  2018. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  2019. $i "Build the application again"
  2020. $t $(MAKE) -C $(APP) $v
  2021. $i "Check that Cowlib compiled files exist"
  2022. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  2023. $i "Clean the application"
  2024. $t $(MAKE) -C $(APP) clean $v
  2025. $i "Check that Cowlib is still here"
  2026. $t test -d $(APP)/deps/cowlib
  2027. $i "Check that all relevant files were removed"
  2028. $t test ! -e $(APP)/apps/my_app/my_app.d
  2029. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  2030. $t test ! -e $(APP)/apps/my_app/ebin/boy.beam
  2031. $t test ! -e $(APP)/apps/my_app/ebin/girl.beam
  2032. $i "Distclean the application"
  2033. $t $(MAKE) -C $(APP) distclean $v
  2034. $i "Check that all relevant files were removed"
  2035. $t test ! -e $(APP)/deps
  2036. $i "Build the application"
  2037. $t $(MAKE) -C $(APP) $v
  2038. $i "Check that all compiled files exist"
  2039. $t test -f $(APP)/apps/my_app/my_app.d
  2040. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2041. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  2042. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  2043. $t test -d $(APP)/deps/cowlib
  2044. ifndef LEGACY
  2045. $i "Check that the application was compiled correctly"
  2046. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  2047. ok = application:load(my_app), \
  2048. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  2049. true = lists:member(cowlib, MyAppDeps), \
  2050. halt()"
  2051. endif
  2052. core-app-hrl-include-loop: build clean
  2053. $i "Bootstrap a new OTP library named $(APP)"
  2054. $t mkdir $(APP)/
  2055. $t cp ../erlang.mk $(APP)/
  2056. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2057. $i "Generate .hrl files with header loop"
  2058. $t mkdir $(APP)/include/
  2059. $t printf "%s\n" "-include(\"blue.hrl\")." > $(APP)/include/red.hrl
  2060. $t printf "%s\n" "-include(\"red.hrl\")." > $(APP)/include/blue.hrl
  2061. $i "Generate .erl files dependent from headers"
  2062. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2063. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2064. $i "Build the application. Compilation should fail"
  2065. $t ! $(MAKE) -C $(APP) $v
  2066. $i "Check .d file"
  2067. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2068. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2069. core-app-hrl-include_lib-loop: build clean
  2070. $i "Bootstrap a new OTP library named $(APP)"
  2071. $t mkdir $(APP)/
  2072. $t cp ../erlang.mk $(APP)/
  2073. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2074. $i "Generate .hrl files with heaeder loop"
  2075. $t mkdir $(APP)/include/
  2076. $t printf "%s\n" "-include_lib(\"blue.hrl\")." > $(APP)/include/red.hrl
  2077. $t printf "%s\n" "-include_lib(\"red.hrl\")." > $(APP)/include/blue.hrl
  2078. $i "Generate .erl files dependent from headers"
  2079. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2080. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2081. $i "Build the application. Compilation should fail"
  2082. $t ! $(MAKE) -C $(APP) $v
  2083. $i "Check .d file"
  2084. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2085. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2086. core-app-hrl-include-loop-define-protected: build clean
  2087. $i "Bootstrap a new OTP library named $(APP)"
  2088. $t mkdir $(APP)/
  2089. $t cp ../erlang.mk $(APP)/
  2090. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2091. $i "Generate .hrl files with hrl loop protection "
  2092. $t mkdir $(APP)/include/
  2093. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2094. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2095. $i "Generate .erl files dependent from headers"
  2096. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2097. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2098. $i "Build the application. Compilation should fail"
  2099. $t ! $(MAKE) -C $(APP) $v ; ret=$$?
  2100. $i "Check .d file"
  2101. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2102. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2103. core-app-hrl-include_lib-loop-define-protected: build clean
  2104. $i "Bootstrap a new OTP library named $(APP)"
  2105. $t mkdir $(APP)/
  2106. $t cp ../erlang.mk $(APP)/
  2107. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2108. $i "Generate .hrl files with hrl loop protection "
  2109. $t mkdir $(APP)/include/
  2110. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2111. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2112. $i "Generate .erl files dependent from headers"
  2113. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2114. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2115. $i "Build the application"
  2116. $t $(MAKE) -C $(APP) $v ; ret=$$?
  2117. $i "Check .d file"
  2118. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2119. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2120. core-app-hrl-multiapps-include-loop-define-protected: build clean
  2121. $i "Create a multi application repository with no root application"
  2122. $t mkdir $(APP)/
  2123. $t cp ../erlang.mk $(APP)/
  2124. $t echo "include erlang.mk" > $(APP)/Makefile
  2125. $i "Create a new application named my_app"
  2126. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  2127. $i "Create a new library named my_lib"
  2128. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  2129. $i "Add my_lib as LOCAL_DEPS of my_app"
  2130. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  2131. $i "Generate .hrl files"
  2132. $t mkdir $(APP)/apps/my_lib/include/
  2133. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/apps/my_lib/include/blue.hrl
  2134. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/apps/my_lib/include/red.hrl
  2135. $i "Generate .erl files dependent from headers"
  2136. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  2137. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  2138. $i "Build the application"
  2139. $t $(MAKE) -C $(APP) $v
  2140. $i "Check that all compiled files exist"
  2141. $t test -f $(APP)/apps/my_app/my_app.d
  2142. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2143. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2144. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2145. $i "Check that the application was compiled correctly"
  2146. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2147. {ok, _Apps } = application:ensure_all_started(my_app), \
  2148. {ok, Mods = [use_blue, use_red]} \
  2149. = application:get_key(my_app, modules), \
  2150. [{module, M} = code:load_file(M) || M <- Mods], \
  2151. halt()"
  2152. $i "Touch one .hrl file; check that only required files are rebuilt"
  2153. # The use_red.erl gets touched because of its dependency to red.hrl.
  2154. $t printf "%s\n" \
  2155. $(APP)/apps/my_app/my_app.d \
  2156. $(APP)/apps/my_app/ebin/my_app.app \
  2157. $(APP)/apps/my_app/ebin/use_red.beam \
  2158. $(APP)/apps/my_app/src/use_red.erl \
  2159. $(APP)/apps/my_app/src/use_blue.erl \
  2160. $(APP)/apps/my_app/ebin/use_blue.beam | sort > $(APP)/EXPECT
  2161. $t $(SLEEP)
  2162. $t touch $(APP)/apps/my_lib/include/red.hrl
  2163. $t $(SLEEP)
  2164. $t $(MAKE) -C $(APP) $v
  2165. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  2166. $t rm $(APP)/EXPECT
  2167. $i "Check that the application was compiled correctly"
  2168. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2169. {ok, _Apps } = application:ensure_all_started(my_app), \
  2170. {ok, Mods = [use_blue, use_red]} \
  2171. = application:get_key(my_app, modules), \
  2172. [{module, M} = code:load_file(M) || M <- Mods], \
  2173. halt()"
  2174. $i "Clean the application"
  2175. $t $(MAKE) -C $(APP) clean $v
  2176. $i "Check that source files still exist"
  2177. $t test -f $(APP)/Makefile
  2178. $t test -f $(APP)/erlang.mk
  2179. $t test -f $(APP)/apps/my_lib/Makefile
  2180. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  2181. $t test -f $(APP)/apps/my_lib/include/red.hrl
  2182. $t test -f $(APP)/apps/my_app/Makefile
  2183. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  2184. $t test -f $(APP)/apps/my_app/src/use_red.erl
  2185. ifdef LEGACY
  2186. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  2187. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  2188. endif
  2189. $i "Check that all build artifacts are removed"
  2190. $t test ! -e $(APP)/apps/my_lib/my_app.d
  2191. $t test ! -e $(APP)/apps/my_lib/ebin/
  2192. $t test ! -e $(APP)/apps/my_app/my_app.d
  2193. $t test ! -e $(APP)/apps/my_app/ebin/
  2194. $i "Build the application again"
  2195. $t $(MAKE) -C $(APP) $v
  2196. $i "Check that all compiled files exist"
  2197. $t test -f $(APP)/apps/my_app/my_app.d
  2198. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2199. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2200. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2201. $i "Check that the application was compiled correctly"
  2202. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2203. {ok, _Apps } = application:ensure_all_started(my_app), \
  2204. {ok, Mods = [use_blue, use_red]} \
  2205. = application:get_key(my_app, modules), \
  2206. [{module, M} = code:load_file(M) || M <- Mods], \
  2207. halt()"