core_app.mk 44 KB

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