core_app.mk 45 KB

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