core_compat.mk 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. # Core: Compatibility with other build tools.
  2. #
  3. # Note: autopatch functionality is covered separately.
  4. CORE_COMPAT_CASES = auto-rebar rebar rebar-deps rebar-deps-pkg rebar-erlc-opts
  5. CORE_COMPAT_TARGETS = $(addprefix core-compat-,$(CORE_COMPAT_CASES))
  6. CORE_COMPAT_CLEAN_TARGETS = $(addprefix clean-,$(CORE_COMPAT_TARGETS))
  7. REBAR_BINARY = https://github.com/rebar/rebar/releases/download/2.6.0/rebar
  8. .PHONY: core-compat $(CORE_COMPAT_TARGETS) clean-core-compat $(CORE_COMPAT_CLEAN_TARGETS)
  9. clean-core-compat: $(CORE_COMPAT_CLEAN_TARGETS)
  10. $(CORE_COMPAT_CLEAN_TARGETS):
  11. $t rm -rf $(APP_TO_CLEAN)/
  12. core-compat: $(CORE_COMPAT_TARGETS)
  13. core-compat-auto-rebar: build clean-core-compat-auto-rebar
  14. $i "Bootstrap a new OTP library named $(APP)"
  15. $t mkdir $(APP)/
  16. $t cp ../erlang.mk $(APP)/
  17. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  18. $i "Add rebar.config as a dependency of 'app' target"
  19. $t echo "app:: rebar.config" >> $(APP)/Makefile
  20. $i "Build the application"
  21. $t $(MAKE) -C $(APP) $v
  22. $i "Check that rebar.config was created"
  23. $t test -f $(APP)/rebar.config
  24. $i "Check that rebar.config can be loaded"
  25. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  26. $i "Create a temporary file"
  27. $t touch $(APP)/older_file
  28. $i "Wait a second"
  29. $t sleep 1
  30. $i "Build the application again"
  31. $t $(MAKE) -C $(APP) $v
  32. $i "Check that rebar.config is newer than the temporary file"
  33. $t test $(APP)/rebar.config -nt $(APP)/older_file
  34. $i "Check that rebar.config can be loaded"
  35. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  36. $i "Distclean the application"
  37. $t $(MAKE) -C $(APP) distclean $v
  38. $i "Download rebar"
  39. $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
  40. $t chmod +x $(APP)/rebar
  41. $i "Use rebar to build the application"
  42. $t cd $(APP) && ./rebar compile $v
  43. core-compat-rebar: build clean-core-compat-rebar
  44. $i "Bootstrap a new OTP library named $(APP)"
  45. $t mkdir $(APP)/
  46. $t cp ../erlang.mk $(APP)/
  47. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  48. $i "Run 'make rebar.config'"
  49. $t $(MAKE) -C $(APP) rebar.config $v
  50. $i "Check that rebar.config was created"
  51. $t test -f $(APP)/rebar.config
  52. $i "Check that rebar.config can be loaded"
  53. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  54. $i "Create a temporary file"
  55. $t touch $(APP)/older_file
  56. $i "Wait a second"
  57. $t sleep 1
  58. $i "Run 'make rebar.config' again"
  59. $t $(MAKE) -C $(APP) rebar.config $v
  60. $i "Check that rebar.config is newer than the temporary file"
  61. $t test $(APP)/rebar.config -nt $(APP)/older_file
  62. $i "Check that rebar.config can be loaded"
  63. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  64. $i "Distclean the application"
  65. $t $(MAKE) -C $(APP) distclean $v
  66. $i "Download rebar"
  67. $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
  68. $t chmod +x $(APP)/rebar
  69. $i "Use rebar to build the application"
  70. $t cd $(APP) && ./rebar compile $v
  71. core-compat-rebar-deps: build clean-core-compat-rebar-deps
  72. $i "Bootstrap a new OTP library named $(APP)"
  73. $t mkdir $(APP)/
  74. $t cp ../erlang.mk $(APP)/
  75. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  76. $i "Add Cowboy as a dependency"
  77. $t sed -i.bak '2i\
  78. DEPS = cowboy\
  79. dep_cowboy = git https://github.com/ninenines/cowboy 1.0.0\
  80. ' $(APP)/Makefile
  81. $i "Run 'make rebar.config'"
  82. $t $(MAKE) -C $(APP) rebar.config $v
  83. $i "Check that rebar.config was created"
  84. $t test -f $(APP)/rebar.config
  85. $i "Check that Cowboy is listed in rebar.config"
  86. $t $(ERL) -eval " \
  87. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  88. {_, [{cowboy, _, {git, _, \"1.0.0\"}}]} = lists:keyfind(deps, 1, C), \
  89. halt()"
  90. $i "Distclean the application"
  91. $t $(MAKE) -C $(APP) distclean $v
  92. $i "Download rebar"
  93. $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
  94. $t chmod +x $(APP)/rebar
  95. $i "Use rebar to build the application"
  96. $t cd $(APP) && ./rebar get-deps compile $v
  97. core-compat-rebar-deps-pkg: build clean-core-compat-rebar-deps-pkg
  98. $i "Bootstrap a new OTP library named $(APP)"
  99. $t mkdir $(APP)/
  100. $t cp ../erlang.mk $(APP)/
  101. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  102. $i "Add Cowboy package as a dependency"
  103. $t sed -i.bak '2i\
  104. DEPS = cowboy\
  105. ' $(APP)/Makefile
  106. $i "Run 'make rebar.config'"
  107. $t $(MAKE) -C $(APP) rebar.config $v
  108. $i "Check that rebar.config was created"
  109. $t test -f $(APP)/rebar.config
  110. $i "Check that Cowboy is listed in rebar.config"
  111. $t $(ERL) -eval " \
  112. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  113. {_, [{cowboy, _, {git, \"https://github.com/\" ++ _, _}}]} = lists:keyfind(deps, 1, C), \
  114. halt()"
  115. $i "Distclean the application"
  116. $t $(MAKE) -C $(APP) distclean $v
  117. $i "Download rebar"
  118. $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
  119. $t chmod +x $(APP)/rebar
  120. $i "Use rebar to build the application"
  121. $t cd $(APP) && ./rebar get-deps compile $v
  122. core-compat-rebar-erlc-opts: build clean-core-compat-rebar-erlc-opts
  123. $i "Bootstrap a new OTP library named $(APP)"
  124. $t mkdir $(APP)/
  125. $t cp ../erlang.mk $(APP)/
  126. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  127. $i "Add extra options to ERLC_OPTS"
  128. $t echo "ERLC_OPTS += +warn_export_all +warn_missing_spec +warn_untyped_record" >> $(APP)/Makefile
  129. $i "Run 'make rebar.config'"
  130. $t $(MAKE) -C $(APP) rebar.config $v
  131. $i "Check that rebar.config was created"
  132. $t test -f $(APP)/rebar.config
  133. $i "Check that -Werror is not listed in rebar.config"
  134. $t $(ERL) -eval " \
  135. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  136. {_, Opts} = lists:keyfind(erl_opts, 1, C), \
  137. false = lists:member(warning_as_errors, Opts), \
  138. halt()"
  139. $i "Check that debug_info is listed in rebar.config"
  140. $t $(ERL) -eval " \
  141. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  142. {_, Opts} = lists:keyfind(erl_opts, 1, C), \
  143. true = lists:member(debug_info, Opts), \
  144. halt()"
  145. $i "Check that extra options are listed in rebar.config"
  146. $t $(ERL) -eval " \
  147. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  148. {_, Opts} = lists:keyfind(erl_opts, 1, C), \
  149. true = lists:member(warn_export_all, Opts), \
  150. true = lists:member(warn_missing_spec, Opts), \
  151. true = lists:member(warn_untyped_record, Opts), \
  152. halt()"
  153. $i "Distclean the application"
  154. $t $(MAKE) -C $(APP) distclean $v
  155. $i "Download rebar"
  156. $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
  157. $t chmod +x $(APP)/rebar
  158. $i "Use rebar to build the application"
  159. $t cd $(APP) && ./rebar compile $v