core_app.mk 87 KB

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