core_app.mk 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. # Core: Building applications.
  2. CORE_APP_CASES = asn1 error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive mib no-app no-makedep xrl xrl-include yrl yrl-include
  3. CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
  4. CORE_APP_CLEAN_TARGETS = $(addprefix clean-,$(CORE_APP_TARGETS))
  5. .PHONY: core-app $(CORE_APP_TARGETS) clean-core-app $(CORE_APP_CLEAN_TARGETS)
  6. clean-core-app: $(CORE_APP_CLEAN_TARGETS)
  7. $(CORE_APP_CLEAN_TARGETS):
  8. $t rm -rf $(APP_TO_CLEAN)/
  9. core-app: $(CORE_APP_TARGETS)
  10. core-app-asn1: build clean-core-app-asn1
  11. $i "Bootstrap a new OTP library named $(APP)"
  12. $t mkdir $(APP)/
  13. $t cp ../erlang.mk $(APP)/
  14. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  15. $i "Download .asn1 files from Erlang/OTP"
  16. $t mkdir $(APP)/asn1/
  17. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  18. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  19. $i "Generate .erl files dependent from headers generated by .asn1 files"
  20. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  21. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  22. $i "Generate an unrelated .hrl file"
  23. $t mkdir $(APP)/include/
  24. $t touch $(APP)/include/unrelated.hrl
  25. $i "Build the application"
  26. $t $(MAKE) -C $(APP) $v
  27. $i "Check that all compiled files exist"
  28. $t test -f $(APP)/$(APP).d
  29. $t test -f $(APP)/ebin/$(APP).app
  30. $t test -f $(APP)/ebin/CAP.beam
  31. $t test -f $(APP)/ebin/Def.beam
  32. $t test -f $(APP)/ebin/use_cap.beam
  33. $t test -f $(APP)/ebin/use_def.beam
  34. $t test -f $(APP)/include/CAP.asn1db
  35. $t test -f $(APP)/include/CAP.hrl
  36. $t test -f $(APP)/include/Def.asn1db
  37. $t test -f $(APP)/include/Def.hrl
  38. $t test -f $(APP)/src/CAP.erl
  39. $t test -f $(APP)/src/Def.erl
  40. $i "Check that the application was compiled correctly"
  41. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  42. ok = application:start($(APP)), \
  43. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  44. = application:get_key($(APP), modules), \
  45. [{module, M} = code:load_file(M) || M <- Mods], \
  46. halt()"
  47. $i "Touch one .asn1 file; check that only required files are rebuilt"
  48. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  49. $t printf "%s\n" \
  50. $(APP)/$(APP).d \
  51. $(APP)/ebin/$(APP).app \
  52. $(APP)/ebin/CAP.beam \
  53. $(APP)/ebin/use_cap.beam \
  54. $(APP)/include/CAP.asn1db \
  55. $(APP)/include/CAP.hrl \
  56. $(APP)/src/CAP.erl \
  57. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  58. $t touch $(APP)/asn1/CAP.asn1
  59. $t $(MAKE) -C $(APP) $v
  60. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  61. $t rm $(APP)/EXPECT
  62. $i "Check that the application was compiled correctly"
  63. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  64. ok = application:start($(APP)), \
  65. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  66. = application:get_key($(APP), modules), \
  67. [{module, M} = code:load_file(M) || M <- Mods], \
  68. halt()"
  69. $i "Clean the application"
  70. $t $(MAKE) -C $(APP) clean $v
  71. $i "Check that source files still exist"
  72. $t test -f $(APP)/Makefile
  73. $t test -f $(APP)/erlang.mk
  74. $t test -f $(APP)/asn1/CAP.asn1
  75. $t test -f $(APP)/asn1/Def.asn1
  76. $t test -f $(APP)/include/unrelated.hrl
  77. $t test -f $(APP)/src/$(APP).app.src
  78. $t test -f $(APP)/src/use_cap.erl
  79. $t test -f $(APP)/src/use_def.erl
  80. $i "Check that all build artifacts are removed, including intermediates"
  81. $t test ! -e $(APP)/$(APP).d
  82. $t test ! -e $(APP)/ebin/
  83. $t test ! -e $(APP)/include/CAP.asn1db
  84. $t test ! -e $(APP)/include/CAP.hrl
  85. $t test ! -e $(APP)/include/Def.asn1db
  86. $t test ! -e $(APP)/include/Def.hrl
  87. $t test ! -e $(APP)/src/CAP.erl
  88. $t test ! -e $(APP)/src/Def.erl
  89. $i "Build the application again"
  90. $t $(MAKE) -C $(APP) $v
  91. $i "Check that all compiled files exist"
  92. $t test -f $(APP)/$(APP).d
  93. $t test -f $(APP)/ebin/$(APP).app
  94. $t test -f $(APP)/ebin/CAP.beam
  95. $t test -f $(APP)/ebin/Def.beam
  96. $t test -f $(APP)/ebin/use_cap.beam
  97. $t test -f $(APP)/ebin/use_def.beam
  98. $t test -f $(APP)/include/CAP.asn1db
  99. $t test -f $(APP)/include/CAP.hrl
  100. $t test -f $(APP)/include/Def.asn1db
  101. $t test -f $(APP)/include/Def.hrl
  102. $t test -f $(APP)/src/CAP.erl
  103. $t test -f $(APP)/src/Def.erl
  104. $i "Check that the application was compiled correctly"
  105. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  106. ok = application:start($(APP)), \
  107. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  108. = application:get_key($(APP), modules), \
  109. [{module, M} = code:load_file(M) || M <- Mods], \
  110. halt()"
  111. core-app-error: build clean-core-app-error
  112. $i "Bootstrap a new OTP library named $(APP)"
  113. $t mkdir $(APP)/
  114. $t cp ../erlang.mk $(APP)/
  115. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  116. $i "Generate a bad .erl files"
  117. $t touch $(APP)/src/breaking.erl
  118. $i "Generate unrelated .erl files"
  119. $t echo "-module(boy)." > $(APP)/src/boy.erl
  120. $t echo "-module(girl)." > $(APP)/src/girl.erl
  121. $i "Check that trying to build returns non-zero"
  122. $t if $(MAKE) -C $(APP) $v; then false; fi
  123. core-app-generate-erl: build clean-core-app-generate-erl
  124. $i "Bootstrap a new OTP library named $(APP)"
  125. $t mkdir $(APP)/
  126. $t cp ../erlang.mk $(APP)/
  127. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  128. $i "Create a fake script file to be used as dependency"
  129. $t touch $(APP)/script.sh
  130. $i "Append rules to the Makefile to generate a .erl module"
  131. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  132. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  133. $i "Generate unrelated .erl files"
  134. $t echo "-module(boy)." > $(APP)/src/boy.erl
  135. $t echo "-module(girl)." > $(APP)/src/girl.erl
  136. $i "Build the application"
  137. $t $(MAKE) -C $(APP) $v
  138. $i "Check that all compiled files exist"
  139. $t test -f $(APP)/$(APP).d
  140. $t test -f $(APP)/ebin/$(APP).app
  141. $t test -f $(APP)/ebin/boy.beam
  142. $t test -f $(APP)/ebin/generated.beam
  143. $t test -f $(APP)/ebin/girl.beam
  144. $t test -f $(APP)/src/generated.erl
  145. $i "Check that the application was compiled correctly"
  146. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  147. ok = application:start($(APP)), \
  148. {ok, Mods = [boy, generated, girl]} \
  149. = application:get_key($(APP), modules), \
  150. [{module, M} = code:load_file(M) || M <- Mods], \
  151. halt()"
  152. $i "Touch the script file; check that only required files are rebuilt"
  153. $t printf "%s\n" \
  154. $(APP)/$(APP).d \
  155. $(APP)/ebin/$(APP).app \
  156. $(APP)/ebin/generated.beam \
  157. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  158. $t touch $(APP)/script.sh
  159. $t $(MAKE) -C $(APP) $v
  160. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  161. $t rm $(APP)/EXPECT
  162. $i "Check that the application was compiled correctly"
  163. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  164. ok = application:start($(APP)), \
  165. {ok, Mods = [boy, generated, girl]} \
  166. = application:get_key($(APP), modules), \
  167. [{module, M} = code:load_file(M) || M <- Mods], \
  168. halt()"
  169. $i "Clean the application"
  170. $t $(MAKE) -C $(APP) clean $v
  171. $i "Check that source files still exist"
  172. $t test -f $(APP)/Makefile
  173. $t test -f $(APP)/erlang.mk
  174. $t test -f $(APP)/script.sh
  175. $t test -f $(APP)/src/$(APP).app.src
  176. $t test -f $(APP)/src/boy.erl
  177. $t test -f $(APP)/src/girl.erl
  178. $i "Check that the generated .erl file still exists"
  179. $t test -f $(APP)/src/generated.erl
  180. $i "Check that all build artifacts are removed"
  181. $t test ! -e $(APP)/$(APP).d
  182. $t test ! -e $(APP)/ebin/
  183. $i "Add a rule to remove the generated .erl file on clean"
  184. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  185. $i "Clean the application again"
  186. $t $(MAKE) -C $(APP) clean $v
  187. $i "Check that the generated .erl file was removed"
  188. $t test ! -e $(APP)/src/generated.erl
  189. $i "Build the application again"
  190. $t $(MAKE) -C $(APP) $v
  191. $i "Check that all compiled files exist"
  192. $t test -f $(APP)/$(APP).d
  193. $t test -f $(APP)/ebin/$(APP).app
  194. $t test -f $(APP)/ebin/boy.beam
  195. $t test -f $(APP)/ebin/generated.beam
  196. $t test -f $(APP)/ebin/girl.beam
  197. $t test -f $(APP)/src/generated.erl
  198. $i "Check that the application was compiled correctly"
  199. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  200. ok = application:start($(APP)), \
  201. {ok, Mods = [boy, generated, girl]} \
  202. = application:get_key($(APP), modules), \
  203. [{module, M} = code:load_file(M) || M <- Mods], \
  204. halt()"
  205. core-app-generate-erl-include: build clean-core-app-generate-erl-include
  206. $i "Bootstrap a new OTP library named $(APP)"
  207. $t mkdir $(APP)/
  208. $t cp ../erlang.mk $(APP)/
  209. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  210. $i "Create a fake script file to be used as dependency"
  211. $t touch $(APP)/script.sh
  212. $i "Append rules to the Makefile to generate a .erl module"
  213. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  214. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  215. $i "Generate the .hrl file"
  216. $t mkdir $(APP)/include/
  217. $t touch $(APP)/include/included.hrl
  218. $i "Generate unrelated .erl files"
  219. $t echo "-module(boy)." > $(APP)/src/boy.erl
  220. $t echo "-module(girl)." > $(APP)/src/girl.erl
  221. $i "Build the application"
  222. $t $(MAKE) -C $(APP) $v
  223. $i "Check that all compiled files exist"
  224. $t test -f $(APP)/$(APP).d
  225. $t test -f $(APP)/ebin/$(APP).app
  226. $t test -f $(APP)/ebin/boy.beam
  227. $t test -f $(APP)/ebin/generated.beam
  228. $t test -f $(APP)/ebin/girl.beam
  229. $t test -f $(APP)/src/generated.erl
  230. $i "Check that the application was compiled correctly"
  231. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  232. ok = application:start($(APP)), \
  233. {ok, Mods = [boy, generated, girl]} \
  234. = application:get_key($(APP), modules), \
  235. [{module, M} = code:load_file(M) || M <- Mods], \
  236. halt()"
  237. $i "Touch the .hrl file; check that only required files are rebuilt"
  238. $t printf "%s\n" \
  239. $(APP)/$(APP).d \
  240. $(APP)/ebin/$(APP).app \
  241. $(APP)/ebin/generated.beam \
  242. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  243. $t touch $(APP)/include/included.hrl
  244. $t $(MAKE) -C $(APP) $v
  245. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  246. $t rm $(APP)/EXPECT
  247. $i "Check that the application was compiled correctly"
  248. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  249. ok = application:start($(APP)), \
  250. {ok, Mods = [boy, generated, girl]} \
  251. = application:get_key($(APP), modules), \
  252. [{module, M} = code:load_file(M) || M <- Mods], \
  253. halt()"
  254. core-app-generate-erl-prepend: build clean-core-app-generate-erl-prepend
  255. $i "Bootstrap a new OTP library named $(APP)"
  256. $t mkdir $(APP)/
  257. $t cp ../erlang.mk $(APP)/
  258. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  259. $i "Create a fake script file to be used as dependency"
  260. $t touch $(APP)/script.sh
  261. $i "Generate a Makefile and prepend rules that generate a .erl module"
  262. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  263. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  264. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  265. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  266. $t echo "include erlang.mk" >> $(APP)/Makefile
  267. $i "Generate unrelated .erl files"
  268. $t echo "-module(boy)." > $(APP)/src/boy.erl
  269. $t echo "-module(girl)." > $(APP)/src/girl.erl
  270. $i "Build the application"
  271. $t $(MAKE) -C $(APP) $v
  272. $i "Check that all compiled files exist"
  273. $t test -f $(APP)/$(APP).d
  274. $t test -f $(APP)/ebin/$(APP).app
  275. $t test -f $(APP)/ebin/boy.beam
  276. $t test -f $(APP)/ebin/generated.beam
  277. $t test -f $(APP)/ebin/girl.beam
  278. $t test -f $(APP)/src/generated.erl
  279. $i "Check that the application was compiled correctly"
  280. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  281. ok = application:start($(APP)), \
  282. {ok, Mods = [boy, generated, girl]} \
  283. = application:get_key($(APP), modules), \
  284. [{module, M} = code:load_file(M) || M <- Mods], \
  285. halt()"
  286. $i "Touch the script file; check that only required files are rebuilt"
  287. $t printf "%s\n" \
  288. $(APP)/$(APP).d \
  289. $(APP)/ebin/$(APP).app \
  290. $(APP)/ebin/generated.beam \
  291. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  292. $t touch $(APP)/script.sh
  293. $t $(MAKE) -C $(APP) $v
  294. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  295. $t rm $(APP)/EXPECT
  296. $i "Check that the application was compiled correctly"
  297. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  298. ok = application:start($(APP)), \
  299. {ok, Mods = [boy, generated, girl]} \
  300. = application:get_key($(APP), modules), \
  301. [{module, M} = code:load_file(M) || M <- Mods], \
  302. halt()"
  303. $i "Clean the application"
  304. $t $(MAKE) -C $(APP) clean $v
  305. $i "Check that source files still exist"
  306. $t test -f $(APP)/Makefile
  307. $t test -f $(APP)/erlang.mk
  308. $t test -f $(APP)/script.sh
  309. $t test -f $(APP)/src/$(APP).app.src
  310. $t test -f $(APP)/src/boy.erl
  311. $t test -f $(APP)/src/girl.erl
  312. $i "Check that the generated .erl file still exists"
  313. $t test -f $(APP)/src/generated.erl
  314. $i "Check that all build artifacts are removed"
  315. $t test ! -e $(APP)/$(APP).d
  316. $t test ! -e $(APP)/ebin/
  317. $i "Add a rule to remove the generated .erl file on clean"
  318. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  319. $i "Clean the application again"
  320. $t $(MAKE) -C $(APP) clean $v
  321. $i "Check that the generated .erl file was removed"
  322. $t test ! -e $(APP)/src/generated.erl
  323. $i "Build the application again"
  324. $t $(MAKE) -C $(APP) $v
  325. $i "Check that all compiled files exist"
  326. $t test -f $(APP)/$(APP).d
  327. $t test -f $(APP)/ebin/$(APP).app
  328. $t test -f $(APP)/ebin/boy.beam
  329. $t test -f $(APP)/ebin/generated.beam
  330. $t test -f $(APP)/ebin/girl.beam
  331. $t test -f $(APP)/src/generated.erl
  332. $i "Check that the application was compiled correctly"
  333. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  334. ok = application:start($(APP)), \
  335. {ok, Mods = [boy, generated, girl]} \
  336. = application:get_key($(APP), modules), \
  337. [{module, M} = code:load_file(M) || M <- Mods], \
  338. halt()"
  339. core-app-hrl: build clean-core-app-hrl
  340. $i "Bootstrap a new OTP library named $(APP)"
  341. $t mkdir $(APP)/
  342. $t cp ../erlang.mk $(APP)/
  343. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  344. $i "Generate .hrl files"
  345. $t mkdir $(APP)/include/
  346. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  347. $i "Generate .erl files dependent from headers"
  348. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  349. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  350. $i "Build the application"
  351. $t $(MAKE) -C $(APP) $v
  352. $i "Check that all compiled files exist"
  353. $t test -f $(APP)/$(APP).d
  354. $t test -f $(APP)/ebin/$(APP).app
  355. $t test -f $(APP)/ebin/use_blue.beam
  356. $t test -f $(APP)/ebin/use_red.beam
  357. $i "Check that the application was compiled correctly"
  358. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  359. ok = application:start($(APP)), \
  360. {ok, Mods = [use_blue, use_red]} \
  361. = application:get_key($(APP), modules), \
  362. [{module, M} = code:load_file(M) || M <- Mods], \
  363. halt()"
  364. $i "Touch one .hrl file; check that only required files are rebuilt"
  365. # The use_red.erl gets touched because of its dependency to red.hrl.
  366. $t printf "%s\n" \
  367. $(APP)/$(APP).d \
  368. $(APP)/ebin/$(APP).app \
  369. $(APP)/ebin/use_red.beam \
  370. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  371. $t touch $(APP)/include/red.hrl
  372. $t $(MAKE) -C $(APP) $v
  373. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  374. $t rm $(APP)/EXPECT
  375. $i "Check that the application was compiled correctly"
  376. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  377. ok = application:start($(APP)), \
  378. {ok, Mods = [use_blue, use_red]} \
  379. = application:get_key($(APP), modules), \
  380. [{module, M} = code:load_file(M) || M <- Mods], \
  381. halt()"
  382. $i "Clean the application"
  383. $t $(MAKE) -C $(APP) clean $v
  384. $i "Check that source files still exist"
  385. $t test -f $(APP)/Makefile
  386. $t test -f $(APP)/erlang.mk
  387. $t test -f $(APP)/include/blue.hrl
  388. $t test -f $(APP)/include/red.hrl
  389. $t test -f $(APP)/src/$(APP).app.src
  390. $t test -f $(APP)/src/use_blue.erl
  391. $t test -f $(APP)/src/use_red.erl
  392. $i "Check that all build artifacts are removed"
  393. $t test ! -e $(APP)/$(APP).d
  394. $t test ! -e $(APP)/ebin/
  395. $i "Build the application again"
  396. $t $(MAKE) -C $(APP) $v
  397. $i "Check that all compiled files exist"
  398. $t test -f $(APP)/$(APP).d
  399. $t test -f $(APP)/ebin/$(APP).app
  400. $t test -f $(APP)/ebin/use_blue.beam
  401. $t test -f $(APP)/ebin/use_red.beam
  402. $i "Check that the application was compiled correctly"
  403. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  404. ok = application:start($(APP)), \
  405. {ok, Mods = [use_blue, use_red]} \
  406. = application:get_key($(APP), modules), \
  407. [{module, M} = code:load_file(M) || M <- Mods], \
  408. halt()"
  409. core-app-hrl-recursive: build clean-core-app-hrl-recursive
  410. $i "Bootstrap a new OTP library named $(APP)"
  411. $t mkdir $(APP)/
  412. $t cp ../erlang.mk $(APP)/
  413. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  414. $i "Generate .hrl files"
  415. $t mkdir $(APP)/include/
  416. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  417. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  418. $i "Generate .erl files dependent from headers"
  419. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  420. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  421. $i "Build the application"
  422. $t $(MAKE) -C $(APP) $v
  423. $i "Check that all compiled files exist"
  424. $t test -f $(APP)/$(APP).d
  425. $t test -f $(APP)/ebin/$(APP).app
  426. $t test -f $(APP)/ebin/use_blue.beam
  427. $t test -f $(APP)/ebin/use_red.beam
  428. $i "Check that the application was compiled correctly"
  429. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  430. ok = application:start($(APP)), \
  431. {ok, Mods = [use_blue, use_red]} \
  432. = application:get_key($(APP), modules), \
  433. [{module, M} = code:load_file(M) || M <- Mods], \
  434. halt()"
  435. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  436. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  437. $t printf "%s\n" \
  438. $(APP)/$(APP).d \
  439. $(APP)/ebin/$(APP).app \
  440. $(APP)/ebin/use_red.beam \
  441. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  442. $t touch $(APP)/include/pill.hrl
  443. $t $(MAKE) -C $(APP) $v
  444. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  445. $t rm $(APP)/EXPECT
  446. $i "Check that the application was compiled correctly"
  447. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  448. ok = application:start($(APP)), \
  449. {ok, Mods = [use_blue, use_red]} \
  450. = application:get_key($(APP), modules), \
  451. [{module, M} = code:load_file(M) || M <- Mods], \
  452. halt()"
  453. $i "Clean the application"
  454. $t $(MAKE) -C $(APP) clean $v
  455. $i "Check that source files still exist"
  456. $t test -f $(APP)/Makefile
  457. $t test -f $(APP)/erlang.mk
  458. $t test -f $(APP)/include/blue.hrl
  459. $t test -f $(APP)/include/pill.hrl
  460. $t test -f $(APP)/include/red.hrl
  461. $t test -f $(APP)/src/$(APP).app.src
  462. $t test -f $(APP)/src/use_blue.erl
  463. $t test -f $(APP)/src/use_red.erl
  464. $i "Check that all build artifacts are removed"
  465. $t test ! -e $(APP)/$(APP).d
  466. $t test ! -e $(APP)/ebin/
  467. $i "Build the application again"
  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/use_blue.beam
  473. $t test -f $(APP)/ebin/use_red.beam
  474. $i "Check that the application was compiled correctly"
  475. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  476. ok = application:start($(APP)), \
  477. {ok, Mods = [use_blue, use_red]} \
  478. = application:get_key($(APP), modules), \
  479. [{module, M} = code:load_file(M) || M <- Mods], \
  480. halt()"
  481. core-app-mib: build clean-core-app-mib
  482. $i "Bootstrap a new OTP library named $(APP)"
  483. $t mkdir $(APP)/
  484. $t cp ../erlang.mk $(APP)/
  485. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  486. $i "Download .mib files from Erlang/OTP"
  487. $t mkdir $(APP)/mibs/
  488. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  489. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
  490. $i "Generate .erl files dependent from headers generated by .mib files"
  491. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  492. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  493. $i "Generate an unrelated .hrl file"
  494. $t mkdir $(APP)/include/
  495. $t touch $(APP)/include/unrelated.hrl
  496. $i "Build the application"
  497. $t $(MAKE) -C $(APP) $v
  498. $i "Check that all compiled files exist"
  499. $t test -f $(APP)/$(APP).d
  500. $t test -f $(APP)/ebin/$(APP).app
  501. $t test -f $(APP)/ebin/use_v1.beam
  502. $t test -f $(APP)/ebin/use_v2.beam
  503. $t test -f $(APP)/include/EX1-MIB.hrl
  504. $t test -f $(APP)/include/OTP-REG.hrl
  505. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  506. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  507. $i "Check that the application was compiled correctly"
  508. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  509. ok = application:start($(APP)), \
  510. {ok, Mods = [use_v1, use_v2]} \
  511. = application:get_key($(APP), modules), \
  512. [{module, M} = code:load_file(M) || M <- Mods], \
  513. halt()"
  514. $i "Touch one .mib file; check that only required files are rebuilt"
  515. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  516. $t printf "%s\n" \
  517. $(APP)/$(APP).d \
  518. $(APP)/ebin/$(APP).app \
  519. $(APP)/ebin/use_v1.beam \
  520. $(APP)/include/EX1-MIB.hrl \
  521. $(APP)/priv/mibs/EX1-MIB.bin \
  522. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  523. $t touch $(APP)/mibs/EX1-MIB.mib
  524. $t $(MAKE) -C $(APP) $v
  525. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  526. $t rm $(APP)/EXPECT
  527. $i "Check that the application was compiled correctly"
  528. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  529. ok = application:start($(APP)), \
  530. {ok, Mods = [use_v1, use_v2]} \
  531. = application:get_key($(APP), modules), \
  532. [{module, M} = code:load_file(M) || M <- Mods], \
  533. halt()"
  534. $i "Clean the application"
  535. $t $(MAKE) -C $(APP) clean $v
  536. $i "Check that source files still exist"
  537. $t test -f $(APP)/Makefile
  538. $t test -f $(APP)/erlang.mk
  539. $t test -f $(APP)/include/unrelated.hrl
  540. $t test -f $(APP)/mibs/EX1-MIB.mib
  541. $t test -f $(APP)/mibs/OTP-REG.mib
  542. $t test -f $(APP)/src/$(APP).app.src
  543. $t test -f $(APP)/src/use_v1.erl
  544. $t test -f $(APP)/src/use_v2.erl
  545. $i "Check that all build artifacts are removed, including intermediates"
  546. $t test ! -e $(APP)/$(APP).d
  547. $t test ! -e $(APP)/ebin/
  548. $t test ! -e $(APP)/include/EX1-MIB.hrl
  549. $t test ! -e $(APP)/include/OTP-REG.hrl
  550. $t test ! -e $(APP)/priv/mibs/
  551. $i "Build the application again"
  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_v1.beam
  557. $t test -f $(APP)/ebin/use_v2.beam
  558. $t test -f $(APP)/include/EX1-MIB.hrl
  559. $t test -f $(APP)/include/OTP-REG.hrl
  560. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  561. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  562. $i "Check that the application was compiled correctly"
  563. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  564. ok = application:start($(APP)), \
  565. {ok, Mods = [use_v1, use_v2]} \
  566. = application:get_key($(APP), modules), \
  567. [{module, M} = code:load_file(M) || M <- Mods], \
  568. halt()"
  569. core-app-no-app: build clean-core-app-no-app
  570. $i "Bootstrap a project without an OTP library"
  571. $t mkdir $(APP)/
  572. $t cp ../erlang.mk $(APP)/
  573. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  574. $t rm -rf $(APP)/src
  575. $i "Build the project"
  576. $t $(MAKE) -C $(APP) $v
  577. core-app-no-makedep: build clean-core-app-no-makedep
  578. $i "Bootstrap a new OTP library named $(APP)"
  579. $t mkdir $(APP)/
  580. $t cp ../erlang.mk $(APP)/
  581. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  582. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  583. $t sed -i.bak '2i\
  584. NO_MAKEDEP ?= 1\
  585. ' $(APP)/Makefile
  586. $i "Generate .hrl files"
  587. $t mkdir $(APP)/include/
  588. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  589. $i "Generate .erl files dependent from headers"
  590. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  591. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  592. $i "Build the application"
  593. $t $(MAKE) -C $(APP) $v
  594. $i "Check that all compiled files exist"
  595. $t test -f $(APP)/$(APP).d
  596. $t test -f $(APP)/ebin/$(APP).app
  597. $t test -f $(APP)/ebin/use_blue.beam
  598. $t test -f $(APP)/ebin/use_red.beam
  599. $i "Check that the application was compiled correctly"
  600. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  601. ok = application:start($(APP)), \
  602. {ok, Mods = [use_blue, use_red]} \
  603. = application:get_key($(APP), modules), \
  604. [{module, M} = code:load_file(M) || M <- Mods], \
  605. halt()"
  606. $i "Touch one .hrl file; check that only required files are rebuilt"
  607. # The use_red.erl gets touched because of its dependency to red.hrl.
  608. $t printf "%s\n" \
  609. $(APP)/ebin/$(APP).app \
  610. $(APP)/ebin/use_red.beam \
  611. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  612. $t touch $(APP)/include/red.hrl
  613. $t $(MAKE) -C $(APP) $v
  614. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  615. $t rm $(APP)/EXPECT
  616. $i "Check that the application was compiled correctly"
  617. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  618. ok = application:start($(APP)), \
  619. {ok, Mods = [use_blue, use_red]} \
  620. = application:get_key($(APP), modules), \
  621. [{module, M} = code:load_file(M) || M <- Mods], \
  622. halt()"
  623. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  624. # The use_red.erl gets touched because of its dependency to red.hrl.
  625. $t printf "%s\n" \
  626. $(APP)/$(APP).d \
  627. $(APP)/ebin/$(APP).app \
  628. $(APP)/ebin/use_red.beam \
  629. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  630. $t touch $(APP)/include/red.hrl
  631. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  632. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  633. $t rm $(APP)/EXPECT
  634. $i "Check that the application was compiled correctly"
  635. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  636. ok = application:start($(APP)), \
  637. {ok, Mods = [use_blue, use_red]} \
  638. = application:get_key($(APP), modules), \
  639. [{module, M} = code:load_file(M) || M <- Mods], \
  640. halt()"
  641. $i "Clean the application"
  642. $t $(MAKE) -C $(APP) clean $v
  643. $i "Check that source files still exist"
  644. $t test -f $(APP)/Makefile
  645. $t test -f $(APP)/erlang.mk
  646. $t test -f $(APP)/include/blue.hrl
  647. $t test -f $(APP)/include/red.hrl
  648. $t test -f $(APP)/src/$(APP).app.src
  649. $t test -f $(APP)/src/use_blue.erl
  650. $t test -f $(APP)/src/use_red.erl
  651. $i "Check that all build artifacts are removed"
  652. $t test ! -e $(APP)/$(APP).d
  653. $t test ! -e $(APP)/ebin/
  654. $i "Build the application again"
  655. $t $(MAKE) -C $(APP) $v
  656. $i "Check that all compiled files exist"
  657. $t test -f $(APP)/$(APP).d
  658. $t test -f $(APP)/ebin/$(APP).app
  659. $t test -f $(APP)/ebin/use_blue.beam
  660. $t test -f $(APP)/ebin/use_red.beam
  661. $i "Check that the application was compiled correctly"
  662. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  663. ok = application:start($(APP)), \
  664. {ok, Mods = [use_blue, use_red]} \
  665. = application:get_key($(APP), modules), \
  666. [{module, M} = code:load_file(M) || M <- Mods], \
  667. halt()"
  668. core-app-xrl: build clean-core-app-xrl
  669. $i "Bootstrap a new OTP library named $(APP)"
  670. $t mkdir $(APP)/
  671. $t cp ../erlang.mk $(APP)/
  672. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  673. $i "Download .xrl files from Robert"
  674. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  675. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  676. $i "Generate unrelated .erl files"
  677. $t echo "-module(boy)." > $(APP)/src/boy.erl
  678. $t echo "-module(girl)." > $(APP)/src/girl.erl
  679. $i "Disable warnings; our test .xrl files aren't perfect"
  680. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  681. $i "Build the application"
  682. $t $(MAKE) -C $(APP) $v
  683. $i "Check that all compiled files exist"
  684. $t test -f $(APP)/$(APP).d
  685. $t test -f $(APP)/ebin/$(APP).app
  686. $t test -f $(APP)/ebin/boy.beam
  687. $t test -f $(APP)/ebin/erlang_scan.beam
  688. $t test -f $(APP)/ebin/girl.beam
  689. $t test -f $(APP)/ebin/lfe_scan.beam
  690. $t test -f $(APP)/src/erlang_scan.erl
  691. $t test -f $(APP)/src/lfe_scan.erl
  692. $i "Check that the application was compiled correctly"
  693. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  694. ok = application:start($(APP)), \
  695. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  696. = application:get_key($(APP), modules), \
  697. [{module, M} = code:load_file(M) || M <- Mods], \
  698. halt()"
  699. $i "Touch one .xrl file; check that only required files are rebuilt"
  700. $t printf "%s\n" \
  701. $(APP)/$(APP).d \
  702. $(APP)/ebin/$(APP).app \
  703. $(APP)/ebin/erlang_scan.beam \
  704. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  705. $t touch $(APP)/src/erlang_scan.xrl
  706. $t $(MAKE) -C $(APP) $v
  707. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  708. $t rm $(APP)/EXPECT
  709. $i "Check that the application was compiled correctly"
  710. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  711. ok = application:start($(APP)), \
  712. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  713. = application:get_key($(APP), modules), \
  714. [{module, M} = code:load_file(M) || M <- Mods], \
  715. halt()"
  716. $i "Clean the application"
  717. $t $(MAKE) -C $(APP) clean $v
  718. $i "Check that source files still exist"
  719. $t test -f $(APP)/Makefile
  720. $t test -f $(APP)/erlang.mk
  721. $t test -f $(APP)/src/$(APP).app.src
  722. $t test -f $(APP)/src/boy.erl
  723. $t test -f $(APP)/src/erlang_scan.xrl
  724. $t test -f $(APP)/src/girl.erl
  725. $t test -f $(APP)/src/lfe_scan.xrl
  726. $i "Check that all build artifacts are removed, including intermediates"
  727. $t test ! -e $(APP)/$(APP).d
  728. $t test ! -e $(APP)/ebin/
  729. $t test ! -e $(APP)/src/erlang_scan.erl
  730. $t test ! -e $(APP)/src/lfe_scan.erl
  731. $i "Build the application again"
  732. $t $(MAKE) -C $(APP) $v
  733. $i "Check that all compiled files exist"
  734. $t test -f $(APP)/$(APP).d
  735. $t test -f $(APP)/ebin/$(APP).app
  736. $t test -f $(APP)/ebin/boy.beam
  737. $t test -f $(APP)/ebin/erlang_scan.beam
  738. $t test -f $(APP)/ebin/girl.beam
  739. $t test -f $(APP)/ebin/lfe_scan.beam
  740. $t test -f $(APP)/src/erlang_scan.erl
  741. $t test -f $(APP)/src/lfe_scan.erl
  742. $i "Check that the application was compiled correctly"
  743. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  744. ok = application:start($(APP)), \
  745. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  746. = application:get_key($(APP), modules), \
  747. [{module, M} = code:load_file(M) || M <- Mods], \
  748. halt()"
  749. core-app-xrl-include: build clean-core-app-xrl-include
  750. $i "Bootstrap a new OTP library named $(APP)"
  751. $t mkdir $(APP)/
  752. $t cp ../erlang.mk $(APP)/
  753. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  754. $i "Download a .xrl file with numerous includes from Gordon"
  755. $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
  756. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  757. $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
  758. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  759. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  760. $i "Generate unrelated .erl files"
  761. $t echo "-module(boy)." > $(APP)/src/boy.erl
  762. $t echo "-module(girl)." > $(APP)/src/girl.erl
  763. $i "Disable warnings; our test .xrl files aren't perfect"
  764. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  765. $i "Build the application"
  766. $t $(MAKE) -C $(APP) $v
  767. $i "Check that all compiled files exist"
  768. $t test -f $(APP)/$(APP).d
  769. $t test -f $(APP)/ebin/$(APP).app
  770. $t test -f $(APP)/ebin/boy.beam
  771. $t test -f $(APP)/ebin/girl.beam
  772. $t test -f $(APP)/ebin/xfl_lexer.beam
  773. $t test -f $(APP)/src/xfl_lexer.erl
  774. $i "Check that the application was compiled correctly"
  775. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  776. ok = application:start($(APP)), \
  777. {ok, Mods = [boy, girl, xfl_lexer]} \
  778. = application:get_key($(APP), modules), \
  779. [{module, M} = code:load_file(M) || M <- Mods], \
  780. halt()"
  781. $i "Touch the .xrl file; check that only required files are rebuilt"
  782. $t printf "%s\n" \
  783. $(APP)/$(APP).d \
  784. $(APP)/ebin/$(APP).app \
  785. $(APP)/ebin/xfl_lexer.beam \
  786. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  787. $t touch $(APP)/src/xfl_lexer.xrl
  788. $t $(MAKE) -C $(APP) $v
  789. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  790. $t rm $(APP)/EXPECT
  791. $i "Check that the application was compiled correctly"
  792. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  793. ok = application:start($(APP)), \
  794. {ok, Mods = [boy, girl, xfl_lexer]} \
  795. = application:get_key($(APP), modules), \
  796. [{module, M} = code:load_file(M) || M <- Mods], \
  797. halt()"
  798. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  799. $t printf "%s\n" \
  800. $(APP)/$(APP).d \
  801. $(APP)/ebin/$(APP).app \
  802. $(APP)/ebin/xfl_lexer.beam \
  803. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  804. $t touch $(APP)/src/typechecks.hrl
  805. $t $(MAKE) -C $(APP) $v
  806. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  807. $t rm $(APP)/EXPECT
  808. $i "Check that the application was compiled correctly"
  809. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  810. ok = application:start($(APP)), \
  811. {ok, Mods = [boy, girl, xfl_lexer]} \
  812. = application:get_key($(APP), modules), \
  813. [{module, M} = code:load_file(M) || M <- Mods], \
  814. halt()"
  815. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  816. $t printf "%s\n" \
  817. $(APP)/$(APP).d \
  818. $(APP)/ebin/$(APP).app \
  819. $(APP)/ebin/xfl_lexer.beam \
  820. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  821. $t touch $(APP)/src/errvals.hrl
  822. $t $(MAKE) -C $(APP) $v
  823. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  824. $t rm $(APP)/EXPECT
  825. $i "Check that the application was compiled correctly"
  826. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  827. ok = application:start($(APP)), \
  828. {ok, Mods = [boy, girl, xfl_lexer]} \
  829. = application:get_key($(APP), modules), \
  830. [{module, M} = code:load_file(M) || M <- Mods], \
  831. halt()"
  832. $i "Clean the application"
  833. $t $(MAKE) -C $(APP) clean $v
  834. $i "Check that source files still exist"
  835. $t test -f $(APP)/Makefile
  836. $t test -f $(APP)/erlang.mk
  837. $t test -f $(APP)/src/$(APP).app.src
  838. $t test -f $(APP)/src/boy.erl
  839. $t test -f $(APP)/src/girl.erl
  840. $t test -f $(APP)/src/errvals.hrl
  841. $t test -f $(APP)/src/muin_proc_dict.hrl
  842. $t test -f $(APP)/src/muin_records.hrl
  843. $t test -f $(APP)/src/typechecks.hrl
  844. $t test -f $(APP)/src/xfl_lexer.xrl
  845. $i "Check that all build artifacts are removed, including intermediates"
  846. $t test ! -e $(APP)/$(APP).d
  847. $t test ! -e $(APP)/ebin/
  848. $t test ! -e $(APP)/src/xfl_lexer.erl
  849. $i "Build the application again"
  850. $t $(MAKE) -C $(APP) $v
  851. $i "Check that all compiled files exist"
  852. $t test -f $(APP)/$(APP).d
  853. $t test -f $(APP)/ebin/$(APP).app
  854. $t test -f $(APP)/ebin/boy.beam
  855. $t test -f $(APP)/ebin/girl.beam
  856. $t test -f $(APP)/ebin/xfl_lexer.beam
  857. $t test -f $(APP)/src/xfl_lexer.erl
  858. $i "Check that the application was compiled correctly"
  859. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  860. ok = application:start($(APP)), \
  861. {ok, Mods = [boy, girl, xfl_lexer]} \
  862. = application:get_key($(APP), modules), \
  863. [{module, M} = code:load_file(M) || M <- Mods], \
  864. halt()"
  865. core-app-yrl: build clean-core-app-yrl
  866. $i "Bootstrap a new OTP library named $(APP)"
  867. $t mkdir $(APP)/
  868. $t cp ../erlang.mk $(APP)/
  869. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  870. $i "Download .yrl files from Erlang/OTP"
  871. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  872. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  873. $i "Generate unrelated .erl files"
  874. $t echo "-module(boy)." > $(APP)/src/boy.erl
  875. $t echo "-module(girl)." > $(APP)/src/girl.erl
  876. $i "Build the application"
  877. $t $(MAKE) -C $(APP) $v
  878. $i "Check that all compiled files exist"
  879. $t test -f $(APP)/$(APP).d
  880. $t test -f $(APP)/ebin/$(APP).app
  881. $t test -f $(APP)/ebin/boy.beam
  882. $t test -f $(APP)/ebin/girl.beam
  883. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  884. $t test -f $(APP)/ebin/xref_parser.beam
  885. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  886. $t test -f $(APP)/src/xref_parser.erl
  887. $i "Check that the application was compiled correctly"
  888. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  889. ok = application:start($(APP)), \
  890. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  891. = application:get_key($(APP), modules), \
  892. [{module, M} = code:load_file(M) || M <- Mods], \
  893. halt()"
  894. $i "Touch one .yrl file; check that only required files are rebuilt"
  895. $t printf "%s\n" \
  896. $(APP)/$(APP).d \
  897. $(APP)/ebin/$(APP).app \
  898. $(APP)/ebin/xref_parser.beam \
  899. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  900. $t touch $(APP)/src/xref_parser.yrl
  901. $t $(MAKE) -C $(APP) $v
  902. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  903. $t rm $(APP)/EXPECT
  904. $i "Check that the application was compiled correctly"
  905. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  906. ok = application:start($(APP)), \
  907. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  908. = application:get_key($(APP), modules), \
  909. [{module, M} = code:load_file(M) || M <- Mods], \
  910. halt()"
  911. $i "Clean the application"
  912. $t $(MAKE) -C $(APP) clean $v
  913. $i "Check that source files still exist"
  914. $t test -f $(APP)/Makefile
  915. $t test -f $(APP)/erlang.mk
  916. $t test -f $(APP)/src/$(APP).app.src
  917. $t test -f $(APP)/src/boy.erl
  918. $t test -f $(APP)/src/girl.erl
  919. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  920. $t test -f $(APP)/src/xref_parser.yrl
  921. $i "Check that all build artifacts are removed, including intermediates"
  922. $t test ! -e $(APP)/$(APP).d
  923. $t test ! -e $(APP)/ebin/
  924. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  925. $t test ! -e $(APP)/src/xref_parser.erl
  926. $i "Build the application again"
  927. $t $(MAKE) -C $(APP) $v
  928. $i "Check that all compiled files exist"
  929. $t test -f $(APP)/$(APP).d
  930. $t test -f $(APP)/ebin/$(APP).app
  931. $t test -f $(APP)/ebin/boy.beam
  932. $t test -f $(APP)/ebin/girl.beam
  933. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  934. $t test -f $(APP)/ebin/xref_parser.beam
  935. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  936. $t test -f $(APP)/src/xref_parser.erl
  937. $i "Check that the application was compiled correctly"
  938. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  939. ok = application:start($(APP)), \
  940. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  941. = application:get_key($(APP), modules), \
  942. [{module, M} = code:load_file(M) || M <- Mods], \
  943. halt()"
  944. core-app-yrl-include: build clean-core-app-yrl-include
  945. $i "Bootstrap a new OTP library named $(APP)"
  946. $t mkdir $(APP)/
  947. $t cp ../erlang.mk $(APP)/
  948. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  949. $i "Download a .yrl file with includes from Erlang/OTP"
  950. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  951. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  952. $i "Generate unrelated .erl files"
  953. $t echo "-module(boy)." > $(APP)/src/boy.erl
  954. $t echo "-module(girl)." > $(APP)/src/girl.erl
  955. $i "Build the application"
  956. $t $(MAKE) -C $(APP) $v
  957. $i "Check that all compiled files exist"
  958. $t test -f $(APP)/$(APP).d
  959. $t test -f $(APP)/ebin/$(APP).app
  960. $t test -f $(APP)/ebin/boy.beam
  961. $t test -f $(APP)/ebin/core_parse.beam
  962. $t test -f $(APP)/ebin/girl.beam
  963. $t test -f $(APP)/src/core_parse.erl
  964. $i "Check that the application was compiled correctly"
  965. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  966. ok = application:start($(APP)), \
  967. {ok, Mods = [boy, core_parse, girl]} \
  968. = application:get_key($(APP), modules), \
  969. [{module, M} = code:load_file(M) || M <- Mods], \
  970. halt()"
  971. $i "Touch the .yrl file; check that only required files are rebuilt"
  972. $t printf "%s\n" \
  973. $(APP)/$(APP).d \
  974. $(APP)/ebin/$(APP).app \
  975. $(APP)/ebin/core_parse.beam \
  976. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  977. $t touch $(APP)/src/core_parse.yrl
  978. $t $(MAKE) -C $(APP) $v
  979. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  980. $t rm $(APP)/EXPECT
  981. $i "Check that the application was compiled correctly"
  982. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  983. ok = application:start($(APP)), \
  984. {ok, Mods = [boy, core_parse, girl]} \
  985. = application:get_key($(APP), modules), \
  986. [{module, M} = code:load_file(M) || M <- Mods], \
  987. halt()"
  988. $i "Touch the .hrl file included; check that only required files are rebuilt"
  989. $t printf "%s\n" \
  990. $(APP)/$(APP).d \
  991. $(APP)/ebin/$(APP).app \
  992. $(APP)/ebin/core_parse.beam \
  993. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  994. $t touch $(APP)/src/core_parse.hrl
  995. $t $(MAKE) -C $(APP) $v
  996. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  997. $t rm $(APP)/EXPECT
  998. $i "Check that the application was compiled correctly"
  999. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1000. ok = application:start($(APP)), \
  1001. {ok, Mods = [boy, core_parse, girl]} \
  1002. = application:get_key($(APP), modules), \
  1003. [{module, M} = code:load_file(M) || M <- Mods], \
  1004. halt()"
  1005. $i "Clean the application"
  1006. $t $(MAKE) -C $(APP) clean $v
  1007. $i "Check that source files still exist"
  1008. $t test -f $(APP)/Makefile
  1009. $t test -f $(APP)/erlang.mk
  1010. $t test -f $(APP)/src/$(APP).app.src
  1011. $t test -f $(APP)/src/boy.erl
  1012. $t test -f $(APP)/src/core_parse.hrl
  1013. $t test -f $(APP)/src/core_parse.yrl
  1014. $t test -f $(APP)/src/girl.erl
  1015. $i "Check that all build artifacts are removed, including intermediates"
  1016. $t test ! -e $(APP)/$(APP).d
  1017. $t test ! -e $(APP)/ebin/
  1018. $t test ! -e $(APP)/src/core_parse.erl
  1019. $i "Build the application again"
  1020. $t $(MAKE) -C $(APP) $v
  1021. $i "Check that all compiled files exist"
  1022. $t test -f $(APP)/$(APP).d
  1023. $t test -f $(APP)/ebin/$(APP).app
  1024. $t test -f $(APP)/ebin/boy.beam
  1025. $t test -f $(APP)/ebin/core_parse.beam
  1026. $t test -f $(APP)/ebin/girl.beam
  1027. $t test -f $(APP)/src/core_parse.erl
  1028. $i "Check that the application was compiled correctly"
  1029. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1030. ok = application:start($(APP)), \
  1031. {ok, Mods = [boy, core_parse, girl]} \
  1032. = application:get_key($(APP), modules), \
  1033. [{module, M} = code:load_file(M) || M <- Mods], \
  1034. halt()"