core_app.mk 52 KB

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