core_app.mk 78 KB

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