core_app.mk 45 KB

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