core_app.mk 44 KB

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