core_app.mk 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723
  1. # Core: Building applications.
  2. CORE_APP_CASES = appsrc-change asn1 auto-git-id env erlc-exclude erlc-opts erlc-opts-filter error extra-keys generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib name-special-char no-app no-makedep project-mod pt pt-erlc-opts xrl xrl-include yrl yrl-header yrl-include
  3. CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
  4. .PHONY: core-app $(CORE_APP_TARGETS)
  5. core-app: $(CORE_APP_TARGETS)
  6. ifdef LEGACY
  7. core-app-appsrc-change: build clean
  8. $i "Bootstrap a new OTP application named $(APP)"
  9. $t mkdir $(APP)/
  10. $t cp ../erlang.mk $(APP)/
  11. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  12. $i "Build the application"
  13. $t $(MAKE) -C $(APP) $v
  14. $i "Touch the .app.src file; check that only the .app file gets rebuilt"
  15. $t printf "%s\n" $(APP)/ebin/$(APP).app > $(APP)/EXPECT
  16. $t $(SLEEP)
  17. $t touch $(APP)/src/$(APP).app.src
  18. $t $(SLEEP)
  19. $t $(MAKE) -C $(APP) $v
  20. $t find $(APP) -type f -newer $(APP)/src/$(APP).app.src | sort | diff $(APP)/EXPECT -
  21. $t rm $(APP)/EXPECT
  22. endif
  23. core-app-asn1: build clean
  24. $i "Bootstrap a new OTP library named $(APP)"
  25. $t mkdir $(APP)/
  26. $t cp ../erlang.mk $(APP)/
  27. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  28. $i "Download .asn1 files from Erlang/OTP"
  29. $t mkdir $(APP)/asn1/
  30. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  31. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  32. $i "Generate .erl files dependent from headers generated by .asn1 files"
  33. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  34. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  35. $i "Generate an unrelated .hrl file"
  36. $t mkdir $(APP)/include/
  37. $t touch $(APP)/include/unrelated.hrl
  38. $i "Build the application"
  39. $t $(MAKE) -C $(APP) $v
  40. $i "Check that all compiled files exist"
  41. $t test -f $(APP)/$(APP).d
  42. $t test -f $(APP)/ebin/$(APP).app
  43. $t test -f $(APP)/ebin/CAP.beam
  44. $t test -f $(APP)/ebin/Def.beam
  45. $t test -f $(APP)/ebin/use_cap.beam
  46. $t test -f $(APP)/ebin/use_def.beam
  47. $t test -f $(APP)/include/CAP.asn1db
  48. $t test -f $(APP)/include/CAP.hrl
  49. $t test -f $(APP)/include/Def.asn1db
  50. $t test -f $(APP)/include/Def.hrl
  51. $t test -f $(APP)/src/CAP.erl
  52. $t test -f $(APP)/src/Def.erl
  53. $i "Check that the application was compiled correctly"
  54. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  55. ok = application:start($(APP)), \
  56. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  57. = application:get_key($(APP), modules), \
  58. [{module, M} = code:load_file(M) || M <- Mods], \
  59. halt()"
  60. $i "Touch one .asn1 file; check that only required files are rebuilt"
  61. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  62. $t printf "%s\n" \
  63. $(APP)/$(APP).d \
  64. $(APP)/ebin/$(APP).app \
  65. $(APP)/ebin/CAP.beam \
  66. $(APP)/ebin/use_cap.beam \
  67. $(APP)/include/CAP.asn1db \
  68. $(APP)/include/CAP.hrl \
  69. $(APP)/src/CAP.erl \
  70. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  71. $t $(SLEEP)
  72. $t touch $(APP)/asn1/CAP.asn1
  73. $t $(SLEEP)
  74. $t $(MAKE) -C $(APP) $v
  75. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  76. $t rm $(APP)/EXPECT
  77. $i "Check that the application was compiled correctly"
  78. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  79. ok = application:start($(APP)), \
  80. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  81. = application:get_key($(APP), modules), \
  82. [{module, M} = code:load_file(M) || M <- Mods], \
  83. halt()"
  84. $i "Clean the application"
  85. $t $(MAKE) -C $(APP) clean $v
  86. $i "Check that source files still exist"
  87. $t test -f $(APP)/Makefile
  88. $t test -f $(APP)/erlang.mk
  89. $t test -f $(APP)/asn1/CAP.asn1
  90. $t test -f $(APP)/asn1/Def.asn1
  91. $t test -f $(APP)/include/unrelated.hrl
  92. ifdef LEGACY
  93. $t test -f $(APP)/src/$(APP).app.src
  94. endif
  95. $t test -f $(APP)/src/use_cap.erl
  96. $t test -f $(APP)/src/use_def.erl
  97. $i "Check that all build artifacts are removed, including intermediates"
  98. $t test ! -e $(APP)/$(APP).d
  99. $t test ! -e $(APP)/ebin/
  100. $t test ! -e $(APP)/include/CAP.asn1db
  101. $t test ! -e $(APP)/include/CAP.hrl
  102. $t test ! -e $(APP)/include/Def.asn1db
  103. $t test ! -e $(APP)/include/Def.hrl
  104. $t test ! -e $(APP)/src/CAP.erl
  105. $t test ! -e $(APP)/src/Def.erl
  106. $i "Build the application again"
  107. $t $(MAKE) -C $(APP) $v
  108. $i "Check that all compiled files exist"
  109. $t test -f $(APP)/$(APP).d
  110. $t test -f $(APP)/ebin/$(APP).app
  111. $t test -f $(APP)/ebin/CAP.beam
  112. $t test -f $(APP)/ebin/Def.beam
  113. $t test -f $(APP)/ebin/use_cap.beam
  114. $t test -f $(APP)/ebin/use_def.beam
  115. $t test -f $(APP)/include/CAP.asn1db
  116. $t test -f $(APP)/include/CAP.hrl
  117. $t test -f $(APP)/include/Def.asn1db
  118. $t test -f $(APP)/include/Def.hrl
  119. $t test -f $(APP)/src/CAP.erl
  120. $t test -f $(APP)/src/Def.erl
  121. $i "Check that the application was compiled correctly"
  122. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  123. ok = application:start($(APP)), \
  124. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  125. = application:get_key($(APP), modules), \
  126. [{module, M} = code:load_file(M) || M <- Mods], \
  127. halt()"
  128. core-app-auto-git-id: build clean
  129. $i "Bootstrap a new OTP library named $(APP)"
  130. $t mkdir $(APP)/
  131. $t cp ../erlang.mk $(APP)/
  132. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  133. $i "Make it a git repository"
  134. $t cd $(APP) && \
  135. git init -q && \
  136. git config user.email "testsuite@erlang.mk" && \
  137. git config user.name "test suite" && \
  138. git add . && \
  139. git commit -q -m "Tests"
  140. $i "Build the application"
  141. $t $(MAKE) -C $(APP) $v
  142. ifdef LEGACY
  143. # Legacy replaces {id, "git"} always regardless of built as a dependency.
  144. $i "Check that the generated .app file has an id key"
  145. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  146. ok = application:start($(APP)), \
  147. {ok, ID} = application:get_key($(APP), id), \
  148. true = ID =/= [], \
  149. halt()"
  150. else
  151. # If there is no .app.src though, only fill in id when built as a dependency.
  152. $i "Check that the generated .app file has no id key"
  153. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  154. ok = application:start($(APP)), \
  155. {ok, []} = application:get_key($(APP), id), \
  156. halt()"
  157. endif
  158. $i "Clean the application"
  159. $t $(MAKE) -C $(APP) clean $v
  160. $i "Build the application with IS_DEP=1"
  161. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  162. $i "Check that the generated .app file has an id key"
  163. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  164. ok = application:start($(APP)), \
  165. {ok, ID} = application:get_key($(APP), id), \
  166. true = ID =/= [], \
  167. halt()"
  168. ifndef LEGACY
  169. core-app-env: build clean
  170. $i "Bootstrap a new OTP library named $(APP)"
  171. $t mkdir $(APP)/
  172. $t cp ../erlang.mk $(APP)/
  173. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  174. $i "Define PROJECT_ENV"
  175. $t echo "PROJECT_ENV = [{test_key, test_value}]" >> $(APP)/Makefile
  176. $i "Build the application"
  177. $t $(MAKE) -C $(APP) $v
  178. $i "Check that the application was compiled correctly"
  179. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  180. ok = application:load($(APP)), \
  181. {ok, test_value} = application:get_env($(APP), test_key), \
  182. halt()"
  183. $i "Define PROJECT_ENV with escape in string, special char"
  184. $t echo "PROJECT_ENV = [{test_atom, '\\\$$\$$test'}, {test_key, \"\\\"test_\\tvalue\\\"\"}]" >> $(APP)/Makefile
  185. $i "Build the application"
  186. $t $(MAKE) -C $(APP) $v
  187. $i "Check that the application was compiled correctly"
  188. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  189. ok = application:load($(APP)), \
  190. {ok, \"\\\"test_\\tvalue\\\"\"} = application:get_env($(APP), test_key), \
  191. {ok, '\\\$$test'} = application:get_env($(APP), test_atom), \
  192. halt()"
  193. endif
  194. core-app-erlc-exclude: build clean
  195. $i "Bootstrap a new OTP library named $(APP)"
  196. $t mkdir $(APP)/
  197. $t cp ../erlang.mk $(APP)/
  198. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  199. $i "Generate .erl files"
  200. $t echo "-module(boy)." > $(APP)/src/boy.erl
  201. $t echo "-module(girl)." > $(APP)/src/girl.erl
  202. $i "Exclude boy.erl from the compilation"
  203. $t echo "ERLC_EXCLUDE = boy" >> $(APP)/Makefile
  204. $i "Build the application"
  205. $t $(MAKE) -C $(APP) $v
  206. $i "Check that boy.erl was not compiled"
  207. $t test ! -e $(APP)/ebin/boy.beam
  208. $i "Check that the application was compiled correctly (without boy.erl)"
  209. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  210. ok = application:start($(APP)), \
  211. {ok, Mods = [girl]} \
  212. = application:get_key($(APP), modules), \
  213. [{module, M} = code:load_file(M) || M <- Mods], \
  214. halt()"
  215. core-app-erlc-opts: build clean
  216. $i "Bootstrap a new OTP library named $(APP)"
  217. $t mkdir $(APP)/
  218. $t cp ../erlang.mk $(APP)/
  219. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  220. $i "Define an empty ERLC_OPTS (without debug_info)"
  221. $t echo "ERLC_OPTS =" >> $(APP)/Makefile
  222. $i "Generate .erl files"
  223. $t echo "-module(boy)." > $(APP)/src/boy.erl
  224. $t echo "-module(girl)." > $(APP)/src/girl.erl
  225. $i "Build the application"
  226. $t $(MAKE) -C $(APP) $v
  227. $i "Check that the application was compiled correctly (without debug_info)"
  228. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  229. ok = application:start($(APP)), \
  230. {ok, Mods = [boy, girl]} \
  231. = application:get_key($(APP), modules), \
  232. [{module, M} = code:load_file(M) || M <- Mods], \
  233. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  234. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  235. halt()"
  236. core-app-erlc-opts-filter: build clean
  237. $i "Bootstrap a new OTP library named $(APP)"
  238. $t mkdir $(APP)/
  239. $t cp ../erlang.mk $(APP)/
  240. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  241. $i "Define ERLC_OPTS filtering out debug_info"
  242. $t echo "ERLC_OPTS := \$$(filter-out +debug_info,\$$(ERLC_OPTS))" >> $(APP)/Makefile
  243. $i "Generate .erl files"
  244. $t echo "-module(boy)." > $(APP)/src/boy.erl
  245. $t echo "-module(girl)." > $(APP)/src/girl.erl
  246. $i "Build the application"
  247. $t $(MAKE) -C $(APP) $v
  248. $i "Check that the application was compiled correctly (without debug_info)"
  249. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  250. ok = application:start($(APP)), \
  251. {ok, Mods = [boy, girl]} \
  252. = application:get_key($(APP), modules), \
  253. [{module, M} = code:load_file(M) || M <- Mods], \
  254. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  255. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  256. halt()"
  257. core-app-error: build clean
  258. $i "Bootstrap a new OTP library named $(APP)"
  259. $t mkdir $(APP)/
  260. $t cp ../erlang.mk $(APP)/
  261. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  262. $i "Generate a bad .erl files"
  263. $t touch $(APP)/src/breaking.erl
  264. $i "Generate unrelated .erl files"
  265. $t echo "-module(boy)." > $(APP)/src/boy.erl
  266. $t echo "-module(girl)." > $(APP)/src/girl.erl
  267. $i "Check that trying to build returns non-zero"
  268. $t ! $(MAKE) -C $(APP) $v
  269. ifndef LEGACY
  270. core-app-extra-keys: build clean
  271. $i "Bootstrap a new OTP library named $(APP)"
  272. $t mkdir $(APP)/
  273. $t cp ../erlang.mk $(APP)/
  274. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  275. $i "Define PROJECT_APP_EXTRA_KEYS"
  276. $t printf "define PROJECT_APP_EXTRA_KEYS\n\t{maxT, 10000},\n\t{non_standard_key, test_value}\nendef\n" >> $(APP)/Makefile
  277. $i "Build the application"
  278. $t $(MAKE) -C $(APP) $v
  279. $i "Check that the application was compiled correctly"
  280. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  281. ok = application:load($(APP)), \
  282. {ok, 10000} = application:get_key($(APP), maxT), \
  283. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  284. {ok, [App]} = file:consult(AppFile), \
  285. {application, $(APP), Props} = App, \
  286. test_value = proplists:get_value(non_standard_key, Props),\
  287. halt()"
  288. $i "Define PROJECT_APP_EXTRA_KEYS with escape in string, special char"
  289. $t echo "PROJECT_APP_EXTRA_KEYS = {non_standard_atom, '\\\$$\$$my_app'}, {non_standard_string, \"\\\"test_\\tvalue\\\"\"}" >> $(APP)/Makefile
  290. $i "Build the application"
  291. $t $(MAKE) -C $(APP) $v
  292. $i "Check that the application was compiled correctly"
  293. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  294. ok = application:load($(APP)), \
  295. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  296. {ok, [App]} = file:consult(AppFile), \
  297. {application, $(APP), Props} = App, \
  298. '\\\$$my_app' = proplists:get_value(non_standard_atom, Props),\
  299. \"\\\"test_\\tvalue\\\"\" = proplists:get_value(non_standard_string, Props),\
  300. halt()"
  301. endif
  302. core-app-generate-erl: build clean
  303. $i "Bootstrap a new OTP library named $(APP)"
  304. $t mkdir $(APP)/
  305. $t cp ../erlang.mk $(APP)/
  306. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  307. $i "Create a fake script file to be used as dependency"
  308. $t touch $(APP)/script.sh
  309. $i "Append rules to the Makefile to generate a .erl module"
  310. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  311. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  312. $i "Generate unrelated .erl files"
  313. $t echo "-module(boy)." > $(APP)/src/boy.erl
  314. $t echo "-module(girl)." > $(APP)/src/girl.erl
  315. $i "Build the application"
  316. $t $(MAKE) -C $(APP) $v
  317. $i "Check that all compiled files exist"
  318. $t test -f $(APP)/$(APP).d
  319. $t test -f $(APP)/ebin/$(APP).app
  320. $t test -f $(APP)/ebin/boy.beam
  321. $t test -f $(APP)/ebin/generated.beam
  322. $t test -f $(APP)/ebin/girl.beam
  323. $t test -f $(APP)/src/generated.erl
  324. $i "Check that the application was compiled correctly"
  325. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  326. ok = application:start($(APP)), \
  327. {ok, Mods = [boy, generated, girl]} \
  328. = application:get_key($(APP), modules), \
  329. [{module, M} = code:load_file(M) || M <- Mods], \
  330. halt()"
  331. $i "Touch the script file; check that only required files are rebuilt"
  332. $t printf "%s\n" \
  333. $(APP)/$(APP).d \
  334. $(APP)/ebin/$(APP).app \
  335. $(APP)/ebin/generated.beam \
  336. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  337. $t $(SLEEP)
  338. $t touch $(APP)/script.sh
  339. $t $(SLEEP)
  340. $t $(MAKE) -C $(APP) $v
  341. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  342. $t rm $(APP)/EXPECT
  343. $i "Check that the application was compiled correctly"
  344. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  345. ok = application:start($(APP)), \
  346. {ok, Mods = [boy, generated, girl]} \
  347. = application:get_key($(APP), modules), \
  348. [{module, M} = code:load_file(M) || M <- Mods], \
  349. halt()"
  350. $i "Clean the application"
  351. $t $(MAKE) -C $(APP) clean $v
  352. $i "Check that source files still exist"
  353. $t test -f $(APP)/Makefile
  354. $t test -f $(APP)/erlang.mk
  355. $t test -f $(APP)/script.sh
  356. ifdef LEGACY
  357. $t test -f $(APP)/src/$(APP).app.src
  358. endif
  359. $t test -f $(APP)/src/boy.erl
  360. $t test -f $(APP)/src/girl.erl
  361. $i "Check that the generated .erl file still exists"
  362. $t test -f $(APP)/src/generated.erl
  363. $i "Check that all build artifacts are removed"
  364. $t test ! -e $(APP)/$(APP).d
  365. $t test ! -e $(APP)/ebin/
  366. $i "Add a rule to remove the generated .erl file on clean"
  367. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  368. $i "Clean the application again"
  369. $t $(MAKE) -C $(APP) clean $v
  370. $i "Check that the generated .erl file was removed"
  371. $t test ! -e $(APP)/src/generated.erl
  372. $i "Build the application again"
  373. $t $(MAKE) -C $(APP) $v
  374. $i "Check that all compiled files exist"
  375. $t test -f $(APP)/$(APP).d
  376. $t test -f $(APP)/ebin/$(APP).app
  377. $t test -f $(APP)/ebin/boy.beam
  378. $t test -f $(APP)/ebin/generated.beam
  379. $t test -f $(APP)/ebin/girl.beam
  380. $t test -f $(APP)/src/generated.erl
  381. $i "Check that the application was compiled correctly"
  382. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  383. ok = application:start($(APP)), \
  384. {ok, Mods = [boy, generated, girl]} \
  385. = application:get_key($(APP), modules), \
  386. [{module, M} = code:load_file(M) || M <- Mods], \
  387. halt()"
  388. core-app-generate-erl-include: build clean
  389. $i "Bootstrap a new OTP library named $(APP)"
  390. $t mkdir $(APP)/
  391. $t cp ../erlang.mk $(APP)/
  392. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  393. $i "Create a fake script file to be used as dependency"
  394. $t touch $(APP)/script.sh
  395. $i "Append rules to the Makefile to generate a .erl module"
  396. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  397. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  398. $i "Generate the .hrl file"
  399. $t mkdir $(APP)/include/
  400. $t touch $(APP)/include/included.hrl
  401. $i "Generate unrelated .erl files"
  402. $t echo "-module(boy)." > $(APP)/src/boy.erl
  403. $t echo "-module(girl)." > $(APP)/src/girl.erl
  404. $i "Build the application"
  405. $t $(MAKE) -C $(APP) $v
  406. $i "Check that all compiled files exist"
  407. $t test -f $(APP)/$(APP).d
  408. $t test -f $(APP)/ebin/$(APP).app
  409. $t test -f $(APP)/ebin/boy.beam
  410. $t test -f $(APP)/ebin/generated.beam
  411. $t test -f $(APP)/ebin/girl.beam
  412. $t test -f $(APP)/src/generated.erl
  413. $i "Check that the application was compiled correctly"
  414. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  415. ok = application:start($(APP)), \
  416. {ok, Mods = [boy, generated, girl]} \
  417. = application:get_key($(APP), modules), \
  418. [{module, M} = code:load_file(M) || M <- Mods], \
  419. halt()"
  420. $i "Touch the .hrl file; check that only required files are rebuilt"
  421. $t printf "%s\n" \
  422. $(APP)/$(APP).d \
  423. $(APP)/ebin/$(APP).app \
  424. $(APP)/ebin/generated.beam \
  425. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  426. $t $(SLEEP)
  427. $t touch $(APP)/include/included.hrl
  428. $t $(SLEEP)
  429. $t $(MAKE) -C $(APP) $v
  430. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  431. $t rm $(APP)/EXPECT
  432. $i "Check that the application was compiled correctly"
  433. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  434. ok = application:start($(APP)), \
  435. {ok, Mods = [boy, generated, girl]} \
  436. = application:get_key($(APP), modules), \
  437. [{module, M} = code:load_file(M) || M <- Mods], \
  438. halt()"
  439. core-app-generate-erl-prepend: build clean
  440. $i "Bootstrap a new OTP library named $(APP)"
  441. $t mkdir $(APP)/
  442. $t cp ../erlang.mk $(APP)/
  443. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  444. $i "Create a fake script file to be used as dependency"
  445. $t touch $(APP)/script.sh
  446. $i "Generate a Makefile and prepend rules that generate a .erl module"
  447. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  448. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  449. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  450. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  451. $t echo "include erlang.mk" >> $(APP)/Makefile
  452. $i "Generate unrelated .erl files"
  453. $t echo "-module(boy)." > $(APP)/src/boy.erl
  454. $t echo "-module(girl)." > $(APP)/src/girl.erl
  455. $i "Build the application"
  456. $t $(MAKE) -C $(APP) $v
  457. $i "Check that all compiled files exist"
  458. $t test -f $(APP)/$(APP).d
  459. $t test -f $(APP)/ebin/$(APP).app
  460. $t test -f $(APP)/ebin/boy.beam
  461. $t test -f $(APP)/ebin/generated.beam
  462. $t test -f $(APP)/ebin/girl.beam
  463. $t test -f $(APP)/src/generated.erl
  464. $i "Check that the application was compiled correctly"
  465. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  466. ok = application:start($(APP)), \
  467. {ok, Mods = [boy, generated, girl]} \
  468. = application:get_key($(APP), modules), \
  469. [{module, M} = code:load_file(M) || M <- Mods], \
  470. halt()"
  471. $i "Touch the script file; check that only required files are rebuilt"
  472. $t printf "%s\n" \
  473. $(APP)/$(APP).d \
  474. $(APP)/ebin/$(APP).app \
  475. $(APP)/ebin/generated.beam \
  476. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  477. $t $(SLEEP)
  478. $t touch $(APP)/script.sh
  479. $t $(SLEEP)
  480. $t $(MAKE) -C $(APP) $v
  481. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  482. $t rm $(APP)/EXPECT
  483. $i "Check that the application was compiled correctly"
  484. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  485. ok = application:start($(APP)), \
  486. {ok, Mods = [boy, generated, girl]} \
  487. = application:get_key($(APP), modules), \
  488. [{module, M} = code:load_file(M) || M <- Mods], \
  489. halt()"
  490. $i "Clean the application"
  491. $t $(MAKE) -C $(APP) clean $v
  492. $i "Check that source files still exist"
  493. $t test -f $(APP)/Makefile
  494. $t test -f $(APP)/erlang.mk
  495. $t test -f $(APP)/script.sh
  496. ifdef LEGACY
  497. $t test -f $(APP)/src/$(APP).app.src
  498. endif
  499. $t test -f $(APP)/src/boy.erl
  500. $t test -f $(APP)/src/girl.erl
  501. $i "Check that the generated .erl file still exists"
  502. $t test -f $(APP)/src/generated.erl
  503. $i "Check that all build artifacts are removed"
  504. $t test ! -e $(APP)/$(APP).d
  505. $t test ! -e $(APP)/ebin/
  506. $i "Add a rule to remove the generated .erl file on clean"
  507. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  508. $i "Clean the application again"
  509. $t $(MAKE) -C $(APP) clean $v
  510. $i "Check that the generated .erl file was removed"
  511. $t test ! -e $(APP)/src/generated.erl
  512. $i "Build the application again"
  513. $t $(MAKE) -C $(APP) $v
  514. $i "Check that all compiled files exist"
  515. $t test -f $(APP)/$(APP).d
  516. $t test -f $(APP)/ebin/$(APP).app
  517. $t test -f $(APP)/ebin/boy.beam
  518. $t test -f $(APP)/ebin/generated.beam
  519. $t test -f $(APP)/ebin/girl.beam
  520. $t test -f $(APP)/src/generated.erl
  521. $i "Check that the application was compiled correctly"
  522. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  523. ok = application:start($(APP)), \
  524. {ok, Mods = [boy, generated, girl]} \
  525. = application:get_key($(APP), modules), \
  526. [{module, M} = code:load_file(M) || M <- Mods], \
  527. halt()"
  528. core-app-hrl: build clean
  529. $i "Bootstrap a new OTP library named $(APP)"
  530. $t mkdir $(APP)/
  531. $t cp ../erlang.mk $(APP)/
  532. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  533. $i "Generate .hrl files"
  534. $t mkdir $(APP)/include/
  535. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  536. $i "Generate .erl files dependent from headers"
  537. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  538. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  539. $i "Build the application"
  540. $t $(MAKE) -C $(APP) $v
  541. $i "Check that all compiled files exist"
  542. $t test -f $(APP)/$(APP).d
  543. $t test -f $(APP)/ebin/$(APP).app
  544. $t test -f $(APP)/ebin/use_blue.beam
  545. $t test -f $(APP)/ebin/use_red.beam
  546. $i "Check that the application was compiled correctly"
  547. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  548. ok = application:start($(APP)), \
  549. {ok, Mods = [use_blue, use_red]} \
  550. = application:get_key($(APP), modules), \
  551. [{module, M} = code:load_file(M) || M <- Mods], \
  552. halt()"
  553. $i "Touch one .hrl file; check that only required files are rebuilt"
  554. # The use_red.erl gets touched because of its dependency to red.hrl.
  555. $t printf "%s\n" \
  556. $(APP)/$(APP).d \
  557. $(APP)/ebin/$(APP).app \
  558. $(APP)/ebin/use_red.beam \
  559. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  560. $t $(SLEEP)
  561. $t touch $(APP)/include/red.hrl
  562. $t $(SLEEP)
  563. $t $(MAKE) -C $(APP) $v
  564. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  565. $t rm $(APP)/EXPECT
  566. $i "Check that the application was compiled correctly"
  567. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  568. ok = application:start($(APP)), \
  569. {ok, Mods = [use_blue, use_red]} \
  570. = application:get_key($(APP), modules), \
  571. [{module, M} = code:load_file(M) || M <- Mods], \
  572. halt()"
  573. $i "Clean the application"
  574. $t $(MAKE) -C $(APP) clean $v
  575. $i "Check that source files still exist"
  576. $t test -f $(APP)/Makefile
  577. $t test -f $(APP)/erlang.mk
  578. $t test -f $(APP)/include/blue.hrl
  579. $t test -f $(APP)/include/red.hrl
  580. ifdef LEGACY
  581. $t test -f $(APP)/src/$(APP).app.src
  582. endif
  583. $t test -f $(APP)/src/use_blue.erl
  584. $t test -f $(APP)/src/use_red.erl
  585. $i "Check that all build artifacts are removed"
  586. $t test ! -e $(APP)/$(APP).d
  587. $t test ! -e $(APP)/ebin/
  588. $i "Build the application again"
  589. $t $(MAKE) -C $(APP) $v
  590. $i "Check that all compiled files exist"
  591. $t test -f $(APP)/$(APP).d
  592. $t test -f $(APP)/ebin/$(APP).app
  593. $t test -f $(APP)/ebin/use_blue.beam
  594. $t test -f $(APP)/ebin/use_red.beam
  595. $i "Check that the application was compiled correctly"
  596. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  597. ok = application:start($(APP)), \
  598. {ok, Mods = [use_blue, use_red]} \
  599. = application:get_key($(APP), modules), \
  600. [{module, M} = code:load_file(M) || M <- Mods], \
  601. halt()"
  602. core-app-hrl-recursive: build clean
  603. $i "Bootstrap a new OTP library named $(APP)"
  604. $t mkdir $(APP)/
  605. $t cp ../erlang.mk $(APP)/
  606. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  607. $i "Generate .hrl files"
  608. $t mkdir $(APP)/include/
  609. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  610. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  611. $i "Generate .erl files dependent from headers"
  612. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  613. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  614. $i "Build the application"
  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_blue.beam
  620. $t test -f $(APP)/ebin/use_red.beam
  621. $i "Check that the application was compiled correctly"
  622. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  623. ok = application:start($(APP)), \
  624. {ok, Mods = [use_blue, use_red]} \
  625. = application:get_key($(APP), modules), \
  626. [{module, M} = code:load_file(M) || M <- Mods], \
  627. halt()"
  628. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  629. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  630. $t printf "%s\n" \
  631. $(APP)/$(APP).d \
  632. $(APP)/ebin/$(APP).app \
  633. $(APP)/ebin/use_red.beam \
  634. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  635. $t $(SLEEP)
  636. $t touch $(APP)/include/pill.hrl
  637. $t $(SLEEP)
  638. $t $(MAKE) -C $(APP) $v
  639. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  640. $t rm $(APP)/EXPECT
  641. $i "Check that the application was compiled correctly"
  642. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  643. ok = application:start($(APP)), \
  644. {ok, Mods = [use_blue, use_red]} \
  645. = application:get_key($(APP), modules), \
  646. [{module, M} = code:load_file(M) || M <- Mods], \
  647. halt()"
  648. $i "Clean the application"
  649. $t $(MAKE) -C $(APP) clean $v
  650. $i "Check that source files still exist"
  651. $t test -f $(APP)/Makefile
  652. $t test -f $(APP)/erlang.mk
  653. $t test -f $(APP)/include/blue.hrl
  654. $t test -f $(APP)/include/pill.hrl
  655. $t test -f $(APP)/include/red.hrl
  656. ifdef LEGACY
  657. $t test -f $(APP)/src/$(APP).app.src
  658. endif
  659. $t test -f $(APP)/src/use_blue.erl
  660. $t test -f $(APP)/src/use_red.erl
  661. $i "Check that all build artifacts are removed"
  662. $t test ! -e $(APP)/$(APP).d
  663. $t test ! -e $(APP)/ebin/
  664. $i "Build the application again"
  665. $t $(MAKE) -C $(APP) $v
  666. $i "Check that all compiled files exist"
  667. $t test -f $(APP)/$(APP).d
  668. $t test -f $(APP)/ebin/$(APP).app
  669. $t test -f $(APP)/ebin/use_blue.beam
  670. $t test -f $(APP)/ebin/use_red.beam
  671. $i "Check that the application was compiled correctly"
  672. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  673. ok = application:start($(APP)), \
  674. {ok, Mods = [use_blue, use_red]} \
  675. = application:get_key($(APP), modules), \
  676. [{module, M} = code:load_file(M) || M <- Mods], \
  677. halt()"
  678. core-app-makefile-change: build clean
  679. $i "Bootstrap a new OTP application named $(APP)"
  680. $t mkdir $(APP)/
  681. $t cp ../erlang.mk $(APP)/
  682. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  683. $i "Build the application"
  684. $t $(MAKE) -C $(APP) $v
  685. $i "Touch the Makefile; check that all files get rebuilt"
  686. $t printf "%s\n" \
  687. $(APP)/$(APP).d \
  688. $(APP)/ebin/$(APP).app \
  689. $(APP)/ebin/$(APP)_app.beam \
  690. $(APP)/ebin/$(APP)_sup.beam \
  691. $(APP)/src/$(APP)_app.erl \
  692. $(APP)/src/$(APP)_sup.erl | sort > $(APP)/EXPECT
  693. $t $(SLEEP)
  694. $t touch $(APP)/Makefile
  695. $t $(SLEEP)
  696. $t $(MAKE) -C $(APP) $v
  697. $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT -
  698. $t rm $(APP)/EXPECT
  699. core-app-mib: build clean
  700. $i "Bootstrap a new OTP library named $(APP)"
  701. $t mkdir $(APP)/
  702. $t cp ../erlang.mk $(APP)/
  703. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  704. $i "Download .mib files from Erlang/OTP"
  705. $t mkdir $(APP)/mibs/
  706. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  707. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
  708. $i "Generate .erl files dependent from headers generated by .mib files"
  709. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  710. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  711. $i "Generate an unrelated .hrl file"
  712. $t mkdir $(APP)/include/
  713. $t touch $(APP)/include/unrelated.hrl
  714. $i "Build the application"
  715. $t $(MAKE) -C $(APP) $v
  716. $i "Check that all compiled files exist"
  717. $t test -f $(APP)/$(APP).d
  718. $t test -f $(APP)/ebin/$(APP).app
  719. $t test -f $(APP)/ebin/use_v1.beam
  720. $t test -f $(APP)/ebin/use_v2.beam
  721. $t test -f $(APP)/include/EX1-MIB.hrl
  722. $t test -f $(APP)/include/OTP-REG.hrl
  723. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  724. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  725. $i "Check that the application was compiled correctly"
  726. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  727. ok = application:start($(APP)), \
  728. {ok, Mods = [use_v1, use_v2]} \
  729. = application:get_key($(APP), modules), \
  730. [{module, M} = code:load_file(M) || M <- Mods], \
  731. halt()"
  732. $i "Touch one .mib file; check that only required files are rebuilt"
  733. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  734. $t printf "%s\n" \
  735. $(APP)/$(APP).d \
  736. $(APP)/ebin/$(APP).app \
  737. $(APP)/ebin/use_v1.beam \
  738. $(APP)/include/EX1-MIB.hrl \
  739. $(APP)/priv/mibs/EX1-MIB.bin \
  740. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  741. $t $(SLEEP)
  742. $t touch $(APP)/mibs/EX1-MIB.mib
  743. $t $(SLEEP)
  744. $t $(MAKE) -C $(APP) $v
  745. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  746. $t rm $(APP)/EXPECT
  747. $i "Check that the application was compiled correctly"
  748. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  749. ok = application:start($(APP)), \
  750. {ok, Mods = [use_v1, use_v2]} \
  751. = application:get_key($(APP), modules), \
  752. [{module, M} = code:load_file(M) || M <- Mods], \
  753. halt()"
  754. $i "Clean the application"
  755. $t $(MAKE) -C $(APP) clean $v
  756. $i "Check that source files still exist"
  757. $t test -f $(APP)/Makefile
  758. $t test -f $(APP)/erlang.mk
  759. $t test -f $(APP)/include/unrelated.hrl
  760. $t test -f $(APP)/mibs/EX1-MIB.mib
  761. $t test -f $(APP)/mibs/OTP-REG.mib
  762. ifdef LEGACY
  763. $t test -f $(APP)/src/$(APP).app.src
  764. endif
  765. $t test -f $(APP)/src/use_v1.erl
  766. $t test -f $(APP)/src/use_v2.erl
  767. $i "Check that all build artifacts are removed, including intermediates"
  768. $t test ! -e $(APP)/$(APP).d
  769. $t test ! -e $(APP)/ebin/
  770. $t test ! -e $(APP)/include/EX1-MIB.hrl
  771. $t test ! -e $(APP)/include/OTP-REG.hrl
  772. $t test ! -e $(APP)/priv/mibs/
  773. $i "Build the application again"
  774. $t $(MAKE) -C $(APP) $v
  775. $i "Check that all compiled files exist"
  776. $t test -f $(APP)/$(APP).d
  777. $t test -f $(APP)/ebin/$(APP).app
  778. $t test -f $(APP)/ebin/use_v1.beam
  779. $t test -f $(APP)/ebin/use_v2.beam
  780. $t test -f $(APP)/include/EX1-MIB.hrl
  781. $t test -f $(APP)/include/OTP-REG.hrl
  782. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  783. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  784. $i "Check that the application was compiled correctly"
  785. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  786. ok = application:start($(APP)), \
  787. {ok, Mods = [use_v1, use_v2]} \
  788. = application:get_key($(APP), modules), \
  789. [{module, M} = code:load_file(M) || M <- Mods], \
  790. halt()"
  791. ifndef LEGACY
  792. core-app-name-special-char: build clean
  793. $i "Bootstrap a new OTP library named $(APP)"
  794. $t mkdir $(APP)/
  795. $t cp ../erlang.mk $(APP)/
  796. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  797. $i "Set PROJECT_DESCRIPTION = test % in the Makefile"
  798. $t echo "PROJECT_DESCRIPTION = test %" >> $(APP)/Makefile
  799. $i "Build the application"
  800. $t $(MAKE) -C $(APP) $v
  801. $i "Check that the application was compiled correctly"
  802. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  803. ok = application:load($(APP)), \
  804. {ok,\"test %\"} = application:get_key($(APP), description), \
  805. halt()"
  806. endif
  807. core-app-no-app: build clean
  808. $i "Bootstrap a project without an OTP library"
  809. $t mkdir $(APP)/
  810. $t cp ../erlang.mk $(APP)/
  811. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  812. $t rm -rf $(APP)/src
  813. $i "Build the project"
  814. $t $(MAKE) -C $(APP) $v
  815. core-app-no-makedep: build clean
  816. $i "Bootstrap a new OTP library named $(APP)"
  817. $t mkdir $(APP)/
  818. $t cp ../erlang.mk $(APP)/
  819. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  820. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  821. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  822. $i "Generate .hrl files"
  823. $t mkdir $(APP)/include/
  824. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  825. $i "Generate .erl files dependent from headers"
  826. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  827. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  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/use_blue.beam
  834. $t test -f $(APP)/ebin/use_red.beam
  835. $i "Check that the application was compiled correctly"
  836. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  837. ok = application:start($(APP)), \
  838. {ok, Mods = [use_blue, use_red]} \
  839. = application:get_key($(APP), modules), \
  840. [{module, M} = code:load_file(M) || M <- Mods], \
  841. halt()"
  842. $i "Touch one .hrl file; check that only required files are rebuilt"
  843. # The use_red.erl gets touched because of its dependency to red.hrl.
  844. $t printf "%s\n" \
  845. $(APP)/ebin/$(APP).app \
  846. $(APP)/ebin/use_red.beam \
  847. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  848. $t $(SLEEP)
  849. $t touch $(APP)/include/red.hrl
  850. $t $(SLEEP)
  851. $t $(MAKE) -C $(APP) $v
  852. $t find $(APP) -type f -newer $(APP)/include/red.hrl | 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 = [use_blue, use_red]} \
  858. = application:get_key($(APP), modules), \
  859. [{module, M} = code:load_file(M) || M <- Mods], \
  860. halt()"
  861. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  862. # The use_red.erl gets touched because of its dependency to red.hrl.
  863. $t printf "%s\n" \
  864. $(APP)/$(APP).d \
  865. $(APP)/ebin/$(APP).app \
  866. $(APP)/ebin/use_red.beam \
  867. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  868. $t $(SLEEP)
  869. $t touch $(APP)/include/red.hrl
  870. $t $(SLEEP)
  871. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  872. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  873. $t rm $(APP)/EXPECT
  874. $i "Check that the application was compiled correctly"
  875. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  876. ok = application:start($(APP)), \
  877. {ok, Mods = [use_blue, use_red]} \
  878. = application:get_key($(APP), modules), \
  879. [{module, M} = code:load_file(M) || M <- Mods], \
  880. halt()"
  881. $i "Clean the application"
  882. $t $(MAKE) -C $(APP) clean $v
  883. $i "Check that source files still exist"
  884. $t test -f $(APP)/Makefile
  885. $t test -f $(APP)/erlang.mk
  886. $t test -f $(APP)/include/blue.hrl
  887. $t test -f $(APP)/include/red.hrl
  888. ifdef LEGACY
  889. $t test -f $(APP)/src/$(APP).app.src
  890. endif
  891. $t test -f $(APP)/src/use_blue.erl
  892. $t test -f $(APP)/src/use_red.erl
  893. $i "Check that all build artifacts are removed"
  894. $t test ! -e $(APP)/$(APP).d
  895. $t test ! -e $(APP)/ebin/
  896. $i "Build the application again"
  897. $t $(MAKE) -C $(APP) $v
  898. $i "Check that all compiled files exist"
  899. $t test -f $(APP)/$(APP).d
  900. $t test -f $(APP)/ebin/$(APP).app
  901. $t test -f $(APP)/ebin/use_blue.beam
  902. $t test -f $(APP)/ebin/use_red.beam
  903. $i "Check that the application was compiled correctly"
  904. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  905. ok = application:start($(APP)), \
  906. {ok, Mods = [use_blue, use_red]} \
  907. = application:get_key($(APP), modules), \
  908. [{module, M} = code:load_file(M) || M <- Mods], \
  909. halt()"
  910. core-app-project-mod: build clean
  911. $i "Bootstrap a new OTP library named $(APP)"
  912. $t mkdir $(APP)/
  913. $t cp ../erlang.mk $(APP)/
  914. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  915. $i "Generate an application module"
  916. $t printf "%s\n" \
  917. "-module(app_mod)." \
  918. "-export([start/2, stop/1])." \
  919. "start(_StartType, _StartArgs) -> {ok, self()}." \
  920. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  921. $i "Build the application with PROJECT_MOD"
  922. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  923. $i "Check that the application starts correctly"
  924. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  925. core-app-pt: build clean
  926. $i "Bootstrap a new OTP library named $(APP)"
  927. $t mkdir $(APP)/
  928. $t cp ../erlang.mk $(APP)/
  929. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  930. $i "Generate a parse_transform module"
  931. $t printf "%s\n" \
  932. "-module(my_pt)." \
  933. "-export([parse_transform/2])." \
  934. "parse_transform(Forms, _) ->" \
  935. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  936. " Forms." > $(APP)/src/my_pt.erl
  937. $i "Generate a .erl file that uses the my_pt parse_transform"
  938. $t printf "%s\n" \
  939. "-module(my_user)." \
  940. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  941. $i "Compile my_pt first"
  942. $t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
  943. $i "Build the application; confirm the parse_transform is used"
  944. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  945. $i "Check that the application was compiled correctly"
  946. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  947. ok = application:start($(APP)), \
  948. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  949. [{module, M} = code:load_file(M) || M <- Mods], \
  950. halt()"
  951. core-app-pt-erlc-opts: build clean
  952. $i "Bootstrap a new OTP library named $(APP)"
  953. $t mkdir $(APP)/
  954. $t cp ../erlang.mk $(APP)/
  955. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  956. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  957. $t mkdir -p $(APP)/deps/my_pt_dep/
  958. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  959. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  960. $i "Generate a parse_transform module in my_pt_dep"
  961. $t printf "%s\n" \
  962. "-module(my_pt)." \
  963. "-export([parse_transform/2])." \
  964. "parse_transform(Forms, _) ->" \
  965. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  966. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  967. $i "Add my_pt_dep to the list of dependencies"
  968. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  969. $i "Generate .erl files"
  970. $t echo "-module(boy)." > $(APP)/src/boy.erl
  971. $t echo "-module(girl)." > $(APP)/src/girl.erl
  972. $i "Add the my_pt parse_transform to ERLC_OPTS"
  973. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  974. $i "Build the application; confirm the parse_transform is used"
  975. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  976. $i "Check that the application was compiled correctly"
  977. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  978. ok = application:start($(APP)), \
  979. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  980. [{module, M} = code:load_file(M) || M <- Mods], \
  981. halt()"
  982. core-app-xrl: build clean
  983. $i "Bootstrap a new OTP library named $(APP)"
  984. $t mkdir $(APP)/
  985. $t cp ../erlang.mk $(APP)/
  986. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  987. $i "Download .xrl files from Robert"
  988. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  989. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  990. $i "Generate unrelated .erl files"
  991. $t echo "-module(boy)." > $(APP)/src/boy.erl
  992. $t echo "-module(girl)." > $(APP)/src/girl.erl
  993. $i "Disable warnings; our test .xrl files aren't perfect"
  994. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  995. $i "Build the application"
  996. $t $(MAKE) -C $(APP) $v
  997. $i "Check that all compiled files exist"
  998. $t test -f $(APP)/$(APP).d
  999. $t test -f $(APP)/ebin/$(APP).app
  1000. $t test -f $(APP)/ebin/boy.beam
  1001. $t test -f $(APP)/ebin/erlang_scan.beam
  1002. $t test -f $(APP)/ebin/girl.beam
  1003. $t test -f $(APP)/ebin/lfe_scan.beam
  1004. $t test -f $(APP)/src/erlang_scan.erl
  1005. $t test -f $(APP)/src/lfe_scan.erl
  1006. $i "Check that the application was compiled correctly"
  1007. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1008. ok = application:start($(APP)), \
  1009. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1010. = application:get_key($(APP), modules), \
  1011. [{module, M} = code:load_file(M) || M <- Mods], \
  1012. halt()"
  1013. $i "Touch one .xrl file; check that only required files are rebuilt"
  1014. $t printf "%s\n" \
  1015. $(APP)/$(APP).d \
  1016. $(APP)/ebin/$(APP).app \
  1017. $(APP)/ebin/erlang_scan.beam \
  1018. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  1019. $t $(SLEEP)
  1020. $t touch $(APP)/src/erlang_scan.xrl
  1021. $t $(SLEEP)
  1022. $t $(MAKE) -C $(APP) $v
  1023. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  1024. $t rm $(APP)/EXPECT
  1025. $i "Check that the application was compiled correctly"
  1026. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1027. ok = application:start($(APP)), \
  1028. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1029. = application:get_key($(APP), modules), \
  1030. [{module, M} = code:load_file(M) || M <- Mods], \
  1031. halt()"
  1032. $i "Clean the application"
  1033. $t $(MAKE) -C $(APP) clean $v
  1034. $i "Check that source files still exist"
  1035. $t test -f $(APP)/Makefile
  1036. $t test -f $(APP)/erlang.mk
  1037. ifdef LEGACY
  1038. $t test -f $(APP)/src/$(APP).app.src
  1039. endif
  1040. $t test -f $(APP)/src/boy.erl
  1041. $t test -f $(APP)/src/erlang_scan.xrl
  1042. $t test -f $(APP)/src/girl.erl
  1043. $t test -f $(APP)/src/lfe_scan.xrl
  1044. $i "Check that all build artifacts are removed, including intermediates"
  1045. $t test ! -e $(APP)/$(APP).d
  1046. $t test ! -e $(APP)/ebin/
  1047. $t test ! -e $(APP)/src/erlang_scan.erl
  1048. $t test ! -e $(APP)/src/lfe_scan.erl
  1049. $i "Build the application again"
  1050. $t $(MAKE) -C $(APP) $v
  1051. $i "Check that all compiled files exist"
  1052. $t test -f $(APP)/$(APP).d
  1053. $t test -f $(APP)/ebin/$(APP).app
  1054. $t test -f $(APP)/ebin/boy.beam
  1055. $t test -f $(APP)/ebin/erlang_scan.beam
  1056. $t test -f $(APP)/ebin/girl.beam
  1057. $t test -f $(APP)/ebin/lfe_scan.beam
  1058. $t test -f $(APP)/src/erlang_scan.erl
  1059. $t test -f $(APP)/src/lfe_scan.erl
  1060. $i "Check that the application was compiled correctly"
  1061. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1062. ok = application:start($(APP)), \
  1063. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1064. = application:get_key($(APP), modules), \
  1065. [{module, M} = code:load_file(M) || M <- Mods], \
  1066. halt()"
  1067. core-app-xrl-include: build clean
  1068. $i "Bootstrap a new OTP library named $(APP)"
  1069. $t mkdir $(APP)/
  1070. $t cp ../erlang.mk $(APP)/
  1071. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1072. $i "Download a .xrl file with numerous includes from Gordon"
  1073. $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
  1074. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1075. $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
  1076. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1077. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  1078. $i "Generate unrelated .erl files"
  1079. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1080. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1081. $i "Disable warnings; our test .xrl files aren't perfect"
  1082. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1083. $i "Build the application"
  1084. $t $(MAKE) -C $(APP) $v
  1085. $i "Check that all compiled files exist"
  1086. $t test -f $(APP)/$(APP).d
  1087. $t test -f $(APP)/ebin/$(APP).app
  1088. $t test -f $(APP)/ebin/boy.beam
  1089. $t test -f $(APP)/ebin/girl.beam
  1090. $t test -f $(APP)/ebin/xfl_lexer.beam
  1091. $t test -f $(APP)/src/xfl_lexer.erl
  1092. $i "Check that the application was compiled correctly"
  1093. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1094. ok = application:start($(APP)), \
  1095. {ok, Mods = [boy, girl, xfl_lexer]} \
  1096. = application:get_key($(APP), modules), \
  1097. [{module, M} = code:load_file(M) || M <- Mods], \
  1098. halt()"
  1099. $i "Touch the .xrl file; check that only required files are rebuilt"
  1100. $t printf "%s\n" \
  1101. $(APP)/$(APP).d \
  1102. $(APP)/ebin/$(APP).app \
  1103. $(APP)/ebin/xfl_lexer.beam \
  1104. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1105. $t $(SLEEP)
  1106. $t touch $(APP)/src/xfl_lexer.xrl
  1107. $t $(SLEEP)
  1108. $t $(MAKE) -C $(APP) $v
  1109. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1110. $t rm $(APP)/EXPECT
  1111. $i "Check that the application was compiled correctly"
  1112. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1113. ok = application:start($(APP)), \
  1114. {ok, Mods = [boy, girl, xfl_lexer]} \
  1115. = application:get_key($(APP), modules), \
  1116. [{module, M} = code:load_file(M) || M <- Mods], \
  1117. halt()"
  1118. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1119. $t printf "%s\n" \
  1120. $(APP)/$(APP).d \
  1121. $(APP)/ebin/$(APP).app \
  1122. $(APP)/ebin/xfl_lexer.beam \
  1123. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1124. $t $(SLEEP)
  1125. $t touch $(APP)/src/typechecks.hrl
  1126. $t $(SLEEP)
  1127. $t $(MAKE) -C $(APP) $v
  1128. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  1129. $t rm $(APP)/EXPECT
  1130. $i "Check that the application was compiled correctly"
  1131. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1132. ok = application:start($(APP)), \
  1133. {ok, Mods = [boy, girl, xfl_lexer]} \
  1134. = application:get_key($(APP), modules), \
  1135. [{module, M} = code:load_file(M) || M <- Mods], \
  1136. halt()"
  1137. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1138. $t printf "%s\n" \
  1139. $(APP)/$(APP).d \
  1140. $(APP)/ebin/$(APP).app \
  1141. $(APP)/ebin/xfl_lexer.beam \
  1142. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1143. $t $(SLEEP)
  1144. $t touch $(APP)/src/errvals.hrl
  1145. $t $(SLEEP)
  1146. $t $(MAKE) -C $(APP) $v
  1147. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1148. $t rm $(APP)/EXPECT
  1149. $i "Check that the application was compiled correctly"
  1150. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1151. ok = application:start($(APP)), \
  1152. {ok, Mods = [boy, girl, xfl_lexer]} \
  1153. = application:get_key($(APP), modules), \
  1154. [{module, M} = code:load_file(M) || M <- Mods], \
  1155. halt()"
  1156. $i "Clean the application"
  1157. $t $(MAKE) -C $(APP) clean $v
  1158. $i "Check that source files still exist"
  1159. $t test -f $(APP)/Makefile
  1160. $t test -f $(APP)/erlang.mk
  1161. ifdef LEGACY
  1162. $t test -f $(APP)/src/$(APP).app.src
  1163. endif
  1164. $t test -f $(APP)/src/boy.erl
  1165. $t test -f $(APP)/src/girl.erl
  1166. $t test -f $(APP)/src/errvals.hrl
  1167. $t test -f $(APP)/src/muin_proc_dict.hrl
  1168. $t test -f $(APP)/src/muin_records.hrl
  1169. $t test -f $(APP)/src/typechecks.hrl
  1170. $t test -f $(APP)/src/xfl_lexer.xrl
  1171. $i "Check that all build artifacts are removed, including intermediates"
  1172. $t test ! -e $(APP)/$(APP).d
  1173. $t test ! -e $(APP)/ebin/
  1174. $t test ! -e $(APP)/src/xfl_lexer.erl
  1175. $i "Build the application again"
  1176. $t $(MAKE) -C $(APP) $v
  1177. $i "Check that all compiled files exist"
  1178. $t test -f $(APP)/$(APP).d
  1179. $t test -f $(APP)/ebin/$(APP).app
  1180. $t test -f $(APP)/ebin/boy.beam
  1181. $t test -f $(APP)/ebin/girl.beam
  1182. $t test -f $(APP)/ebin/xfl_lexer.beam
  1183. $t test -f $(APP)/src/xfl_lexer.erl
  1184. $i "Check that the application was compiled correctly"
  1185. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1186. ok = application:start($(APP)), \
  1187. {ok, Mods = [boy, girl, xfl_lexer]} \
  1188. = application:get_key($(APP), modules), \
  1189. [{module, M} = code:load_file(M) || M <- Mods], \
  1190. halt()"
  1191. core-app-yrl: build clean
  1192. $i "Bootstrap a new OTP library named $(APP)"
  1193. $t mkdir $(APP)/
  1194. $t cp ../erlang.mk $(APP)/
  1195. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1196. $i "Download .yrl files from Erlang/OTP"
  1197. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1198. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1199. $i "Generate unrelated .erl files"
  1200. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1201. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1202. $i "Build the application"
  1203. $t $(MAKE) -C $(APP) $v
  1204. $i "Check that all compiled files exist"
  1205. $t test -f $(APP)/$(APP).d
  1206. $t test -f $(APP)/ebin/$(APP).app
  1207. $t test -f $(APP)/ebin/boy.beam
  1208. $t test -f $(APP)/ebin/girl.beam
  1209. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1210. $t test -f $(APP)/ebin/xref_parser.beam
  1211. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1212. $t test -f $(APP)/src/xref_parser.erl
  1213. $i "Check that the application was compiled correctly"
  1214. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1215. ok = application:start($(APP)), \
  1216. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1217. = application:get_key($(APP), modules), \
  1218. [{module, M} = code:load_file(M) || M <- Mods], \
  1219. halt()"
  1220. $i "Touch one .yrl file; check that only required files are rebuilt"
  1221. $t printf "%s\n" \
  1222. $(APP)/$(APP).d \
  1223. $(APP)/ebin/$(APP).app \
  1224. $(APP)/ebin/xref_parser.beam \
  1225. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1226. $t $(SLEEP)
  1227. $t touch $(APP)/src/xref_parser.yrl
  1228. $t $(SLEEP)
  1229. $t $(MAKE) -C $(APP) $v
  1230. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1231. $t rm $(APP)/EXPECT
  1232. $i "Check that the application was compiled correctly"
  1233. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1234. ok = application:start($(APP)), \
  1235. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1236. = application:get_key($(APP), modules), \
  1237. [{module, M} = code:load_file(M) || M <- Mods], \
  1238. halt()"
  1239. $i "Clean the application"
  1240. $t $(MAKE) -C $(APP) clean $v
  1241. $i "Check that source files still exist"
  1242. $t test -f $(APP)/Makefile
  1243. $t test -f $(APP)/erlang.mk
  1244. ifdef LEGACY
  1245. $t test -f $(APP)/src/$(APP).app.src
  1246. endif
  1247. $t test -f $(APP)/src/boy.erl
  1248. $t test -f $(APP)/src/girl.erl
  1249. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1250. $t test -f $(APP)/src/xref_parser.yrl
  1251. $i "Check that all build artifacts are removed, including intermediates"
  1252. $t test ! -e $(APP)/$(APP).d
  1253. $t test ! -e $(APP)/ebin/
  1254. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1255. $t test ! -e $(APP)/src/xref_parser.erl
  1256. $i "Build the application again"
  1257. $t $(MAKE) -C $(APP) $v
  1258. $i "Check that all compiled files exist"
  1259. $t test -f $(APP)/$(APP).d
  1260. $t test -f $(APP)/ebin/$(APP).app
  1261. $t test -f $(APP)/ebin/boy.beam
  1262. $t test -f $(APP)/ebin/girl.beam
  1263. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1264. $t test -f $(APP)/ebin/xref_parser.beam
  1265. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1266. $t test -f $(APP)/src/xref_parser.erl
  1267. $i "Check that the application was compiled correctly"
  1268. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1269. ok = application:start($(APP)), \
  1270. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1271. = application:get_key($(APP), modules), \
  1272. [{module, M} = code:load_file(M) || M <- Mods], \
  1273. halt()"
  1274. core-app-yrl-header: build clean
  1275. $i "Bootstrap a new OTP library named $(APP)"
  1276. $t mkdir $(APP)/
  1277. $t cp ../erlang.mk $(APP)/
  1278. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1279. $i "Create a .yrl file"
  1280. $t echo "Nonterminals E T F." > $(APP)/src/y_parse.yrl
  1281. $t echo "Terminals '+' '*' '(' ')' number." >> $(APP)/src/y_parse.yrl
  1282. $t echo "Rootsymbol E." >> $(APP)/src/y_parse.yrl
  1283. $t echo "E -> E '+' T: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1284. $t echo "E -> T : '\$$1'." >> $(APP)/src/y_parse.yrl
  1285. $t echo "T -> T '*' F: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1286. $t echo "T -> F : '\$$1'." >> $(APP)/src/y_parse.yrl
  1287. $t echo "F -> '(' E ')' : '\$$2'." >> $(APP)/src/y_parse.yrl
  1288. $t echo "F -> number : '\$$1'. " >> $(APP)/src/y_parse.yrl
  1289. $i "Create the yrl header file"
  1290. $t mkdir $(APP)/include
  1291. $t echo "-export([forty_two/0])." > $(APP)/include/yecc_header.hrl
  1292. # A bunch of gobbldygook we don't actually care about, they just
  1293. # need to exist so we don't get errors.
  1294. $t echo "-export([yeccpars1/5, yeccerror/1, yeccpars2/7, yeccpars2_0/7, yeccpars2_1/7, yeccpars2_2/7, yeccpars2_3/7, yeccpars2_5/7, yeccpars2_6/7, yeccpars2_7/7, yeccpars2_9/7, yeccpars2_11/7, 'yeccgoto_\'E\''/7, 'yeccgoto_\'F\''/7, 'yeccgoto_\'T\''/7, yeccpars2_9_/1, yeccpars2_11_/1, yeccpars2_7_/1])." >> $(APP)/include/yecc_header.hrl
  1295. $t echo "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1296. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1297. # Required bits done, now part we'll actually test for.
  1298. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1299. $i "Generate unrelated .erl files"
  1300. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1301. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1302. $i "Build the application"
  1303. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1304. $i "Check that all compiled files exist"
  1305. $t test -f $(APP)/$(APP).d
  1306. $t test -f $(APP)/ebin/$(APP).app
  1307. $t test -f $(APP)/ebin/boy.beam
  1308. $t test -f $(APP)/ebin/girl.beam
  1309. $t test -f $(APP)/ebin/y_parse.beam
  1310. $t test -f $(APP)/src/y_parse.erl
  1311. $i "Check that the application was compiled correctly"
  1312. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1313. ok = application:start($(APP)), \
  1314. {ok, Mods = [boy, girl, y_parse]} \
  1315. = application:get_key($(APP), modules), \
  1316. [{module, M} = code:load_file(M) || M <- Mods], \
  1317. halt()"
  1318. $i "Check the built yecc module used the header"
  1319. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1320. {module, y_parse} = code:load_file(y_parse), \
  1321. 42 = y_parse:forty_two(), \
  1322. halt()"
  1323. $i "Check that the application was compiled correctly"
  1324. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1325. ok = application:start($(APP)), \
  1326. {ok, Mods = [boy, girl, y_parse]} \
  1327. = application:get_key($(APP), modules), \
  1328. [{module, M} = code:load_file(M) || M <- Mods], \
  1329. halt()"
  1330. core-app-yrl-include: build clean
  1331. $i "Bootstrap a new OTP library named $(APP)"
  1332. $t mkdir $(APP)/
  1333. $t cp ../erlang.mk $(APP)/
  1334. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1335. $i "Download a .yrl file with includes from Erlang/OTP"
  1336. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1337. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1338. $i "Generate unrelated .erl files"
  1339. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1340. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1341. $i "Build the application"
  1342. $t $(MAKE) -C $(APP) $v
  1343. $i "Check that all compiled files exist"
  1344. $t test -f $(APP)/$(APP).d
  1345. $t test -f $(APP)/ebin/$(APP).app
  1346. $t test -f $(APP)/ebin/boy.beam
  1347. $t test -f $(APP)/ebin/core_parse.beam
  1348. $t test -f $(APP)/ebin/girl.beam
  1349. $t test -f $(APP)/src/core_parse.erl
  1350. $i "Check that the application was compiled correctly"
  1351. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1352. ok = application:start($(APP)), \
  1353. {ok, Mods = [boy, core_parse, girl]} \
  1354. = application:get_key($(APP), modules), \
  1355. [{module, M} = code:load_file(M) || M <- Mods], \
  1356. halt()"
  1357. $i "Touch the .yrl file; check that only required files are rebuilt"
  1358. $t printf "%s\n" \
  1359. $(APP)/$(APP).d \
  1360. $(APP)/ebin/$(APP).app \
  1361. $(APP)/ebin/core_parse.beam \
  1362. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1363. $t $(SLEEP)
  1364. $t touch $(APP)/src/core_parse.yrl
  1365. $t $(SLEEP)
  1366. $t $(MAKE) -C $(APP) $v
  1367. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1368. $t rm $(APP)/EXPECT
  1369. $i "Check that the application was compiled correctly"
  1370. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1371. ok = application:start($(APP)), \
  1372. {ok, Mods = [boy, core_parse, girl]} \
  1373. = application:get_key($(APP), modules), \
  1374. [{module, M} = code:load_file(M) || M <- Mods], \
  1375. halt()"
  1376. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1377. $t printf "%s\n" \
  1378. $(APP)/$(APP).d \
  1379. $(APP)/ebin/$(APP).app \
  1380. $(APP)/ebin/core_parse.beam \
  1381. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1382. $t $(SLEEP)
  1383. $t touch $(APP)/src/core_parse.hrl
  1384. $t $(SLEEP)
  1385. $t $(MAKE) -C $(APP) $v
  1386. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1387. $t rm $(APP)/EXPECT
  1388. $i "Check that the application was compiled correctly"
  1389. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1390. ok = application:start($(APP)), \
  1391. {ok, Mods = [boy, core_parse, girl]} \
  1392. = application:get_key($(APP), modules), \
  1393. [{module, M} = code:load_file(M) || M <- Mods], \
  1394. halt()"
  1395. $i "Clean the application"
  1396. $t $(MAKE) -C $(APP) clean $v
  1397. $i "Check that source files still exist"
  1398. $t test -f $(APP)/Makefile
  1399. $t test -f $(APP)/erlang.mk
  1400. ifdef LEGACY
  1401. $t test -f $(APP)/src/$(APP).app.src
  1402. endif
  1403. $t test -f $(APP)/src/boy.erl
  1404. $t test -f $(APP)/src/core_parse.hrl
  1405. $t test -f $(APP)/src/core_parse.yrl
  1406. $t test -f $(APP)/src/girl.erl
  1407. $i "Check that all build artifacts are removed, including intermediates"
  1408. $t test ! -e $(APP)/$(APP).d
  1409. $t test ! -e $(APP)/ebin/
  1410. $t test ! -e $(APP)/src/core_parse.erl
  1411. $i "Build the application again"
  1412. $t $(MAKE) -C $(APP) $v
  1413. $i "Check that all compiled files exist"
  1414. $t test -f $(APP)/$(APP).d
  1415. $t test -f $(APP)/ebin/$(APP).app
  1416. $t test -f $(APP)/ebin/boy.beam
  1417. $t test -f $(APP)/ebin/core_parse.beam
  1418. $t test -f $(APP)/ebin/girl.beam
  1419. $t test -f $(APP)/src/core_parse.erl
  1420. $i "Check that the application was compiled correctly"
  1421. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1422. ok = application:start($(APP)), \
  1423. {ok, Mods = [boy, core_parse, girl]} \
  1424. = application:get_key($(APP), modules), \
  1425. [{module, M} = code:load_file(M) || M <- Mods], \
  1426. halt()"