core_app.mk 56 KB

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