core_app.mk 88 KB

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