core_app.mk 43 KB

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