core_app.mk 87 KB

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