core_app.mk 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616
  1. # Core: Building applications.
  2. CORE_APP_TARGETS = $(call list_targets,core-app)
  3. .PHONY: core-app $(CORE_APP_TARGETS)
  4. core-app: $(CORE_APP_TARGETS)
  5. ifdef LEGACY
  6. core-app-appsrc-change: build clean
  7. $i "Bootstrap a new OTP application named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  11. $i "Build the application"
  12. $t $(MAKE) -C $(APP) $v
  13. $i "Touch the .app.src file; check that only the .app file gets rebuilt"
  14. $t printf "%s\n" $(APP)/ebin/$(APP).app > $(APP)/EXPECT
  15. $t $(SLEEP)
  16. $t touch $(APP)/src/$(APP).app.src
  17. $t $(SLEEP)
  18. $t $(MAKE) -C $(APP) $v
  19. $t find $(APP) -type f -newer $(APP)/src/$(APP).app.src | sort | diff $(APP)/EXPECT -
  20. $t rm $(APP)/EXPECT
  21. endif
  22. core-app-asn1: build clean
  23. $i "Bootstrap a new OTP library named $(APP)"
  24. $t mkdir $(APP)/
  25. $t cp ../erlang.mk $(APP)/
  26. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  27. $i "Download .asn1 files from Erlang/OTP"
  28. $t mkdir $(APP)/asn1/
  29. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  30. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  31. $i "Generate .erl files dependent from headers generated by .asn1 files"
  32. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  33. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  34. $i "Generate an unrelated .hrl file"
  35. $t mkdir $(APP)/include/
  36. $t touch $(APP)/include/unrelated.hrl
  37. $i "Build the application"
  38. $t $(MAKE) -C $(APP) $v
  39. $i "Check that all compiled files exist"
  40. $t test -f $(APP)/$(APP).d
  41. $t test -f $(APP)/ebin/$(APP).app
  42. $t test -f $(APP)/ebin/CAP.beam
  43. $t test -f $(APP)/ebin/Def.beam
  44. $t test -f $(APP)/ebin/use_cap.beam
  45. $t test -f $(APP)/ebin/use_def.beam
  46. $t test -f $(APP)/include/CAP.asn1db
  47. $t test -f $(APP)/include/CAP.hrl
  48. $t test -f $(APP)/include/Def.asn1db
  49. $t test -f $(APP)/include/Def.hrl
  50. $t test -f $(APP)/src/CAP.erl
  51. $t test -f $(APP)/src/Def.erl
  52. $i "Check that the application was compiled correctly"
  53. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  54. ok = application:start($(APP)), \
  55. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  56. = application:get_key($(APP), modules), \
  57. [{module, M} = code:load_file(M) || M <- Mods], \
  58. halt()"
  59. $i "Touch one .asn1 file; check that only required files are rebuilt"
  60. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  61. $t printf "%s\n" \
  62. $(APP)/$(APP).d \
  63. $(APP)/ebin/$(APP).app \
  64. $(APP)/ebin/CAP.beam \
  65. $(APP)/ebin/use_cap.beam \
  66. $(APP)/include/CAP.asn1db \
  67. $(APP)/include/CAP.hrl \
  68. $(APP)/src/CAP.erl \
  69. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  70. $t $(SLEEP)
  71. $t touch $(APP)/asn1/CAP.asn1
  72. $t $(SLEEP)
  73. $t $(MAKE) -C $(APP) $v
  74. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  75. $t rm $(APP)/EXPECT
  76. $i "Check that the application was compiled correctly"
  77. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  78. ok = application:start($(APP)), \
  79. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  80. = application:get_key($(APP), modules), \
  81. [{module, M} = code:load_file(M) || M <- Mods], \
  82. halt()"
  83. $i "Clean the application"
  84. $t $(MAKE) -C $(APP) clean $v
  85. $i "Check that source files still exist"
  86. $t test -f $(APP)/Makefile
  87. $t test -f $(APP)/erlang.mk
  88. $t test -f $(APP)/asn1/CAP.asn1
  89. $t test -f $(APP)/asn1/Def.asn1
  90. $t test -f $(APP)/include/unrelated.hrl
  91. ifdef LEGACY
  92. $t test -f $(APP)/src/$(APP).app.src
  93. endif
  94. $t test -f $(APP)/src/use_cap.erl
  95. $t test -f $(APP)/src/use_def.erl
  96. $i "Check that all build artifacts are removed, including intermediates"
  97. $t test ! -e $(APP)/$(APP).d
  98. $t test ! -e $(APP)/ebin/
  99. $t test ! -e $(APP)/include/CAP.asn1db
  100. $t test ! -e $(APP)/include/CAP.hrl
  101. $t test ! -e $(APP)/include/Def.asn1db
  102. $t test ! -e $(APP)/include/Def.hrl
  103. $t test ! -e $(APP)/src/CAP.erl
  104. $t test ! -e $(APP)/src/Def.erl
  105. $i "Build the application again"
  106. $t $(MAKE) -C $(APP) $v
  107. $i "Check that all compiled files exist"
  108. $t test -f $(APP)/$(APP).d
  109. $t test -f $(APP)/ebin/$(APP).app
  110. $t test -f $(APP)/ebin/CAP.beam
  111. $t test -f $(APP)/ebin/Def.beam
  112. $t test -f $(APP)/ebin/use_cap.beam
  113. $t test -f $(APP)/ebin/use_def.beam
  114. $t test -f $(APP)/include/CAP.asn1db
  115. $t test -f $(APP)/include/CAP.hrl
  116. $t test -f $(APP)/include/Def.asn1db
  117. $t test -f $(APP)/include/Def.hrl
  118. $t test -f $(APP)/src/CAP.erl
  119. $t test -f $(APP)/src/Def.erl
  120. $i "Check that the application was compiled correctly"
  121. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  122. ok = application:start($(APP)), \
  123. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  124. = application:get_key($(APP), modules), \
  125. [{module, M} = code:load_file(M) || M <- Mods], \
  126. halt()"
  127. $i "Clean the application"
  128. $t $(MAKE) -C $(APP) clean $v
  129. $i "Build the application with ERLC_ASN1_OPTS set"
  130. $t echo "ERLC_ASN1_OPTS += +'{record_name_prefix,\"FOO-\"}'" >> $(APP)/Makefile
  131. $t $(MAKE) -C $(APP) $v
  132. $i "Check that the application was built with ERLC_ASN1_OPTS set"
  133. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  134. Attrs = 'Def':module_info(attributes), \
  135. Asn1Info = proplists:get_value(asn1_info, Attrs), \
  136. Opts = proplists:get_value(options, Asn1Info), \
  137. true = lists:member({record_name_prefix, \"FOO-\"}, Opts), \
  138. halt()"
  139. core-app-auto-git-id: build clean
  140. $i "Bootstrap a new OTP library named $(APP)"
  141. $t mkdir $(APP)/
  142. $t cp ../erlang.mk $(APP)/
  143. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  144. $i "Make it a git repository"
  145. $t cd $(APP) && \
  146. git init -q && \
  147. git config user.email "testsuite@erlang.mk" && \
  148. git config user.name "test suite" && \
  149. git add . && \
  150. git commit -q --no-gpg-sign -m "Tests"
  151. $i "Build the application"
  152. $t $(MAKE) -C $(APP) $v
  153. ifdef LEGACY
  154. # Legacy replaces {id, "git"} always regardless of built as a dependency.
  155. $i "Check that the generated .app file has an id key"
  156. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  157. ok = application:start($(APP)), \
  158. {ok, ID} = application:get_key($(APP), id), \
  159. true = ID =/= [], \
  160. halt()"
  161. else
  162. # If there is no .app.src though, only fill in id when built as a dependency.
  163. $i "Check that the generated .app file has no id key"
  164. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  165. ok = application:start($(APP)), \
  166. {ok, []} = application:get_key($(APP), id), \
  167. halt()"
  168. endif
  169. $i "Clean the application"
  170. $t $(MAKE) -C $(APP) clean $v
  171. $i "Build the application with IS_DEP=1"
  172. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  173. $i "Check that the generated .app file has an id key"
  174. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  175. ok = application:start($(APP)), \
  176. {ok, ID} = application:get_key($(APP), id), \
  177. true = ID =/= [], \
  178. halt()"
  179. ifndef LEGACY
  180. core-app-env: build clean
  181. $i "Bootstrap a new OTP library named $(APP)"
  182. $t mkdir $(APP)/
  183. $t cp ../erlang.mk $(APP)/
  184. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  185. $i "Define PROJECT_ENV"
  186. $t echo "PROJECT_ENV = [{test_key, test_value}]" >> $(APP)/Makefile
  187. $i "Build the application"
  188. $t $(MAKE) -C $(APP) $v
  189. $i "Check that the application was compiled correctly"
  190. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  191. ok = application:load($(APP)), \
  192. {ok, test_value} = application:get_env($(APP), test_key), \
  193. halt()"
  194. $i "Define PROJECT_ENV with escape in string, special char"
  195. $t echo "PROJECT_ENV = [{test_atom, '\\\$$\$$test'}, {test_key, \"\\\"test_\\tvalue\\\"\"}]" >> $(APP)/Makefile
  196. $i "Build the application"
  197. $t $(MAKE) -C $(APP) $v
  198. $i "Check that the application was compiled correctly"
  199. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  200. ok = application:load($(APP)), \
  201. {ok, \"\\\"test_\\tvalue\\\"\"} = application:get_env($(APP), test_key), \
  202. {ok, '\\\$$test'} = application:get_env($(APP), test_atom), \
  203. halt()"
  204. endif
  205. core-app-erlc-exclude: build clean
  206. $i "Bootstrap a new OTP library named $(APP)"
  207. $t mkdir $(APP)/
  208. $t cp ../erlang.mk $(APP)/
  209. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  210. $i "Generate .erl files"
  211. $t echo "-module(boy)." > $(APP)/src/boy.erl
  212. $t echo "-module(girl)." > $(APP)/src/girl.erl
  213. $i "Exclude boy.erl from the compilation"
  214. $t echo "ERLC_EXCLUDE = boy" >> $(APP)/Makefile
  215. $i "Build the application"
  216. $t $(MAKE) -C $(APP) $v
  217. $i "Check that boy.erl was not compiled"
  218. $t test ! -e $(APP)/ebin/boy.beam
  219. $i "Check that the application was compiled correctly (without boy.erl)"
  220. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  221. ok = application:start($(APP)), \
  222. {ok, Mods = [girl]} \
  223. = application:get_key($(APP), modules), \
  224. [{module, M} = code:load_file(M) || M <- Mods], \
  225. halt()"
  226. core-app-erlc-opts: build clean
  227. $i "Bootstrap a new OTP library named $(APP)"
  228. $t mkdir $(APP)/
  229. $t cp ../erlang.mk $(APP)/
  230. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  231. $i "Define an empty ERLC_OPTS (without debug_info)"
  232. $t echo "ERLC_OPTS =" >> $(APP)/Makefile
  233. $i "Generate .erl files"
  234. $t echo "-module(boy)." > $(APP)/src/boy.erl
  235. $t echo "-module(girl)." > $(APP)/src/girl.erl
  236. $i "Build the application"
  237. $t $(MAKE) -C $(APP) $v
  238. $i "Check that the application was compiled correctly (without debug_info)"
  239. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  240. ok = application:start($(APP)), \
  241. {ok, Mods = [boy, girl]} \
  242. = application:get_key($(APP), modules), \
  243. [{module, M} = code:load_file(M) || M <- Mods], \
  244. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  245. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  246. halt()"
  247. core-app-erlc-opts-filter: build clean
  248. $i "Bootstrap a new OTP library named $(APP)"
  249. $t mkdir $(APP)/
  250. $t cp ../erlang.mk $(APP)/
  251. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  252. $i "Define ERLC_OPTS filtering out debug_info"
  253. $t echo "ERLC_OPTS := \$$(filter-out +debug_info,\$$(ERLC_OPTS))" >> $(APP)/Makefile
  254. $i "Generate .erl files"
  255. $t echo "-module(boy)." > $(APP)/src/boy.erl
  256. $t echo "-module(girl)." > $(APP)/src/girl.erl
  257. $i "Build the application"
  258. $t $(MAKE) -C $(APP) $v
  259. $i "Check that the application was compiled correctly (without debug_info)"
  260. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  261. ok = application:start($(APP)), \
  262. {ok, Mods = [boy, girl]} \
  263. = application:get_key($(APP), modules), \
  264. [{module, M} = code:load_file(M) || M <- Mods], \
  265. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  266. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  267. halt()"
  268. core-app-error: build clean
  269. $i "Bootstrap a new OTP library named $(APP)"
  270. $t mkdir $(APP)/
  271. $t cp ../erlang.mk $(APP)/
  272. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  273. $i "Generate a bad .erl files"
  274. $t touch $(APP)/src/breaking.erl
  275. $i "Generate unrelated .erl files"
  276. $t echo "-module(boy)." > $(APP)/src/boy.erl
  277. $t echo "-module(girl)." > $(APP)/src/girl.erl
  278. $i "Check that trying to build returns non-zero"
  279. $t ! $(MAKE) -C $(APP) $v
  280. ifndef LEGACY
  281. core-app-extra-keys: build clean
  282. $i "Bootstrap a new OTP library named $(APP)"
  283. $t mkdir $(APP)/
  284. $t cp ../erlang.mk $(APP)/
  285. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  286. $i "Define PROJECT_APP_EXTRA_KEYS"
  287. $t printf "define PROJECT_APP_EXTRA_KEYS\n\t{maxT, 10000},\n\t{non_standard_key, test_value}\nendef\n" >> $(APP)/Makefile
  288. $i "Build the application"
  289. $t $(MAKE) -C $(APP) $v
  290. $i "Check that the application was compiled correctly"
  291. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  292. ok = application:load($(APP)), \
  293. {ok, 10000} = application:get_key($(APP), maxT), \
  294. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  295. {ok, [App]} = file:consult(AppFile), \
  296. {application, $(APP), Props} = App, \
  297. test_value = proplists:get_value(non_standard_key, Props),\
  298. halt()"
  299. $i "Define PROJECT_APP_EXTRA_KEYS with escape in string, special char"
  300. $t echo "PROJECT_APP_EXTRA_KEYS = {non_standard_atom, '\\\$$\$$my_app'}, {non_standard_string, \"\\\"test_\\tvalue\\\"\"}" >> $(APP)/Makefile
  301. $i "Build the application"
  302. $t $(MAKE) -C $(APP) $v
  303. $i "Check that the application was compiled correctly"
  304. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  305. ok = application:load($(APP)), \
  306. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  307. {ok, [App]} = file:consult(AppFile), \
  308. {application, $(APP), Props} = App, \
  309. '\\\$$my_app' = proplists:get_value(non_standard_atom, Props),\
  310. \"\\\"test_\\tvalue\\\"\" = proplists:get_value(non_standard_string, Props),\
  311. halt()"
  312. endif
  313. core-app-generate-erl: build clean
  314. $i "Bootstrap a new OTP library named $(APP)"
  315. $t mkdir $(APP)/
  316. $t cp ../erlang.mk $(APP)/
  317. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  318. $i "Create a fake script file to be used as dependency"
  319. $t touch $(APP)/script.sh
  320. $i "Append rules to the Makefile to generate a .erl module"
  321. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  322. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  323. $i "Generate unrelated .erl files"
  324. $t echo "-module(boy)." > $(APP)/src/boy.erl
  325. $t echo "-module(girl)." > $(APP)/src/girl.erl
  326. $i "Build the application"
  327. $t $(MAKE) -C $(APP) $v
  328. $i "Check that all compiled files exist"
  329. $t test -f $(APP)/$(APP).d
  330. $t test -f $(APP)/ebin/$(APP).app
  331. $t test -f $(APP)/ebin/boy.beam
  332. $t test -f $(APP)/ebin/generated.beam
  333. $t test -f $(APP)/ebin/girl.beam
  334. $t test -f $(APP)/src/generated.erl
  335. $i "Check that the application was compiled correctly"
  336. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  337. ok = application:start($(APP)), \
  338. {ok, Mods = [boy, generated, girl]} \
  339. = application:get_key($(APP), modules), \
  340. [{module, M} = code:load_file(M) || M <- Mods], \
  341. halt()"
  342. $i "Touch the script file; check that only required files are rebuilt"
  343. $t printf "%s\n" \
  344. $(APP)/$(APP).d \
  345. $(APP)/ebin/$(APP).app \
  346. $(APP)/ebin/generated.beam \
  347. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  348. $t $(SLEEP)
  349. $t touch $(APP)/script.sh
  350. $t $(SLEEP)
  351. $t $(MAKE) -C $(APP) $v
  352. $t find $(APP) -type f -newer $(APP)/script.sh | 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. $i "Clean the application"
  362. $t $(MAKE) -C $(APP) clean $v
  363. $i "Check that source files still exist"
  364. $t test -f $(APP)/Makefile
  365. $t test -f $(APP)/erlang.mk
  366. $t test -f $(APP)/script.sh
  367. ifdef LEGACY
  368. $t test -f $(APP)/src/$(APP).app.src
  369. endif
  370. $t test -f $(APP)/src/boy.erl
  371. $t test -f $(APP)/src/girl.erl
  372. $i "Check that the generated .erl file still exists"
  373. $t test -f $(APP)/src/generated.erl
  374. $i "Check that all build artifacts are removed"
  375. $t test ! -e $(APP)/$(APP).d
  376. $t test ! -e $(APP)/ebin/
  377. $i "Add a rule to remove the generated .erl file on clean"
  378. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  379. $i "Clean the application again"
  380. $t $(MAKE) -C $(APP) clean $v
  381. $i "Check that the generated .erl file was removed"
  382. $t test ! -e $(APP)/src/generated.erl
  383. $i "Build the application again"
  384. $t $(MAKE) -C $(APP) $v
  385. $i "Check that all compiled files exist"
  386. $t test -f $(APP)/$(APP).d
  387. $t test -f $(APP)/ebin/$(APP).app
  388. $t test -f $(APP)/ebin/boy.beam
  389. $t test -f $(APP)/ebin/generated.beam
  390. $t test -f $(APP)/ebin/girl.beam
  391. $t test -f $(APP)/src/generated.erl
  392. $i "Check that the application was compiled correctly"
  393. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  394. ok = application:start($(APP)), \
  395. {ok, Mods = [boy, generated, girl]} \
  396. = application:get_key($(APP), modules), \
  397. [{module, M} = code:load_file(M) || M <- Mods], \
  398. halt()"
  399. core-app-generate-erl-include: build clean
  400. $i "Bootstrap a new OTP library named $(APP)"
  401. $t mkdir $(APP)/
  402. $t cp ../erlang.mk $(APP)/
  403. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  404. $i "Create a fake script file to be used as dependency"
  405. $t touch $(APP)/script.sh
  406. $i "Append rules to the Makefile to generate a .erl module"
  407. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  408. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  409. $i "Generate the .hrl file"
  410. $t mkdir $(APP)/include/
  411. $t touch $(APP)/include/included.hrl
  412. $i "Generate unrelated .erl files"
  413. $t echo "-module(boy)." > $(APP)/src/boy.erl
  414. $t echo "-module(girl)." > $(APP)/src/girl.erl
  415. $i "Build the application"
  416. $t $(MAKE) -C $(APP) $v
  417. $i "Check that all compiled files exist"
  418. $t test -f $(APP)/$(APP).d
  419. $t test -f $(APP)/ebin/$(APP).app
  420. $t test -f $(APP)/ebin/boy.beam
  421. $t test -f $(APP)/ebin/generated.beam
  422. $t test -f $(APP)/ebin/girl.beam
  423. $t test -f $(APP)/src/generated.erl
  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 "Touch the .hrl file; check that only required files are rebuilt"
  432. $t printf "%s\n" \
  433. $(APP)/$(APP).d \
  434. $(APP)/ebin/$(APP).app \
  435. $(APP)/ebin/generated.beam \
  436. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  437. $t $(SLEEP)
  438. $t touch $(APP)/include/included.hrl
  439. $t $(SLEEP)
  440. $t $(MAKE) -C $(APP) $v
  441. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  442. $t rm $(APP)/EXPECT
  443. $i "Check that the application was compiled correctly"
  444. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  445. ok = application:start($(APP)), \
  446. {ok, Mods = [boy, generated, girl]} \
  447. = application:get_key($(APP), modules), \
  448. [{module, M} = code:load_file(M) || M <- Mods], \
  449. halt()"
  450. core-app-generate-erl-prepend: build clean
  451. $i "Bootstrap a new OTP library named $(APP)"
  452. $t mkdir $(APP)/
  453. $t cp ../erlang.mk $(APP)/
  454. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  455. $i "Create a fake script file to be used as dependency"
  456. $t touch $(APP)/script.sh
  457. $i "Generate a Makefile and prepend rules that generate a .erl module"
  458. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  459. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  460. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  461. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  462. $t echo "include erlang.mk" >> $(APP)/Makefile
  463. $i "Generate unrelated .erl files"
  464. $t echo "-module(boy)." > $(APP)/src/boy.erl
  465. $t echo "-module(girl)." > $(APP)/src/girl.erl
  466. $i "Build the application"
  467. $t $(MAKE) -C $(APP) $v
  468. $i "Check that all compiled files exist"
  469. $t test -f $(APP)/$(APP).d
  470. $t test -f $(APP)/ebin/$(APP).app
  471. $t test -f $(APP)/ebin/boy.beam
  472. $t test -f $(APP)/ebin/generated.beam
  473. $t test -f $(APP)/ebin/girl.beam
  474. $t test -f $(APP)/src/generated.erl
  475. $i "Check that the application was compiled correctly"
  476. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  477. ok = application:start($(APP)), \
  478. {ok, Mods = [boy, generated, girl]} \
  479. = application:get_key($(APP), modules), \
  480. [{module, M} = code:load_file(M) || M <- Mods], \
  481. halt()"
  482. $i "Touch the script file; check that only required files are rebuilt"
  483. $t printf "%s\n" \
  484. $(APP)/$(APP).d \
  485. $(APP)/ebin/$(APP).app \
  486. $(APP)/ebin/generated.beam \
  487. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  488. $t $(SLEEP)
  489. $t touch $(APP)/script.sh
  490. $t $(SLEEP)
  491. $t $(MAKE) -C $(APP) $v
  492. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  493. $t rm $(APP)/EXPECT
  494. $i "Check that the application was compiled correctly"
  495. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  496. ok = application:start($(APP)), \
  497. {ok, Mods = [boy, generated, girl]} \
  498. = application:get_key($(APP), modules), \
  499. [{module, M} = code:load_file(M) || M <- Mods], \
  500. halt()"
  501. $i "Clean the application"
  502. $t $(MAKE) -C $(APP) clean $v
  503. $i "Check that source files still exist"
  504. $t test -f $(APP)/Makefile
  505. $t test -f $(APP)/erlang.mk
  506. $t test -f $(APP)/script.sh
  507. ifdef LEGACY
  508. $t test -f $(APP)/src/$(APP).app.src
  509. endif
  510. $t test -f $(APP)/src/boy.erl
  511. $t test -f $(APP)/src/girl.erl
  512. $i "Check that the generated .erl file still exists"
  513. $t test -f $(APP)/src/generated.erl
  514. $i "Check that all build artifacts are removed"
  515. $t test ! -e $(APP)/$(APP).d
  516. $t test ! -e $(APP)/ebin/
  517. $i "Add a rule to remove the generated .erl file on clean"
  518. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  519. $i "Clean the application again"
  520. $t $(MAKE) -C $(APP) clean $v
  521. $i "Check that the generated .erl file was removed"
  522. $t test ! -e $(APP)/src/generated.erl
  523. $i "Build the application again"
  524. $t $(MAKE) -C $(APP) $v
  525. $i "Check that all compiled files exist"
  526. $t test -f $(APP)/$(APP).d
  527. $t test -f $(APP)/ebin/$(APP).app
  528. $t test -f $(APP)/ebin/boy.beam
  529. $t test -f $(APP)/ebin/generated.beam
  530. $t test -f $(APP)/ebin/girl.beam
  531. $t test -f $(APP)/src/generated.erl
  532. $i "Check that the application was compiled correctly"
  533. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  534. ok = application:start($(APP)), \
  535. {ok, Mods = [boy, generated, girl]} \
  536. = application:get_key($(APP), modules), \
  537. [{module, M} = code:load_file(M) || M <- Mods], \
  538. halt()"
  539. core-app-hrl: build clean
  540. $i "Bootstrap a new OTP library named $(APP)"
  541. $t mkdir $(APP)/
  542. $t cp ../erlang.mk $(APP)/
  543. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  544. $i "Generate .hrl files"
  545. $t mkdir $(APP)/include/
  546. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  547. $i "Generate .erl files dependent from headers"
  548. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  549. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  550. $i "Build the application"
  551. $t $(MAKE) -C $(APP) $v
  552. $i "Check that all compiled files exist"
  553. $t test -f $(APP)/$(APP).d
  554. $t test -f $(APP)/ebin/$(APP).app
  555. $t test -f $(APP)/ebin/use_blue.beam
  556. $t test -f $(APP)/ebin/use_red.beam
  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 "Touch one .hrl file; check that only required files are rebuilt"
  565. # The use_red.erl gets touched because of its dependency to red.hrl.
  566. $t printf "%s\n" \
  567. $(APP)/$(APP).d \
  568. $(APP)/ebin/$(APP).app \
  569. $(APP)/ebin/use_red.beam \
  570. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  571. $t $(SLEEP)
  572. $t touch $(APP)/include/red.hrl
  573. $t $(SLEEP)
  574. $t $(MAKE) -C $(APP) $v
  575. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  576. $t rm $(APP)/EXPECT
  577. $i "Check that the application was compiled correctly"
  578. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  579. ok = application:start($(APP)), \
  580. {ok, Mods = [use_blue, use_red]} \
  581. = application:get_key($(APP), modules), \
  582. [{module, M} = code:load_file(M) || M <- Mods], \
  583. halt()"
  584. $i "Clean the application"
  585. $t $(MAKE) -C $(APP) clean $v
  586. $i "Check that source files still exist"
  587. $t test -f $(APP)/Makefile
  588. $t test -f $(APP)/erlang.mk
  589. $t test -f $(APP)/include/blue.hrl
  590. $t test -f $(APP)/include/red.hrl
  591. ifdef LEGACY
  592. $t test -f $(APP)/src/$(APP).app.src
  593. endif
  594. $t test -f $(APP)/src/use_blue.erl
  595. $t test -f $(APP)/src/use_red.erl
  596. $i "Check that all build artifacts are removed"
  597. $t test ! -e $(APP)/$(APP).d
  598. $t test ! -e $(APP)/ebin/
  599. $i "Build the application again"
  600. $t $(MAKE) -C $(APP) $v
  601. $i "Check that all compiled files exist"
  602. $t test -f $(APP)/$(APP).d
  603. $t test -f $(APP)/ebin/$(APP).app
  604. $t test -f $(APP)/ebin/use_blue.beam
  605. $t test -f $(APP)/ebin/use_red.beam
  606. $i "Check that the application was compiled correctly"
  607. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  608. ok = application:start($(APP)), \
  609. {ok, Mods = [use_blue, use_red]} \
  610. = application:get_key($(APP), modules), \
  611. [{module, M} = code:load_file(M) || M <- Mods], \
  612. halt()"
  613. core-app-hrl-recursive: build clean
  614. $i "Bootstrap a new OTP library named $(APP)"
  615. $t mkdir $(APP)/
  616. $t cp ../erlang.mk $(APP)/
  617. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  618. $i "Generate .hrl files"
  619. $t mkdir $(APP)/include/
  620. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  621. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  622. $i "Generate .erl files dependent from headers"
  623. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  624. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  625. $i "Build the application"
  626. $t $(MAKE) -C $(APP) $v
  627. $i "Check that all compiled files exist"
  628. $t test -f $(APP)/$(APP).d
  629. $t test -f $(APP)/ebin/$(APP).app
  630. $t test -f $(APP)/ebin/use_blue.beam
  631. $t test -f $(APP)/ebin/use_red.beam
  632. $i "Check that the application was compiled correctly"
  633. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  634. ok = application:start($(APP)), \
  635. {ok, Mods = [use_blue, use_red]} \
  636. = application:get_key($(APP), modules), \
  637. [{module, M} = code:load_file(M) || M <- Mods], \
  638. halt()"
  639. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  640. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  641. $t printf "%s\n" \
  642. $(APP)/$(APP).d \
  643. $(APP)/ebin/$(APP).app \
  644. $(APP)/ebin/use_red.beam \
  645. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  646. $t $(SLEEP)
  647. $t touch $(APP)/include/pill.hrl
  648. $t $(SLEEP)
  649. $t $(MAKE) -C $(APP) $v
  650. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  651. $t rm $(APP)/EXPECT
  652. $i "Check that the application was compiled correctly"
  653. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  654. ok = application:start($(APP)), \
  655. {ok, Mods = [use_blue, use_red]} \
  656. = application:get_key($(APP), modules), \
  657. [{module, M} = code:load_file(M) || M <- Mods], \
  658. halt()"
  659. $i "Clean the application"
  660. $t $(MAKE) -C $(APP) clean $v
  661. $i "Check that source files still exist"
  662. $t test -f $(APP)/Makefile
  663. $t test -f $(APP)/erlang.mk
  664. $t test -f $(APP)/include/blue.hrl
  665. $t test -f $(APP)/include/pill.hrl
  666. $t test -f $(APP)/include/red.hrl
  667. ifdef LEGACY
  668. $t test -f $(APP)/src/$(APP).app.src
  669. endif
  670. $t test -f $(APP)/src/use_blue.erl
  671. $t test -f $(APP)/src/use_red.erl
  672. $i "Check that all build artifacts are removed"
  673. $t test ! -e $(APP)/$(APP).d
  674. $t test ! -e $(APP)/ebin/
  675. $i "Build the application again"
  676. $t $(MAKE) -C $(APP) $v
  677. $i "Check that all compiled files exist"
  678. $t test -f $(APP)/$(APP).d
  679. $t test -f $(APP)/ebin/$(APP).app
  680. $t test -f $(APP)/ebin/use_blue.beam
  681. $t test -f $(APP)/ebin/use_red.beam
  682. $i "Check that the application was compiled correctly"
  683. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  684. ok = application:start($(APP)), \
  685. {ok, Mods = [use_blue, use_red]} \
  686. = application:get_key($(APP), modules), \
  687. [{module, M} = code:load_file(M) || M <- Mods], \
  688. halt()"
  689. core-app-makefile-change: build clean
  690. $i "Bootstrap a new OTP application named $(APP)"
  691. $t mkdir $(APP)/
  692. $t cp ../erlang.mk $(APP)/
  693. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  694. $i "Build the application"
  695. $t $(MAKE) -C $(APP) $v
  696. $i "Touch the Makefile; check that all files get rebuilt"
  697. $t printf "%s\n" \
  698. $(APP)/$(APP).d \
  699. $(APP)/ebin/$(APP).app \
  700. $(APP)/ebin/$(APP)_app.beam \
  701. $(APP)/ebin/$(APP)_sup.beam \
  702. $(APP)/src/$(APP)_app.erl \
  703. $(APP)/src/$(APP)_sup.erl | sort > $(APP)/EXPECT
  704. $t $(SLEEP)
  705. $t touch $(APP)/Makefile
  706. $t $(SLEEP)
  707. $t $(MAKE) -C $(APP) $v
  708. $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT -
  709. $t rm $(APP)/EXPECT
  710. core-app-mib: build clean
  711. $i "Bootstrap a new OTP library named $(APP)"
  712. $t mkdir $(APP)/
  713. $t cp ../erlang.mk $(APP)/
  714. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  715. $i "Download .mib files from Erlang/OTP"
  716. $t mkdir $(APP)/mibs/
  717. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  718. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
  719. $i "Generate .erl files dependent from headers generated by .mib files"
  720. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  721. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  722. $i "Generate an unrelated .hrl file"
  723. $t mkdir $(APP)/include/
  724. $t touch $(APP)/include/unrelated.hrl
  725. $i "Build the application"
  726. $t $(MAKE) -C $(APP) $v
  727. $i "Check that all compiled files exist"
  728. $t test -f $(APP)/$(APP).d
  729. $t test -f $(APP)/ebin/$(APP).app
  730. $t test -f $(APP)/ebin/use_v1.beam
  731. $t test -f $(APP)/ebin/use_v2.beam
  732. $t test -f $(APP)/include/EX1-MIB.hrl
  733. $t test -f $(APP)/include/OTP-REG.hrl
  734. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  735. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  736. $i "Check that the application was compiled correctly"
  737. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  738. ok = application:start($(APP)), \
  739. {ok, Mods = [use_v1, use_v2]} \
  740. = application:get_key($(APP), modules), \
  741. [{module, M} = code:load_file(M) || M <- Mods], \
  742. halt()"
  743. $i "Touch one .mib file; check that only required files are rebuilt"
  744. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  745. $t printf "%s\n" \
  746. $(APP)/$(APP).d \
  747. $(APP)/ebin/$(APP).app \
  748. $(APP)/ebin/use_v1.beam \
  749. $(APP)/include/EX1-MIB.hrl \
  750. $(APP)/priv/mibs/EX1-MIB.bin \
  751. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  752. $t $(SLEEP)
  753. $t touch $(APP)/mibs/EX1-MIB.mib
  754. $t $(SLEEP)
  755. $t $(MAKE) -C $(APP) $v
  756. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  757. $t rm $(APP)/EXPECT
  758. $i "Check that the application was compiled correctly"
  759. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  760. ok = application:start($(APP)), \
  761. {ok, Mods = [use_v1, use_v2]} \
  762. = application:get_key($(APP), modules), \
  763. [{module, M} = code:load_file(M) || M <- Mods], \
  764. halt()"
  765. $i "Clean the application"
  766. $t $(MAKE) -C $(APP) clean $v
  767. $i "Check that source files still exist"
  768. $t test -f $(APP)/Makefile
  769. $t test -f $(APP)/erlang.mk
  770. $t test -f $(APP)/include/unrelated.hrl
  771. $t test -f $(APP)/mibs/EX1-MIB.mib
  772. $t test -f $(APP)/mibs/OTP-REG.mib
  773. ifdef LEGACY
  774. $t test -f $(APP)/src/$(APP).app.src
  775. endif
  776. $t test -f $(APP)/src/use_v1.erl
  777. $t test -f $(APP)/src/use_v2.erl
  778. $i "Check that all build artifacts are removed, including intermediates"
  779. $t test ! -e $(APP)/$(APP).d
  780. $t test ! -e $(APP)/ebin/
  781. $t test ! -e $(APP)/include/EX1-MIB.hrl
  782. $t test ! -e $(APP)/include/OTP-REG.hrl
  783. $t test ! -e $(APP)/priv/mibs/
  784. $i "Build the application again"
  785. $t $(MAKE) -C $(APP) $v
  786. $i "Check that all compiled files exist"
  787. $t test -f $(APP)/$(APP).d
  788. $t test -f $(APP)/ebin/$(APP).app
  789. $t test -f $(APP)/ebin/use_v1.beam
  790. $t test -f $(APP)/ebin/use_v2.beam
  791. $t test -f $(APP)/include/EX1-MIB.hrl
  792. $t test -f $(APP)/include/OTP-REG.hrl
  793. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  794. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  795. $i "Check that the application was compiled correctly"
  796. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  797. ok = application:start($(APP)), \
  798. {ok, Mods = [use_v1, use_v2]} \
  799. = application:get_key($(APP), modules), \
  800. [{module, M} = code:load_file(M) || M <- Mods], \
  801. halt()"
  802. ifndef LEGACY
  803. core-app-name-special-char: build clean
  804. $i "Bootstrap a new OTP library named $(APP)"
  805. $t mkdir $(APP)/
  806. $t cp ../erlang.mk $(APP)/
  807. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  808. $i "Set PROJECT_DESCRIPTION = test % in the Makefile"
  809. $t echo "PROJECT_DESCRIPTION = test %" >> $(APP)/Makefile
  810. $i "Build the application"
  811. $t $(MAKE) -C $(APP) $v
  812. $i "Check that the application was compiled correctly"
  813. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  814. ok = application:load($(APP)), \
  815. {ok,\"test %\"} = application:get_key($(APP), description), \
  816. halt()"
  817. endif
  818. core-app-no-app: build clean
  819. $i "Bootstrap a project without an OTP library"
  820. $t mkdir $(APP)/
  821. $t cp ../erlang.mk $(APP)/
  822. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  823. $t rm -rf $(APP)/src
  824. $i "Build the project"
  825. $t $(MAKE) -C $(APP) $v
  826. core-app-no-makedep: build clean
  827. $i "Bootstrap a new OTP library named $(APP)"
  828. $t mkdir $(APP)/
  829. $t cp ../erlang.mk $(APP)/
  830. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  831. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  832. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  833. $i "Generate .hrl files"
  834. $t mkdir $(APP)/include/
  835. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  836. $i "Generate .erl files dependent from headers"
  837. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  838. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  839. $i "Build the application"
  840. $t $(MAKE) -C $(APP) $v
  841. $i "Check that all compiled files exist"
  842. $t test -f $(APP)/$(APP).d
  843. $t test -f $(APP)/ebin/$(APP).app
  844. $t test -f $(APP)/ebin/use_blue.beam
  845. $t test -f $(APP)/ebin/use_red.beam
  846. $i "Check that the application was compiled correctly"
  847. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  848. ok = application:start($(APP)), \
  849. {ok, Mods = [use_blue, use_red]} \
  850. = application:get_key($(APP), modules), \
  851. [{module, M} = code:load_file(M) || M <- Mods], \
  852. halt()"
  853. $i "Touch one .hrl file; check that only required files are rebuilt"
  854. # The use_red.erl gets touched because of its dependency to red.hrl.
  855. $t printf "%s\n" \
  856. $(APP)/ebin/$(APP).app \
  857. $(APP)/ebin/use_red.beam \
  858. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  859. $t $(SLEEP)
  860. $t touch $(APP)/include/red.hrl
  861. $t $(SLEEP)
  862. $t $(MAKE) -C $(APP) $v
  863. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  864. $t rm $(APP)/EXPECT
  865. $i "Check that the application was compiled correctly"
  866. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  867. ok = application:start($(APP)), \
  868. {ok, Mods = [use_blue, use_red]} \
  869. = application:get_key($(APP), modules), \
  870. [{module, M} = code:load_file(M) || M <- Mods], \
  871. halt()"
  872. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  873. # The use_red.erl gets touched because of its dependency to red.hrl.
  874. $t printf "%s\n" \
  875. $(APP)/$(APP).d \
  876. $(APP)/ebin/$(APP).app \
  877. $(APP)/ebin/use_red.beam \
  878. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  879. $t $(SLEEP)
  880. $t touch $(APP)/include/red.hrl
  881. $t $(SLEEP)
  882. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  883. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  884. $t rm $(APP)/EXPECT
  885. $i "Check that the application was compiled correctly"
  886. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  887. ok = application:start($(APP)), \
  888. {ok, Mods = [use_blue, use_red]} \
  889. = application:get_key($(APP), modules), \
  890. [{module, M} = code:load_file(M) || M <- Mods], \
  891. halt()"
  892. $i "Clean the application"
  893. $t $(MAKE) -C $(APP) clean $v
  894. $i "Check that source files still exist"
  895. $t test -f $(APP)/Makefile
  896. $t test -f $(APP)/erlang.mk
  897. $t test -f $(APP)/include/blue.hrl
  898. $t test -f $(APP)/include/red.hrl
  899. ifdef LEGACY
  900. $t test -f $(APP)/src/$(APP).app.src
  901. endif
  902. $t test -f $(APP)/src/use_blue.erl
  903. $t test -f $(APP)/src/use_red.erl
  904. $i "Check that all build artifacts are removed"
  905. $t test ! -e $(APP)/$(APP).d
  906. $t test ! -e $(APP)/ebin/
  907. $i "Build the application again"
  908. $t $(MAKE) -C $(APP) $v
  909. $i "Check that all compiled files exist"
  910. $t test -f $(APP)/$(APP).d
  911. $t test -f $(APP)/ebin/$(APP).app
  912. $t test -f $(APP)/ebin/use_blue.beam
  913. $t test -f $(APP)/ebin/use_red.beam
  914. $i "Check that the application was compiled correctly"
  915. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  916. ok = application:start($(APP)), \
  917. {ok, Mods = [use_blue, use_red]} \
  918. = application:get_key($(APP), modules), \
  919. [{module, M} = code:load_file(M) || M <- Mods], \
  920. halt()"
  921. core-app-project-mod: build clean
  922. $i "Bootstrap a new OTP library named $(APP)"
  923. $t mkdir $(APP)/
  924. $t cp ../erlang.mk $(APP)/
  925. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  926. $i "Generate an application module"
  927. $t printf "%s\n" \
  928. "-module(app_mod)." \
  929. "-export([start/2, stop/1])." \
  930. "start(_StartType, _StartArgs) -> {ok, self()}." \
  931. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  932. $i "Build the application with PROJECT_MOD"
  933. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  934. $i "Check that the application starts correctly"
  935. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  936. core-app-pt: build clean
  937. $i "Bootstrap a new OTP library named $(APP)"
  938. $t mkdir $(APP)/
  939. $t cp ../erlang.mk $(APP)/
  940. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  941. $i "Generate a parse_transform module"
  942. $t printf "%s\n" \
  943. "-module(my_pt)." \
  944. "-export([parse_transform/2])." \
  945. "parse_transform(Forms, _) ->" \
  946. " io:format(\"# Running my_pt parse_transform.~n\")," \
  947. " Forms." > $(APP)/src/my_pt.erl
  948. $i "Generate a .erl file that uses the my_pt parse_transform"
  949. $t printf "%s\n" \
  950. "-module(my_user)." \
  951. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  952. $i "Compile my_pt first"
  953. $t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
  954. $i "Build the application; confirm the parse_transform is used"
  955. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  956. $i "Check that the application was compiled correctly"
  957. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  958. ok = application:start($(APP)), \
  959. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  960. [{module, M} = code:load_file(M) || M <- Mods], \
  961. halt()"
  962. core-app-pt-erlc-opts: build clean
  963. $i "Bootstrap a new OTP library named $(APP)"
  964. $t mkdir $(APP)/
  965. $t cp ../erlang.mk $(APP)/
  966. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  967. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  968. $t mkdir -p $(APP)/deps/my_pt_dep/
  969. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  970. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  971. $i "Generate a parse_transform module in my_pt_dep"
  972. $t printf "%s\n" \
  973. "-module(my_pt)." \
  974. "-export([parse_transform/2])." \
  975. "parse_transform(Forms, _) ->" \
  976. " io:format(\"# Running my_pt parse_transform.~n\")," \
  977. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  978. $i "Add my_pt_dep to the list of dependencies"
  979. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  980. $i "Generate .erl files"
  981. $t echo "-module(boy)." > $(APP)/src/boy.erl
  982. $t echo "-module(girl)." > $(APP)/src/girl.erl
  983. $i "Add the my_pt parse_transform to ERLC_OPTS"
  984. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  985. $i "Build the application; confirm the parse_transform is used"
  986. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  987. $i "Check that the application was compiled correctly"
  988. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  989. ok = application:start($(APP)), \
  990. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  991. [{module, M} = code:load_file(M) || M <- Mods], \
  992. halt()"
  993. core-app-xrl: build clean
  994. $i "Bootstrap a new OTP library named $(APP)"
  995. $t mkdir $(APP)/
  996. $t cp ../erlang.mk $(APP)/
  997. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  998. $i "Download .xrl files from Robert"
  999. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  1000. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  1001. $i "Generate unrelated .erl files"
  1002. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1003. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1004. $i "Disable warnings; our test .xrl files aren't perfect"
  1005. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1006. $i "Build the application"
  1007. $t $(MAKE) -C $(APP) $v
  1008. $i "Check that all compiled files exist"
  1009. $t test -f $(APP)/$(APP).d
  1010. $t test -f $(APP)/ebin/$(APP).app
  1011. $t test -f $(APP)/ebin/boy.beam
  1012. $t test -f $(APP)/ebin/erlang_scan.beam
  1013. $t test -f $(APP)/ebin/girl.beam
  1014. $t test -f $(APP)/ebin/lfe_scan.beam
  1015. $t test -f $(APP)/src/erlang_scan.erl
  1016. $t test -f $(APP)/src/lfe_scan.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, erlang_scan, girl, lfe_scan]} \
  1021. = application:get_key($(APP), modules), \
  1022. [{module, M} = code:load_file(M) || M <- Mods], \
  1023. halt()"
  1024. $i "Touch one .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/erlang_scan.beam \
  1029. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  1030. $t $(SLEEP)
  1031. $t touch $(APP)/src/erlang_scan.xrl
  1032. $t $(SLEEP)
  1033. $t $(MAKE) -C $(APP) $v
  1034. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.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, erlang_scan, girl, lfe_scan]} \
  1040. = application:get_key($(APP), modules), \
  1041. [{module, M} = code:load_file(M) || M <- Mods], \
  1042. halt()"
  1043. $i "Clean the application"
  1044. $t $(MAKE) -C $(APP) clean $v
  1045. $i "Check that source files still exist"
  1046. $t test -f $(APP)/Makefile
  1047. $t test -f $(APP)/erlang.mk
  1048. ifdef LEGACY
  1049. $t test -f $(APP)/src/$(APP).app.src
  1050. endif
  1051. $t test -f $(APP)/src/boy.erl
  1052. $t test -f $(APP)/src/erlang_scan.xrl
  1053. $t test -f $(APP)/src/girl.erl
  1054. $t test -f $(APP)/src/lfe_scan.xrl
  1055. $i "Check that all build artifacts are removed, including intermediates"
  1056. $t test ! -e $(APP)/$(APP).d
  1057. $t test ! -e $(APP)/ebin/
  1058. $t test ! -e $(APP)/src/erlang_scan.erl
  1059. $t test ! -e $(APP)/src/lfe_scan.erl
  1060. $i "Build the application again"
  1061. $t $(MAKE) -C $(APP) $v
  1062. $i "Check that all compiled files exist"
  1063. $t test -f $(APP)/$(APP).d
  1064. $t test -f $(APP)/ebin/$(APP).app
  1065. $t test -f $(APP)/ebin/boy.beam
  1066. $t test -f $(APP)/ebin/erlang_scan.beam
  1067. $t test -f $(APP)/ebin/girl.beam
  1068. $t test -f $(APP)/ebin/lfe_scan.beam
  1069. $t test -f $(APP)/src/erlang_scan.erl
  1070. $t test -f $(APP)/src/lfe_scan.erl
  1071. $i "Check that the application was compiled correctly"
  1072. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1073. ok = application:start($(APP)), \
  1074. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1075. = application:get_key($(APP), modules), \
  1076. [{module, M} = code:load_file(M) || M <- Mods], \
  1077. halt()"
  1078. core-app-xrl-help: build clean
  1079. $i "Bootstrap a new OTP library named $(APP)"
  1080. $t mkdir $(APP)/
  1081. $t cp ../erlang.mk $(APP)/
  1082. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1083. $i "Download an .xrl file from Robert"
  1084. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  1085. $i "Disable warnings; our test .xrl files aren't perfect"
  1086. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1087. $i "Run 'make help'"
  1088. $t $(MAKE) -C $(APP) help $v
  1089. $i "Check that no files were compiled"
  1090. $t test ! -e $(APP)/$(APP).d
  1091. $t test ! -e $(APP)/ebin/$(APP).app
  1092. $t test ! -e $(APP)/ebin/erlang_scan.beam
  1093. $t test ! -e $(APP)/src/erlang_scan.erl
  1094. core-app-xrl-include: build clean
  1095. $i "Bootstrap a new OTP library named $(APP)"
  1096. $t mkdir $(APP)/
  1097. $t cp ../erlang.mk $(APP)/
  1098. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1099. $i "Download a .xrl file with numerous includes from Gordon"
  1100. $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
  1101. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1102. $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
  1103. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1104. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  1105. $i "Generate unrelated .erl files"
  1106. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1107. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1108. $i "Disable warnings; our test .xrl files aren't perfect"
  1109. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1110. $i "Build the application"
  1111. $t $(MAKE) -C $(APP) $v
  1112. $i "Check that all compiled files exist"
  1113. $t test -f $(APP)/$(APP).d
  1114. $t test -f $(APP)/ebin/$(APP).app
  1115. $t test -f $(APP)/ebin/boy.beam
  1116. $t test -f $(APP)/ebin/girl.beam
  1117. $t test -f $(APP)/ebin/xfl_lexer.beam
  1118. $t test -f $(APP)/src/xfl_lexer.erl
  1119. $i "Check that the application was compiled correctly"
  1120. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1121. ok = application:start($(APP)), \
  1122. {ok, Mods = [boy, girl, xfl_lexer]} \
  1123. = application:get_key($(APP), modules), \
  1124. [{module, M} = code:load_file(M) || M <- Mods], \
  1125. halt()"
  1126. $i "Touch the .xrl file; check that only required files are rebuilt"
  1127. $t printf "%s\n" \
  1128. $(APP)/$(APP).d \
  1129. $(APP)/ebin/$(APP).app \
  1130. $(APP)/ebin/xfl_lexer.beam \
  1131. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1132. $t $(SLEEP)
  1133. $t touch $(APP)/src/xfl_lexer.xrl
  1134. $t $(SLEEP)
  1135. $t $(MAKE) -C $(APP) $v
  1136. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1137. $t rm $(APP)/EXPECT
  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, xfl_lexer]} \
  1142. = application:get_key($(APP), modules), \
  1143. [{module, M} = code:load_file(M) || M <- Mods], \
  1144. halt()"
  1145. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1146. $t printf "%s\n" \
  1147. $(APP)/$(APP).d \
  1148. $(APP)/ebin/$(APP).app \
  1149. $(APP)/ebin/xfl_lexer.beam \
  1150. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1151. $t $(SLEEP)
  1152. $t touch $(APP)/src/typechecks.hrl
  1153. $t $(SLEEP)
  1154. $t $(MAKE) -C $(APP) $v
  1155. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | 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, xfl_lexer]} \
  1161. = application:get_key($(APP), modules), \
  1162. [{module, M} = code:load_file(M) || M <- Mods], \
  1163. halt()"
  1164. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1165. $t printf "%s\n" \
  1166. $(APP)/$(APP).d \
  1167. $(APP)/ebin/$(APP).app \
  1168. $(APP)/ebin/xfl_lexer.beam \
  1169. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1170. $t $(SLEEP)
  1171. $t touch $(APP)/src/errvals.hrl
  1172. $t $(SLEEP)
  1173. $t $(MAKE) -C $(APP) $v
  1174. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1175. $t rm $(APP)/EXPECT
  1176. $i "Check that the application was compiled correctly"
  1177. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1178. ok = application:start($(APP)), \
  1179. {ok, Mods = [boy, girl, xfl_lexer]} \
  1180. = application:get_key($(APP), modules), \
  1181. [{module, M} = code:load_file(M) || M <- Mods], \
  1182. halt()"
  1183. $i "Clean the application"
  1184. $t $(MAKE) -C $(APP) clean $v
  1185. $i "Check that source files still exist"
  1186. $t test -f $(APP)/Makefile
  1187. $t test -f $(APP)/erlang.mk
  1188. ifdef LEGACY
  1189. $t test -f $(APP)/src/$(APP).app.src
  1190. endif
  1191. $t test -f $(APP)/src/boy.erl
  1192. $t test -f $(APP)/src/girl.erl
  1193. $t test -f $(APP)/src/errvals.hrl
  1194. $t test -f $(APP)/src/muin_proc_dict.hrl
  1195. $t test -f $(APP)/src/muin_records.hrl
  1196. $t test -f $(APP)/src/typechecks.hrl
  1197. $t test -f $(APP)/src/xfl_lexer.xrl
  1198. $i "Check that all build artifacts are removed, including intermediates"
  1199. $t test ! -e $(APP)/$(APP).d
  1200. $t test ! -e $(APP)/ebin/
  1201. $t test ! -e $(APP)/src/xfl_lexer.erl
  1202. $i "Build the application again"
  1203. $t $(MAKE) -C $(APP) $v
  1204. $i "Check that all compiled files exist"
  1205. $t test -f $(APP)/$(APP).d
  1206. $t test -f $(APP)/ebin/$(APP).app
  1207. $t test -f $(APP)/ebin/boy.beam
  1208. $t test -f $(APP)/ebin/girl.beam
  1209. $t test -f $(APP)/ebin/xfl_lexer.beam
  1210. $t test -f $(APP)/src/xfl_lexer.erl
  1211. $i "Check that the application was compiled correctly"
  1212. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1213. ok = application:start($(APP)), \
  1214. {ok, Mods = [boy, girl, xfl_lexer]} \
  1215. = application:get_key($(APP), modules), \
  1216. [{module, M} = code:load_file(M) || M <- Mods], \
  1217. halt()"
  1218. core-app-yrl: build clean
  1219. $i "Bootstrap a new OTP library named $(APP)"
  1220. $t mkdir $(APP)/
  1221. $t cp ../erlang.mk $(APP)/
  1222. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1223. $i "Download .yrl files from Erlang/OTP"
  1224. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1225. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1226. $i "Generate unrelated .erl files"
  1227. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1228. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1229. $i "Build the application"
  1230. $t $(MAKE) -C $(APP) $v
  1231. $i "Check that all compiled files exist"
  1232. $t test -f $(APP)/$(APP).d
  1233. $t test -f $(APP)/ebin/$(APP).app
  1234. $t test -f $(APP)/ebin/boy.beam
  1235. $t test -f $(APP)/ebin/girl.beam
  1236. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1237. $t test -f $(APP)/ebin/xref_parser.beam
  1238. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1239. $t test -f $(APP)/src/xref_parser.erl
  1240. $i "Check that the application was compiled correctly"
  1241. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1242. ok = application:start($(APP)), \
  1243. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1244. = application:get_key($(APP), modules), \
  1245. [{module, M} = code:load_file(M) || M <- Mods], \
  1246. halt()"
  1247. $i "Touch one .yrl file; check that only required files are rebuilt"
  1248. $t printf "%s\n" \
  1249. $(APP)/$(APP).d \
  1250. $(APP)/ebin/$(APP).app \
  1251. $(APP)/ebin/xref_parser.beam \
  1252. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1253. $t $(SLEEP)
  1254. $t touch $(APP)/src/xref_parser.yrl
  1255. $t $(SLEEP)
  1256. $t $(MAKE) -C $(APP) $v
  1257. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1258. $t rm $(APP)/EXPECT
  1259. $i "Check that the application was compiled correctly"
  1260. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1261. ok = application:start($(APP)), \
  1262. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1263. = application:get_key($(APP), modules), \
  1264. [{module, M} = code:load_file(M) || M <- Mods], \
  1265. halt()"
  1266. $i "Clean the application"
  1267. $t $(MAKE) -C $(APP) clean $v
  1268. $i "Check that source files still exist"
  1269. $t test -f $(APP)/Makefile
  1270. $t test -f $(APP)/erlang.mk
  1271. ifdef LEGACY
  1272. $t test -f $(APP)/src/$(APP).app.src
  1273. endif
  1274. $t test -f $(APP)/src/boy.erl
  1275. $t test -f $(APP)/src/girl.erl
  1276. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1277. $t test -f $(APP)/src/xref_parser.yrl
  1278. $i "Check that all build artifacts are removed, including intermediates"
  1279. $t test ! -e $(APP)/$(APP).d
  1280. $t test ! -e $(APP)/ebin/
  1281. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1282. $t test ! -e $(APP)/src/xref_parser.erl
  1283. $i "Build the application again"
  1284. $t $(MAKE) -C $(APP) $v
  1285. $i "Check that all compiled files exist"
  1286. $t test -f $(APP)/$(APP).d
  1287. $t test -f $(APP)/ebin/$(APP).app
  1288. $t test -f $(APP)/ebin/boy.beam
  1289. $t test -f $(APP)/ebin/girl.beam
  1290. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1291. $t test -f $(APP)/ebin/xref_parser.beam
  1292. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1293. $t test -f $(APP)/src/xref_parser.erl
  1294. $i "Check that the application was compiled correctly"
  1295. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1296. ok = application:start($(APP)), \
  1297. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1298. = application:get_key($(APP), modules), \
  1299. [{module, M} = code:load_file(M) || M <- Mods], \
  1300. halt()"
  1301. core-app-yrl-header: build clean
  1302. $i "Bootstrap a new OTP library named $(APP)"
  1303. $t mkdir $(APP)/
  1304. $t cp ../erlang.mk $(APP)/
  1305. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1306. $i "Create a .yrl file"
  1307. $t echo "Nonterminals E T F." > $(APP)/src/y_parse.yrl
  1308. $t echo "Terminals '+' '*' '(' ')' number." >> $(APP)/src/y_parse.yrl
  1309. $t echo "Rootsymbol E." >> $(APP)/src/y_parse.yrl
  1310. $t echo "E -> E '+' T: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1311. $t echo "E -> T : '\$$1'." >> $(APP)/src/y_parse.yrl
  1312. $t echo "T -> T '*' F: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1313. $t echo "T -> F : '\$$1'." >> $(APP)/src/y_parse.yrl
  1314. $t echo "F -> '(' E ')' : '\$$2'." >> $(APP)/src/y_parse.yrl
  1315. $t echo "F -> number : '\$$1'. " >> $(APP)/src/y_parse.yrl
  1316. $i "Create the yrl header file"
  1317. $t mkdir $(APP)/include
  1318. $t echo "-export([forty_two/0])." > $(APP)/include/yecc_header.hrl
  1319. # A bunch of gobbldygook we don't actually care about, they just
  1320. # need to exist so we don't get errors.
  1321. $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
  1322. $t echo "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1323. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1324. # Required bits done, now part we'll actually test for.
  1325. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1326. $i "Generate unrelated .erl files"
  1327. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1328. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1329. $i "Build the application"
  1330. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1331. $i "Check that all compiled files exist"
  1332. $t test -f $(APP)/$(APP).d
  1333. $t test -f $(APP)/ebin/$(APP).app
  1334. $t test -f $(APP)/ebin/boy.beam
  1335. $t test -f $(APP)/ebin/girl.beam
  1336. $t test -f $(APP)/ebin/y_parse.beam
  1337. $t test -f $(APP)/src/y_parse.erl
  1338. $i "Check that the application was compiled correctly"
  1339. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1340. ok = application:start($(APP)), \
  1341. {ok, Mods = [boy, girl, y_parse]} \
  1342. = application:get_key($(APP), modules), \
  1343. [{module, M} = code:load_file(M) || M <- Mods], \
  1344. halt()"
  1345. $i "Check the built yecc module used the header"
  1346. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1347. {module, y_parse} = code:load_file(y_parse), \
  1348. 42 = y_parse:forty_two(), \
  1349. halt()"
  1350. $i "Check that the application was compiled correctly"
  1351. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1352. ok = application:start($(APP)), \
  1353. {ok, Mods = [boy, girl, y_parse]} \
  1354. = application:get_key($(APP), modules), \
  1355. [{module, M} = code:load_file(M) || M <- Mods], \
  1356. halt()"
  1357. core-app-yrl-include: build clean
  1358. $i "Bootstrap a new OTP library named $(APP)"
  1359. $t mkdir $(APP)/
  1360. $t cp ../erlang.mk $(APP)/
  1361. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1362. $i "Download a .yrl file with includes from Erlang/OTP"
  1363. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1364. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1365. $i "Generate unrelated .erl files"
  1366. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1367. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1368. $i "Build the application"
  1369. $t $(MAKE) -C $(APP) $v
  1370. $i "Check that all compiled files exist"
  1371. $t test -f $(APP)/$(APP).d
  1372. $t test -f $(APP)/ebin/$(APP).app
  1373. $t test -f $(APP)/ebin/boy.beam
  1374. $t test -f $(APP)/ebin/core_parse.beam
  1375. $t test -f $(APP)/ebin/girl.beam
  1376. $t test -f $(APP)/src/core_parse.erl
  1377. $i "Check that the application was compiled correctly"
  1378. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1379. ok = application:start($(APP)), \
  1380. {ok, Mods = [boy, core_parse, girl]} \
  1381. = application:get_key($(APP), modules), \
  1382. [{module, M} = code:load_file(M) || M <- Mods], \
  1383. halt()"
  1384. $i "Touch the .yrl file; check that only required files are rebuilt"
  1385. $t printf "%s\n" \
  1386. $(APP)/$(APP).d \
  1387. $(APP)/ebin/$(APP).app \
  1388. $(APP)/ebin/core_parse.beam \
  1389. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1390. $t $(SLEEP)
  1391. $t touch $(APP)/src/core_parse.yrl
  1392. $t $(SLEEP)
  1393. $t $(MAKE) -C $(APP) $v
  1394. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1395. $t rm $(APP)/EXPECT
  1396. $i "Check that the application was compiled correctly"
  1397. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1398. ok = application:start($(APP)), \
  1399. {ok, Mods = [boy, core_parse, girl]} \
  1400. = application:get_key($(APP), modules), \
  1401. [{module, M} = code:load_file(M) || M <- Mods], \
  1402. halt()"
  1403. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1404. $t printf "%s\n" \
  1405. $(APP)/$(APP).d \
  1406. $(APP)/ebin/$(APP).app \
  1407. $(APP)/ebin/core_parse.beam \
  1408. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1409. $t $(SLEEP)
  1410. $t touch $(APP)/src/core_parse.hrl
  1411. $t $(SLEEP)
  1412. $t $(MAKE) -C $(APP) $v
  1413. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1414. $t rm $(APP)/EXPECT
  1415. $i "Check that the application was compiled correctly"
  1416. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1417. ok = application:start($(APP)), \
  1418. {ok, Mods = [boy, core_parse, girl]} \
  1419. = application:get_key($(APP), modules), \
  1420. [{module, M} = code:load_file(M) || M <- Mods], \
  1421. halt()"
  1422. $i "Clean the application"
  1423. $t $(MAKE) -C $(APP) clean $v
  1424. $i "Check that source files still exist"
  1425. $t test -f $(APP)/Makefile
  1426. $t test -f $(APP)/erlang.mk
  1427. ifdef LEGACY
  1428. $t test -f $(APP)/src/$(APP).app.src
  1429. endif
  1430. $t test -f $(APP)/src/boy.erl
  1431. $t test -f $(APP)/src/core_parse.hrl
  1432. $t test -f $(APP)/src/core_parse.yrl
  1433. $t test -f $(APP)/src/girl.erl
  1434. $i "Check that all build artifacts are removed, including intermediates"
  1435. $t test ! -e $(APP)/$(APP).d
  1436. $t test ! -e $(APP)/ebin/
  1437. $t test ! -e $(APP)/src/core_parse.erl
  1438. $i "Build the application again"
  1439. $t $(MAKE) -C $(APP) $v
  1440. $i "Check that all compiled files exist"
  1441. $t test -f $(APP)/$(APP).d
  1442. $t test -f $(APP)/ebin/$(APP).app
  1443. $t test -f $(APP)/ebin/boy.beam
  1444. $t test -f $(APP)/ebin/core_parse.beam
  1445. $t test -f $(APP)/ebin/girl.beam
  1446. $t test -f $(APP)/src/core_parse.erl
  1447. $i "Check that the application was compiled correctly"
  1448. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1449. ok = application:start($(APP)), \
  1450. {ok, Mods = [boy, core_parse, girl]} \
  1451. = application:get_key($(APP), modules), \
  1452. [{module, M} = code:load_file(M) || M <- Mods], \
  1453. halt()"
  1454. core-app-hrl-include-lib: build clean
  1455. $i "Bootstrap a new OTP library named $(APP)"
  1456. $t mkdir $(APP)/
  1457. $t cp ../erlang.mk $(APP)/
  1458. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1459. $i "Generate .hrl files"
  1460. $t mkdir $(APP)/include/
  1461. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  1462. $i "Generate .erl files dependent from headers"
  1463. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1464. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1465. $i "Build the application"
  1466. $t $(MAKE) -C $(APP) $v
  1467. $i "Check that all compiled files exist"
  1468. $t test -f $(APP)/$(APP).d
  1469. $t test -f $(APP)/ebin/$(APP).app
  1470. $t test -f $(APP)/ebin/use_blue.beam
  1471. $t test -f $(APP)/ebin/use_red.beam
  1472. $i "Check that the application was compiled correctly"
  1473. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1474. ok = application:start($(APP)), \
  1475. {ok, Mods = [use_blue, use_red]} \
  1476. = application:get_key($(APP), modules), \
  1477. [{module, M} = code:load_file(M) || M <- Mods], \
  1478. halt()"
  1479. $i "Touch one .hrl file; check that only required files are rebuilt"
  1480. # The use_red.erl gets touched because of its dependency to red.hrl.
  1481. $t printf "%s\n" \
  1482. $(APP)/$(APP).d \
  1483. $(APP)/ebin/$(APP).app \
  1484. $(APP)/ebin/use_red.beam \
  1485. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1486. $t $(SLEEP)
  1487. $t touch $(APP)/include/red.hrl
  1488. $t $(SLEEP)
  1489. $t $(MAKE) -C $(APP) $v
  1490. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  1491. $t rm $(APP)/EXPECT
  1492. $i "Check that the application was compiled correctly"
  1493. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1494. ok = application:start($(APP)), \
  1495. {ok, Mods = [use_blue, use_red]} \
  1496. = application:get_key($(APP), modules), \
  1497. [{module, M} = code:load_file(M) || M <- Mods], \
  1498. halt()"
  1499. $i "Clean the application"
  1500. $t $(MAKE) -C $(APP) clean $v
  1501. $i "Check that source files still exist"
  1502. $t test -f $(APP)/Makefile
  1503. $t test -f $(APP)/erlang.mk
  1504. $t test -f $(APP)/include/blue.hrl
  1505. $t test -f $(APP)/include/red.hrl
  1506. ifdef LEGACY
  1507. $t test -f $(APP)/src/$(APP).app.src
  1508. endif
  1509. $t test -f $(APP)/src/use_blue.erl
  1510. $t test -f $(APP)/src/use_red.erl
  1511. $i "Check that all build artifacts are removed"
  1512. $t test ! -e $(APP)/$(APP).d
  1513. $t test ! -e $(APP)/ebin/
  1514. $i "Build the application again"
  1515. $t $(MAKE) -C $(APP) $v
  1516. $i "Check that all compiled files exist"
  1517. $t test -f $(APP)/$(APP).d
  1518. $t test -f $(APP)/ebin/$(APP).app
  1519. $t test -f $(APP)/ebin/use_blue.beam
  1520. $t test -f $(APP)/ebin/use_red.beam
  1521. $i "Check that the application was compiled correctly"
  1522. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1523. ok = application:start($(APP)), \
  1524. {ok, Mods = [use_blue, use_red]} \
  1525. = application:get_key($(APP), modules), \
  1526. [{module, M} = code:load_file(M) || M <- Mods], \
  1527. halt()"
  1528. core-app-hrl-include-lib-recursive: build clean
  1529. $i "Bootstrap a new OTP library named $(APP)"
  1530. $t mkdir $(APP)/
  1531. $t cp ../erlang.mk $(APP)/
  1532. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1533. $i "Generate .hrl files"
  1534. $t mkdir $(APP)/include/
  1535. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  1536. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/include/red.hrl
  1537. $i "Generate .erl files dependent from headers"
  1538. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1539. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1540. $i "Build the application"
  1541. $t $(MAKE) -C $(APP) $v
  1542. $i "Check that all compiled files exist"
  1543. $t test -f $(APP)/$(APP).d
  1544. $t test -f $(APP)/ebin/$(APP).app
  1545. $t test -f $(APP)/ebin/use_blue.beam
  1546. $t test -f $(APP)/ebin/use_red.beam
  1547. $i "Check that the application was compiled correctly"
  1548. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1549. ok = application:start($(APP)), \
  1550. {ok, Mods = [use_blue, use_red]} \
  1551. = application:get_key($(APP), modules), \
  1552. [{module, M} = code:load_file(M) || M <- Mods], \
  1553. halt()"
  1554. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1555. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1556. $t printf "%s\n" \
  1557. $(APP)/$(APP).d \
  1558. $(APP)/ebin/$(APP).app \
  1559. $(APP)/ebin/use_red.beam \
  1560. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1561. $t $(SLEEP)
  1562. $t touch $(APP)/include/pill.hrl
  1563. $t $(SLEEP)
  1564. $t $(MAKE) -C $(APP) $v
  1565. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1566. $t rm $(APP)/EXPECT
  1567. $i "Check that the application was compiled correctly"
  1568. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1569. ok = application:start($(APP)), \
  1570. {ok, Mods = [use_blue, use_red]} \
  1571. = application:get_key($(APP), modules), \
  1572. [{module, M} = code:load_file(M) || M <- Mods], \
  1573. halt()"
  1574. $i "Clean the application"
  1575. $t $(MAKE) -C $(APP) clean $v
  1576. $i "Check that source files still exist"
  1577. $t test -f $(APP)/Makefile
  1578. $t test -f $(APP)/erlang.mk
  1579. $t test -f $(APP)/include/blue.hrl
  1580. $t test -f $(APP)/include/pill.hrl
  1581. $t test -f $(APP)/include/red.hrl
  1582. ifdef LEGACY
  1583. $t test -f $(APP)/src/$(APP).app.src
  1584. endif
  1585. $t test -f $(APP)/src/use_blue.erl
  1586. $t test -f $(APP)/src/use_red.erl
  1587. $i "Check that all build artifacts are removed"
  1588. $t test ! -e $(APP)/$(APP).d
  1589. $t test ! -e $(APP)/ebin/
  1590. $i "Build the application again"
  1591. $t $(MAKE) -C $(APP) $v
  1592. $i "Check that all compiled files exist"
  1593. $t test -f $(APP)/$(APP).d
  1594. $t test -f $(APP)/ebin/$(APP).app
  1595. $t test -f $(APP)/ebin/use_blue.beam
  1596. $t test -f $(APP)/ebin/use_red.beam
  1597. $i "Check that the application was compiled correctly"
  1598. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1599. ok = application:start($(APP)), \
  1600. {ok, Mods = [use_blue, use_red]} \
  1601. = application:get_key($(APP), modules), \
  1602. [{module, M} = code:load_file(M) || M <- Mods], \
  1603. halt()"
  1604. core-app-hrl-multiapps-include-lib: build clean
  1605. $i "Create a multi application repository with no root application"
  1606. $t mkdir $(APP)/
  1607. $t cp ../erlang.mk $(APP)/
  1608. $t echo "include erlang.mk" > $(APP)/Makefile
  1609. $i "Create a new application named my_app"
  1610. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1611. $i "Create a new library named my_lib"
  1612. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1613. $i "Add my_lib as LOCAL_DEPS of my_app"
  1614. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1615. $i "Generate .hrl files"
  1616. $t mkdir $(APP)/apps/my_lib/include/
  1617. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl
  1618. $i "Generate .erl files dependent from headers"
  1619. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1620. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1621. $i "Build the application"
  1622. $t $(MAKE) -C $(APP) $v
  1623. $i "Check that all compiled files exist"
  1624. $t test -f $(APP)/apps/my_app/my_app.d
  1625. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1626. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1627. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1628. $i "Check that the application was compiled correctly"
  1629. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1630. {ok, _Apps } = application:ensure_all_started(my_app), \
  1631. {ok, Mods = [use_blue, use_red]} \
  1632. = application:get_key(my_app, modules), \
  1633. [{module, M} = code:load_file(M) || M <- Mods], \
  1634. halt()"
  1635. $i "Touch one .hrl file; check that only required files are rebuilt"
  1636. # The use_red.erl gets touched because of its dependency to red.hrl.
  1637. $t printf "%s\n" \
  1638. $(APP)/apps/my_app/my_app.d \
  1639. $(APP)/apps/my_app/ebin/my_app.app \
  1640. $(APP)/apps/my_app/ebin/use_red.beam \
  1641. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1642. $t $(SLEEP)
  1643. $t touch $(APP)/apps/my_lib/include/red.hrl
  1644. $t $(SLEEP)
  1645. $t $(MAKE) -C $(APP) $v
  1646. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  1647. $t rm $(APP)/EXPECT
  1648. $i "Check that the application was compiled correctly"
  1649. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1650. {ok, _Apps } = application:ensure_all_started(my_app), \
  1651. {ok, Mods = [use_blue, use_red]} \
  1652. = application:get_key(my_app, modules), \
  1653. [{module, M} = code:load_file(M) || M <- Mods], \
  1654. halt()"
  1655. $i "Clean the application"
  1656. $t $(MAKE) -C $(APP) clean $v
  1657. $i "Check that source files still exist"
  1658. $t test -f $(APP)/Makefile
  1659. $t test -f $(APP)/erlang.mk
  1660. $t test -f $(APP)/apps/my_lib/Makefile
  1661. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1662. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1663. $t test -f $(APP)/apps/my_app/Makefile
  1664. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1665. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1666. ifdef LEGACY
  1667. $t test -f $(APP)/apps/my_lib.app.src
  1668. $t test -f $(APP)/apps/my_app.app.src
  1669. endif
  1670. $i "Check that all build artifacts are removed"
  1671. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1672. $t test ! -e $(APP)/apps/my_lib/ebin/
  1673. $t test ! -e $(APP)/apps/my_app/my_app.d
  1674. $t test ! -e $(APP)/apps/my_app/ebin/
  1675. $i "Build the application again"
  1676. $t $(MAKE) -C $(APP) $v
  1677. $i "Check that all compiled files exist"
  1678. $t test -f $(APP)/apps/my_app/my_app.d
  1679. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1680. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1681. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1682. $i "Check that the application was compiled correctly"
  1683. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1684. {ok, _Apps } = application:ensure_all_started(my_app), \
  1685. {ok, Mods = [use_blue, use_red]} \
  1686. = application:get_key(my_app, modules), \
  1687. [{module, M} = code:load_file(M) || M <- Mods], \
  1688. halt()"
  1689. core-app-hrl-multiapps-include-lib-recursive: build clean
  1690. $i "Create a multi application repository with no root application"
  1691. $t mkdir $(APP)/
  1692. $t cp ../erlang.mk $(APP)/
  1693. $t echo "include erlang.mk" > $(APP)/Makefile
  1694. $i "Create a new application named my_app"
  1695. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1696. $i "Create a new library named my_lib"
  1697. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1698. $i "Add my_lib as LOCAL_DEPS of my_app"
  1699. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1700. $i "Generate .hrl files"
  1701. $t mkdir $(APP)/apps/my_lib/include/
  1702. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl $(APP)/apps/my_lib/include/pill.hrl
  1703. $t echo "-include(\"pill.hrl\")." > $(APP)/apps/my_lib/include/red.hrl
  1704. $i "Generate .erl files dependent from headers"
  1705. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1706. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1707. $i "Build the application"
  1708. $t $(MAKE) -C $(APP) $v
  1709. $i "Check that all compiled files exist"
  1710. $t test -f $(APP)/apps/my_app/my_app.d
  1711. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1712. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1713. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1714. $i "Check that the application was compiled correctly"
  1715. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1716. {ok, _Apps } = application:ensure_all_started(my_app), \
  1717. {ok, Mods = [use_blue, use_red]} \
  1718. = application:get_key(my_app, modules), \
  1719. [{module, M} = code:load_file(M) || M <- Mods], \
  1720. halt()"
  1721. $i "Touch one .hrl file; check that only required files are rebuilt"
  1722. # The use_red.erl gets touched because of its dependency to red.hrl.
  1723. $t printf "%s\n" \
  1724. $(APP)/apps/my_app/my_app.d \
  1725. $(APP)/apps/my_app/ebin/my_app.app \
  1726. $(APP)/apps/my_app/ebin/use_red.beam \
  1727. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1728. $t $(SLEEP)
  1729. $t touch $(APP)/apps/my_lib/include/pill.hrl
  1730. $t $(SLEEP)
  1731. $t $(MAKE) -C $(APP) $v
  1732. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1733. $t rm $(APP)/EXPECT
  1734. $i "Check that the application was compiled correctly"
  1735. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1736. {ok, _Apps } = application:ensure_all_started(my_app), \
  1737. {ok, Mods = [use_blue, use_red]} \
  1738. = application:get_key(my_app, modules), \
  1739. [{module, M} = code:load_file(M) || M <- Mods], \
  1740. halt()"
  1741. $i "Clean the application"
  1742. $t $(MAKE) -C $(APP) clean $v
  1743. $i "Check that source files still exist"
  1744. $t test -f $(APP)/Makefile
  1745. $t test -f $(APP)/erlang.mk
  1746. $t test -f $(APP)/apps/my_lib/Makefile
  1747. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1748. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1749. $t test -f $(APP)/apps/my_lib/include/pill.hrl
  1750. $t test -f $(APP)/apps/my_app/Makefile
  1751. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1752. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1753. ifdef LEGACY
  1754. $t test -f $(APP)/apps/my_lib.app.src
  1755. $t test -f $(APP)/apps/my_app.app.src
  1756. endif
  1757. $i "Check that all build artifacts are removed"
  1758. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1759. $t test ! -e $(APP)/apps/my_lib/ebin/
  1760. $t test ! -e $(APP)/apps/my_app/my_app.d
  1761. $t test ! -e $(APP)/apps/my_app/ebin/
  1762. $i "Build the application again"
  1763. $t $(MAKE) -C $(APP) $v
  1764. $i "Check that all compiled files exist"
  1765. $t test -f $(APP)/apps/my_app/my_app.d
  1766. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1767. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1768. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1769. $i "Check that the application was compiled correctly"
  1770. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1771. {ok, _Apps } = application:ensure_all_started(my_app), \
  1772. {ok, Mods = [use_blue, use_red]} \
  1773. = application:get_key(my_app, modules), \
  1774. [{module, M} = code:load_file(M) || M <- Mods], \
  1775. halt()"
  1776. core-app-hrl-include-lib-src: build clean
  1777. $i "Bootstrap a new OTP library named $(APP)"
  1778. $t mkdir $(APP)/
  1779. $t cp ../erlang.mk $(APP)/
  1780. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1781. $t touch $(APP)/src/blue.hrl $(APP)/src/red.hrl
  1782. $i "Generate .erl files dependent from headers"
  1783. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1784. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1785. $i "Build the application"
  1786. $t $(MAKE) -C $(APP) $v
  1787. $i "Check that all compiled files exist"
  1788. $t test -f $(APP)/$(APP).d
  1789. $t test -f $(APP)/ebin/$(APP).app
  1790. $t test -f $(APP)/ebin/use_blue.beam
  1791. $t test -f $(APP)/ebin/use_red.beam
  1792. $i "Check that the application was compiled correctly"
  1793. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1794. ok = application:start($(APP)), \
  1795. {ok, Mods = [use_blue, use_red]} \
  1796. = application:get_key($(APP), modules), \
  1797. [{module, M} = code:load_file(M) || M <- Mods], \
  1798. halt()"
  1799. $i "Touch one .hrl file; check that only required files are rebuilt"
  1800. # The use_red.erl gets touched because of its dependency to red.hrl.
  1801. $t printf "%s\n" \
  1802. $(APP)/$(APP).d \
  1803. $(APP)/ebin/$(APP).app \
  1804. $(APP)/ebin/use_red.beam \
  1805. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1806. $t $(SLEEP)
  1807. $t touch $(APP)/src/red.hrl
  1808. $t $(SLEEP)
  1809. $t $(MAKE) -C $(APP) $v
  1810. $t find $(APP) -type f -newer $(APP)/src/red.hrl | sort | diff $(APP)/EXPECT -
  1811. $t rm $(APP)/EXPECT
  1812. $i "Check that the application was compiled correctly"
  1813. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1814. ok = application:start($(APP)), \
  1815. {ok, Mods = [use_blue, use_red]} \
  1816. = application:get_key($(APP), modules), \
  1817. [{module, M} = code:load_file(M) || M <- Mods], \
  1818. halt()"
  1819. $i "Clean the application"
  1820. $t $(MAKE) -C $(APP) clean $v
  1821. $i "Check that source files still exist"
  1822. $t test -f $(APP)/Makefile
  1823. $t test -f $(APP)/erlang.mk
  1824. $t test -f $(APP)/src/blue.hrl
  1825. $t test -f $(APP)/src/red.hrl
  1826. ifdef LEGACY
  1827. $t test -f $(APP)/src/$(APP).app.src
  1828. endif
  1829. $t test -f $(APP)/src/use_blue.erl
  1830. $t test -f $(APP)/src/use_red.erl
  1831. $i "Check that all build artifacts are removed"
  1832. $t test ! -e $(APP)/$(APP).d
  1833. $t test ! -e $(APP)/ebin/
  1834. $i "Build the application again"
  1835. $t $(MAKE) -C $(APP) $v
  1836. $i "Check that all compiled files exist"
  1837. $t test -f $(APP)/$(APP).d
  1838. $t test -f $(APP)/ebin/$(APP).app
  1839. $t test -f $(APP)/ebin/use_blue.beam
  1840. $t test -f $(APP)/ebin/use_red.beam
  1841. $i "Check that the application was compiled correctly"
  1842. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1843. ok = application:start($(APP)), \
  1844. {ok, Mods = [use_blue, use_red]} \
  1845. = application:get_key($(APP), modules), \
  1846. [{module, M} = code:load_file(M) || M <- Mods], \
  1847. halt()"
  1848. core-app-hrl-include-lib-src-recursive: build clean
  1849. $i "Bootstrap a new OTP library named $(APP)"
  1850. $t mkdir $(APP)/
  1851. $t cp ../erlang.mk $(APP)/
  1852. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1853. $i "Generate .hrl files"
  1854. $t touch $(APP)/src/blue.hrl $(APP)/src/pill.hrl
  1855. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/src/red.hrl
  1856. $i "Generate .erl files dependent from headers"
  1857. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1858. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1859. $i "Build the application"
  1860. $t $(MAKE) -C $(APP) $v
  1861. $i "Check that all compiled files exist"
  1862. $t test -f $(APP)/$(APP).d
  1863. $t test -f $(APP)/ebin/$(APP).app
  1864. $t test -f $(APP)/ebin/use_blue.beam
  1865. $t test -f $(APP)/ebin/use_red.beam
  1866. $i "Check that the application was compiled correctly"
  1867. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1868. ok = application:start($(APP)), \
  1869. {ok, Mods = [use_blue, use_red]} \
  1870. = application:get_key($(APP), modules), \
  1871. [{module, M} = code:load_file(M) || M <- Mods], \
  1872. halt()"
  1873. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1874. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1875. $t printf "%s\n" \
  1876. $(APP)/$(APP).d \
  1877. $(APP)/ebin/$(APP).app \
  1878. $(APP)/ebin/use_red.beam \
  1879. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1880. $t $(SLEEP)
  1881. $t touch $(APP)/src/pill.hrl
  1882. $t $(SLEEP)
  1883. $t $(MAKE) -C $(APP) $v
  1884. $t find $(APP) -type f -newer $(APP)/src/pill.hrl | sort | diff $(APP)/EXPECT -
  1885. $t rm $(APP)/EXPECT
  1886. $i "Check that the application was compiled correctly"
  1887. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1888. ok = application:start($(APP)), \
  1889. {ok, Mods = [use_blue, use_red]} \
  1890. = application:get_key($(APP), modules), \
  1891. [{module, M} = code:load_file(M) || M <- Mods], \
  1892. halt()"
  1893. $i "Clean the application"
  1894. $t $(MAKE) -C $(APP) clean $v
  1895. $i "Check that source files still exist"
  1896. $t test -f $(APP)/Makefile
  1897. $t test -f $(APP)/erlang.mk
  1898. $t test -f $(APP)/src/blue.hrl
  1899. $t test -f $(APP)/src/pill.hrl
  1900. $t test -f $(APP)/src/red.hrl
  1901. ifdef LEGACY
  1902. $t test -f $(APP)/src/$(APP).app.src
  1903. endif
  1904. $t test -f $(APP)/src/use_blue.erl
  1905. $t test -f $(APP)/src/use_red.erl
  1906. $i "Check that all build artifacts are removed"
  1907. $t test ! -e $(APP)/$(APP).d
  1908. $t test ! -e $(APP)/ebin/
  1909. $i "Build the application again"
  1910. $t $(MAKE) -C $(APP) $v
  1911. $i "Check that all compiled files exist"
  1912. $t test -f $(APP)/$(APP).d
  1913. $t test -f $(APP)/ebin/$(APP).app
  1914. $t test -f $(APP)/ebin/use_blue.beam
  1915. $t test -f $(APP)/ebin/use_red.beam
  1916. $i "Check that the application was compiled correctly"
  1917. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1918. ok = application:start($(APP)), \
  1919. {ok, Mods = [use_blue, use_red]} \
  1920. = application:get_key($(APP), modules), \
  1921. [{module, M} = code:load_file(M) || M <- Mods], \
  1922. halt()"
  1923. core-app-hrl-deps: build clean
  1924. $i "Create a multi application repository with no root application"
  1925. $t mkdir $(APP)/
  1926. $t cp ../erlang.mk $(APP)/
  1927. $t echo "include erlang.mk" > $(APP)/Makefile
  1928. $i "Create a new application named my_app"
  1929. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1930. $t echo "DEPS = cowlib" > $(APP)/apps/my_app/Makefile
  1931. $t echo "include ../../erlang.mk" >> $(APP)/apps/my_app/Makefile
  1932. $t printf "%s\n" "-module(boy)." "-include_lib(\"cowlib/include/cow_inline.hrl\")." > $(APP)/apps/my_app/src/boy.erl
  1933. $t printf "%s\n" "-module(girl)." > $(APP)/apps/my_app/src/girl.erl
  1934. $i "Build the application"
  1935. $t $(MAKE) -C $(APP) $v
  1936. $i "Check that all compiled files exist"
  1937. $t test -f $(APP)/apps/my_app/my_app.d
  1938. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1939. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  1940. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  1941. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  1942. # Applications in apps are compiled automatically but not added
  1943. # to the application resource file unless they are listed in LOCAL_DEPS.
  1944. $i "Check that the application was compiled correctly"
  1945. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  1946. ok = application:load(my_app), \
  1947. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  1948. true = lists:member(cowlib, MyAppDeps), \
  1949. halt()"
  1950. $i "Touch cowlib .hrl file; check that only required files are rebuilt"
  1951. $t printf "%s\n" \
  1952. $(APP)/apps/my_app/my_app.d \
  1953. $(APP)/apps/my_app/ebin/my_app.app \
  1954. $(APP)/apps/my_app/ebin/boy.beam \
  1955. $(APP)/apps/my_app/src/boy.erl | sort > $(APP)/EXPECT
  1956. $t $(SLEEP)
  1957. $t touch $(APP)/deps/cowlib/include/cow_inline.hrl
  1958. $t $(SLEEP)
  1959. $t $(MAKE) -C $(APP) $v
  1960. $t find $(APP)/apps/my_app -type f -newer $(APP)/deps/cowlib/include/cow_inline.hrl | sort | diff $(APP)/EXPECT -
  1961. $t rm $(APP)/EXPECT
  1962. $i "Clean Cowlib"
  1963. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  1964. $i "Check that Cowlib compiled files were removed"
  1965. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  1966. $i "Build the application again"
  1967. $t $(MAKE) -C $(APP) $v
  1968. $i "Check that Cowlib compiled files exist"
  1969. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  1970. $i "Clean the application"
  1971. $t $(MAKE) -C $(APP) clean $v
  1972. $i "Check that Cowlib is still here"
  1973. $t test -d $(APP)/deps/cowlib
  1974. $i "Check that all relevant files were removed"
  1975. $t test ! -e $(APP)/apps/my_app/my_app.d
  1976. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  1977. $t test ! -e $(APP)/apps/my_app/ebin/boy.beam
  1978. $t test ! -e $(APP)/apps/my_app/ebin/girl.beam
  1979. $i "Distclean the application"
  1980. $t $(MAKE) -C $(APP) distclean $v
  1981. $i "Check that all relevant files were removed"
  1982. $t test ! -e $(APP)/deps
  1983. $i "Build the application"
  1984. $t $(MAKE) -C $(APP) $v
  1985. $i "Check that all compiled files exist"
  1986. $t test -f $(APP)/apps/my_app/my_app.d
  1987. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1988. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  1989. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  1990. $t test -d $(APP)/deps/cowlib
  1991. $i "Check that the application was compiled correctly"
  1992. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  1993. ok = application:load(my_app), \
  1994. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  1995. true = lists:member(cowlib, MyAppDeps), \
  1996. halt()"
  1997. core-app-hrl-include-loop: build clean
  1998. $i "Bootstrap a new OTP library named $(APP)"
  1999. $t mkdir $(APP)/
  2000. $t cp ../erlang.mk $(APP)/
  2001. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2002. $i "Generate .hrl files with header loop"
  2003. $t mkdir $(APP)/include/
  2004. $t printf "%s\n" "-include(\"blue.hrl\")." > $(APP)/include/red.hrl
  2005. $t printf "%s\n" "-include(\"red.hrl\")." > $(APP)/include/blue.hrl
  2006. $i "Generate .erl files dependent from headers"
  2007. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2008. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2009. $i "Build the application. Compilation should fail"
  2010. $t ! $(MAKE) -C $(APP) $v
  2011. $i "Check .d file"
  2012. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2013. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2014. core-app-hrl-include_lib-loop: build clean
  2015. $i "Bootstrap a new OTP library named $(APP)"
  2016. $t mkdir $(APP)/
  2017. $t cp ../erlang.mk $(APP)/
  2018. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2019. $i "Generate .hrl files with heaeder loop"
  2020. $t mkdir $(APP)/include/
  2021. $t printf "%s\n" "-include_lib(\"blue.hrl\")." > $(APP)/include/red.hrl
  2022. $t printf "%s\n" "-include_lib(\"red.hrl\")." > $(APP)/include/blue.hrl
  2023. $i "Generate .erl files dependent from headers"
  2024. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2025. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2026. $i "Build the application. Compilation should fail"
  2027. $t ! $(MAKE) -C $(APP) $v
  2028. $i "Check .d file"
  2029. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2030. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2031. core-app-hrl-include-loop-define-protected: build clean
  2032. $i "Bootstrap a new OTP library named $(APP)"
  2033. $t mkdir $(APP)/
  2034. $t cp ../erlang.mk $(APP)/
  2035. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2036. $i "Generate .hrl files with hrl loop protection "
  2037. $t mkdir $(APP)/include/
  2038. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2039. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2040. $i "Generate .erl files dependent from headers"
  2041. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2042. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2043. $i "Build the application. Compilation should fail"
  2044. $t ! $(MAKE) -C $(APP) $v ; ret=$$?
  2045. $i "Check .d file"
  2046. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2047. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2048. core-app-hrl-include_lib-loop-define-protected: build clean
  2049. $i "Bootstrap a new OTP library named $(APP)"
  2050. $t mkdir $(APP)/
  2051. $t cp ../erlang.mk $(APP)/
  2052. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2053. $i "Generate .hrl files with hrl loop protection "
  2054. $t mkdir $(APP)/include/
  2055. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2056. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2057. $i "Generate .erl files dependent from headers"
  2058. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2059. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2060. $i "Build the application"
  2061. $t $(MAKE) -C $(APP) $v ; ret=$$?
  2062. $i "Check .d file"
  2063. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2064. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2065. core-app-hrl-multiapps-include-loop-define-protected: build clean
  2066. $i "Create a multi application repository with no root application"
  2067. $t mkdir $(APP)/
  2068. $t cp ../erlang.mk $(APP)/
  2069. $t echo "include erlang.mk" > $(APP)/Makefile
  2070. $i "Create a new application named my_app"
  2071. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  2072. $i "Create a new library named my_lib"
  2073. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  2074. $i "Add my_lib as LOCAL_DEPS of my_app"
  2075. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  2076. $i "Generate .hrl files"
  2077. $t mkdir $(APP)/apps/my_lib/include/
  2078. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/apps/my_lib/include/blue.hrl
  2079. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/apps/my_lib/include/red.hrl
  2080. $i "Generate .erl files dependent from headers"
  2081. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  2082. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  2083. $i "Build the application"
  2084. $t $(MAKE) -C $(APP) $v
  2085. $i "Check that all compiled files exist"
  2086. $t test -f $(APP)/apps/my_app/my_app.d
  2087. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2088. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2089. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2090. $i "Check that the application was compiled correctly"
  2091. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2092. {ok, _Apps } = application:ensure_all_started(my_app), \
  2093. {ok, Mods = [use_blue, use_red]} \
  2094. = application:get_key(my_app, modules), \
  2095. [{module, M} = code:load_file(M) || M <- Mods], \
  2096. halt()"
  2097. $i "Touch one .hrl file; check that only required files are rebuilt"
  2098. # The use_red.erl gets touched because of its dependency to red.hrl.
  2099. $t printf "%s\n" \
  2100. $(APP)/apps/my_app/my_app.d \
  2101. $(APP)/apps/my_app/ebin/my_app.app \
  2102. $(APP)/apps/my_app/ebin/use_red.beam \
  2103. $(APP)/apps/my_app/src/use_red.erl \
  2104. $(APP)/apps/my_app/src/use_blue.erl \
  2105. $(APP)/apps/my_app/ebin/use_blue.beam | sort > $(APP)/EXPECT
  2106. $t $(SLEEP)
  2107. $t touch $(APP)/apps/my_lib/include/red.hrl
  2108. $t $(SLEEP)
  2109. $t $(MAKE) -C $(APP) $v
  2110. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  2111. $t rm $(APP)/EXPECT
  2112. $i "Check that the application was compiled correctly"
  2113. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2114. {ok, _Apps } = application:ensure_all_started(my_app), \
  2115. {ok, Mods = [use_blue, use_red]} \
  2116. = application:get_key(my_app, modules), \
  2117. [{module, M} = code:load_file(M) || M <- Mods], \
  2118. halt()"
  2119. $i "Clean the application"
  2120. $t $(MAKE) -C $(APP) clean $v
  2121. $i "Check that source files still exist"
  2122. $t test -f $(APP)/Makefile
  2123. $t test -f $(APP)/erlang.mk
  2124. $t test -f $(APP)/apps/my_lib/Makefile
  2125. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  2126. $t test -f $(APP)/apps/my_lib/include/red.hrl
  2127. $t test -f $(APP)/apps/my_app/Makefile
  2128. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  2129. $t test -f $(APP)/apps/my_app/src/use_red.erl
  2130. ifdef LEGACY
  2131. $t test -f $(APP)/apps/my_lib.app.src
  2132. $t test -f $(APP)/apps/my_app.app.src
  2133. endif
  2134. $i "Check that all build artifacts are removed"
  2135. $t test ! -e $(APP)/apps/my_lib/my_app.d
  2136. $t test ! -e $(APP)/apps/my_lib/ebin/
  2137. $t test ! -e $(APP)/apps/my_app/my_app.d
  2138. $t test ! -e $(APP)/apps/my_app/ebin/
  2139. $i "Build the application again"
  2140. $t $(MAKE) -C $(APP) $v
  2141. $i "Check that all compiled files exist"
  2142. $t test -f $(APP)/apps/my_app/my_app.d
  2143. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2144. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2145. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2146. $i "Check that the application was compiled correctly"
  2147. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2148. {ok, _Apps } = application:ensure_all_started(my_app), \
  2149. {ok, Mods = [use_blue, use_red]} \
  2150. = application:get_key(my_app, modules), \
  2151. [{module, M} = code:load_file(M) || M <- Mods], \
  2152. halt()"