core_compat.mk 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. .PHONY: core-compat $(CORE_COMPAT_TARGETS) clean-core-compat $(CORE_COMPAT_CLEAN_TARGETS)
  8. clean-core-compat: $(CORE_COMPAT_CLEAN_TARGETS)
  9. $(CORE_COMPAT_CLEAN_TARGETS):
  10. $t rm -rf $(APP_TO_CLEAN)/
  11. core-compat: $(CORE_COMPAT_TARGETS)
  12. core-compat-auto-rebar: build clean-core-compat-auto-rebar
  13. $i "Bootstrap a new OTP library named $(APP)"
  14. $t mkdir $(APP)/
  15. $t cp ../erlang.mk $(APP)/
  16. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  17. $i "Add rebar.config as a dependency of 'app' target"
  18. $t echo "app:: rebar.config" >> $(APP)/Makefile
  19. $i "Build the application"
  20. $t $(MAKE) -C $(APP) $v
  21. $i "Check that rebar.config was created"
  22. $t test -f $(APP)/rebar.config
  23. $i "Check that rebar.config can be loaded"
  24. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  25. $i "Create a temporary file"
  26. $t touch $(APP)/older_file
  27. $i "Wait a second"
  28. $t sleep 1
  29. $i "Build the application again"
  30. $t $(MAKE) -C $(APP) $v
  31. $i "Check that rebar.config is newer than the temporary file"
  32. $t test $(APP)/rebar.config -nt $(APP)/older_file
  33. $i "Check that rebar.config can be loaded"
  34. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  35. core-compat-rebar: build clean-core-compat-rebar
  36. $i "Bootstrap a new OTP library named $(APP)"
  37. $t mkdir $(APP)/
  38. $t cp ../erlang.mk $(APP)/
  39. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  40. $i "Run 'make rebar.config'"
  41. $t $(MAKE) -C $(APP) rebar.config $v
  42. $i "Check that rebar.config was created"
  43. $t test -f $(APP)/rebar.config
  44. $i "Check that rebar.config can be loaded"
  45. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  46. $i "Create a temporary file"
  47. $t touch $(APP)/older_file
  48. $i "Wait a second"
  49. $t sleep 1
  50. $i "Run 'make rebar.config' again"
  51. $t $(MAKE) -C $(APP) rebar.config $v
  52. $i "Check that rebar.config is newer than the temporary file"
  53. $t test $(APP)/rebar.config -nt $(APP)/older_file
  54. $i "Check that rebar.config can be loaded"
  55. $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
  56. core-compat-rebar-deps: build clean-core-compat-rebar-deps
  57. $i "Bootstrap a new OTP library named $(APP)"
  58. $t mkdir $(APP)/
  59. $t cp ../erlang.mk $(APP)/
  60. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  61. $i "Add Cowboy as a dependency"
  62. $t sed -i.bak '2i\
  63. DEPS = cowboy\
  64. dep_cowboy = git repo commit\
  65. ' $(APP)/Makefile
  66. $i "Run 'make rebar.config'"
  67. $t $(MAKE) -C $(APP) rebar.config $v
  68. $i "Check that rebar.config was created"
  69. $t test -f $(APP)/rebar.config
  70. $i "Check that Cowboy is listed in rebar.config"
  71. $t $(ERL) -eval " \
  72. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  73. {_, [{cowboy, _, {git, \"repo\", \"commit\"}}]} = lists:keyfind(deps, 1, C), \
  74. halt()"
  75. core-compat-rebar-deps-pkg: build clean-core-compat-rebar-deps-pkg
  76. $i "Bootstrap a new OTP library named $(APP)"
  77. $t mkdir $(APP)/
  78. $t cp ../erlang.mk $(APP)/
  79. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  80. $i "Add Cowboy package as a dependency"
  81. $t sed -i.bak '2i\
  82. DEPS = cowboy\
  83. ' $(APP)/Makefile
  84. $i "Run 'make rebar.config'"
  85. $t $(MAKE) -C $(APP) rebar.config $v
  86. $i "Check that rebar.config was created"
  87. $t test -f $(APP)/rebar.config
  88. $i "Check that Cowboy is listed in rebar.config"
  89. $t $(ERL) -eval " \
  90. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  91. {_, [{cowboy, _, {git, \"https://github.com/\" ++ _, _}}]} = lists:keyfind(deps, 1, C), \
  92. halt()"
  93. core-compat-rebar-erlc-opts: build clean-core-compat-rebar-erlc-opts
  94. $i "Bootstrap a new OTP library named $(APP)"
  95. $t mkdir $(APP)/
  96. $t cp ../erlang.mk $(APP)/
  97. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  98. $i "Add extra options to ERLC_OPTS"
  99. $t echo "ERLC_OPTS += +warn_export_all +warn_missing_spec +warn_untyped_record" >> $(APP)/Makefile
  100. $i "Run 'make rebar.config'"
  101. $t $(MAKE) -C $(APP) rebar.config $v
  102. $i "Check that rebar.config was created"
  103. $t test -f $(APP)/rebar.config
  104. $i "Check that -Werror is not listed in rebar.config"
  105. $t $(ERL) -eval " \
  106. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  107. {_, Opts} = lists:keyfind(erl_opts, 1, C), \
  108. false = lists:member(warning_as_errors, Opts), \
  109. halt()"
  110. $i "Check that debug_info is listed in rebar.config"
  111. $t $(ERL) -eval " \
  112. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  113. {_, Opts} = lists:keyfind(erl_opts, 1, C), \
  114. true = lists:member(debug_info, Opts), \
  115. halt()"
  116. $i "Check that extra options are listed in rebar.config"
  117. $t $(ERL) -eval " \
  118. {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
  119. {_, Opts} = lists:keyfind(erl_opts, 1, C), \
  120. true = lists:member(warn_export_all, Opts), \
  121. true = lists:member(warn_missing_spec, Opts), \
  122. true = lists:member(warn_untyped_record, Opts), \
  123. halt()"