core_autopatch.mk 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. # Core: Autopatch.
  2. CORE_AUTOPATCH_TARGETS = $(call list_targets,core-autopatch)
  3. .PHONY: core-autopatch $(CORE_AUTOPATCH_TARGETS)
  4. core-autopatch: $(CORE_AUTOPATCH_TARGETS)
  5. core-autopatch-extended: init
  6. $i "Bootstrap a new OTP library named $(APP)"
  7. $t mkdir $(APP)/
  8. $t cp ../erlang.mk $(APP)/
  9. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  10. $i "Add Ranch to the list of dependencies"
  11. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = ranch\n"}' $(APP)/Makefile
  12. $i "Extend autopatch-ranch to create an additional module"
  13. $t echo "autopatch-ranch:: ; rm -f \$$(DEPS_DIR)/ranch/src/ranch_protocol.erl" >> $(APP)/Makefile
  14. $i "Build the application"
  15. $t $(MAKE) -C $(APP) $v
  16. $i "Check that the module was removed"
  17. $t ! test -e $(APP)/deps/ranch/src/ranch_protocol.erl
  18. $t ! test -e $(APP)/deps/ranch/ebin/ranch_protocol.beam
  19. core-autopatch-extended-erlc-opts: init
  20. $i "Bootstrap a new OTP library named $(APP)"
  21. $t mkdir $(APP)/
  22. $t cp ../erlang.mk $(APP)/
  23. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  24. $i "Add couchbeam to the list of dependencies"
  25. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = couchbeam\n"}' $(APP)/Makefile
  26. $i "Extend autopatch-couchbeam to add options to its ERLC_OPTS"
  27. $t echo "autopatch-couchbeam:: ; echo >> \$$(DEPS_DIR)/couchbeam/Makefile; echo 'ERLC_OPTS += -DWITH_JIFFY' >> \$$(DEPS_DIR)/couchbeam/Makefile" >> $(APP)/Makefile
  28. $i "Build the application"
  29. $t $(MAKE) -C $(APP) $v
  30. $i "Check that couchbeam_ejson was compiled with the added option"
  31. $t $(ERL) -pa $(APP)/deps/couchbeam/ebin -eval 'c:m(couchbeam_ejson), halt()' | grep -c "WITH_JIFFY" | grep -q 1
  32. core-autopatch-no-autopatch: init
  33. $i "Bootstrap a new OTP library named $(APP)"
  34. $t mkdir $(APP)/
  35. $t cp ../erlang.mk $(APP)/
  36. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  37. $i "Add Cowboy to the list of dependencies and Cowlib to the NO_AUTOPATCH list"
  38. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nNO_AUTOPATCH = cowlib\n"}' $(APP)/Makefile
  39. $i "Build the application"
  40. $t $(MAKE) -C $(APP) $v
  41. $i "Check that all dependencies were fetched"
  42. $t test -d $(APP)/deps/cowboy
  43. $t test -d $(APP)/deps/cowlib
  44. $t test -d $(APP)/deps/ranch
  45. $i "Check that Cowlib was not autopatched"
  46. $t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
  47. core-autopatch-no-autopatch-erlang-mk: init
  48. $i "Bootstrap a new OTP library named $(APP)"
  49. $t mkdir $(APP)/
  50. $t cp ../erlang.mk $(APP)/
  51. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  52. $i "Add Cowlib to the list of dependencies and set NO_AUTOPATCH_ERLANG_MK=1"
  53. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\nNO_AUTOPATCH_ERLANG_MK = 1\n"}' $(APP)/Makefile
  54. $i "Build the application"
  55. $t $(MAKE) -C $(APP) $v
  56. $i "Check that all dependencies were fetched"
  57. $t test -d $(APP)/deps/cowlib
  58. $i "Check that Erlang.mk was not autopatched"
  59. $t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
  60. #core-autopatch-no-autopatch-rebar: init
  61. #
  62. # $i "Bootstrap a new OTP library named $(APP)"
  63. # $t mkdir $(APP)/
  64. # $t cp ../erlang.mk $(APP)/
  65. # $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  66. #
  67. # $i "Add Lager to the list of dependencies and to the NO_AUTOPATCH list"
  68. # $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nNO_AUTOPATCH = lager\n"}' $(APP)/Makefile
  69. #
  70. # $i "Build the application"
  71. # $t $(MAKE) -C $(APP) $v
  72. #
  73. # $i "Check that all dependencies were fetched"
  74. # $t test -d $(APP)/deps/goldrush
  75. # $t test -d $(APP)/deps/lager
  76. #
  77. # $i "Check that Lager was not autopatched"
  78. # $t if grep -q erlang\.mk $(APP)/deps/goldrush/Makefile; then false; fi
  79. # $t if grep -q erlang\.mk $(APP)/deps/lager/Makefile; then false; fi
  80. core-autopatch-port_env: init
  81. $i "Bootstrap a new OTP library named $(APP)"
  82. $t mkdir $(APP)/
  83. $t cp ../erlang.mk $(APP)/
  84. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  85. $i "Bootstrap a new NIF named my_dep inside $(APP) that uses rebar"
  86. $t mkdir $(APP)/my_dep
  87. $t cp ../erlang.mk $(APP)/my_dep/
  88. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  89. $t $(MAKE) -C $(APP)/my_dep/ new-nif n=my_dep $v
  90. $t rm $(APP)/my_dep/erlang.mk $(APP)/my_dep/Makefile
  91. $i "Add a rebar.config file with port_env to my_dep"
  92. $t echo "{port_env, [" >> $(APP)/my_dep/rebar.config
  93. $t echo "{\"CFLAGS\", \"\$$CFLAGS \$$(pkg-config --cflags domain-classifier 2>/dev/null)\"}," >> $(APP)/my_dep/rebar.config
  94. $t echo "{\"LDFLAGS\", \"\$$LDFLAGS \$$(pkg-config --libs domain-classifier 2>/dev/null)\"}" >> $(APP)/my_dep/rebar.config
  95. $t echo "]}." >> $(APP)/my_dep/rebar.config
  96. $i "Add my_dep to the list of dependencies"
  97. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  98. ifdef LEGACY
  99. $i "Add my_dep to the applications key in the .app.src file"
  100. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  101. endif
  102. $i "Build the application"
  103. $t $(MAKE) -C $(APP) $v
  104. $i "Check that all dependencies were fetched"
  105. $t test -d $(APP)/deps/my_dep
  106. $i "Confirm that the port_env configuration was expanded properly"
  107. $t grep -q "shell pkg-config" $(APP)/deps/my_dep/c_src/Makefile.erlang.mk
  108. core-autopatch-rebar: init
  109. $i "Bootstrap a new OTP library named $(APP)"
  110. $t mkdir $(APP)/
  111. $t cp ../erlang.mk $(APP)/
  112. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  113. $i "Add erlsha2 to the list of dependencies"
  114. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlsha2\n"}' $(APP)/Makefile
  115. $i "Build the application"
  116. $t $(MAKE) -C $(APP) $v
  117. $i "Check that erlsha2 was fetched and built"
  118. $t test -d $(APP)/deps/erlsha2
  119. $t test -f $(APP)/deps/erlsha2/ebin/erlsha2.beam
  120. ifneq ($(PLATFORM),msys2)
  121. $t test -f $(APP)/deps/erlsha2/priv/erlsha2_nif.so
  122. endif
  123. # This test is expected to fail when run in parallel and flock/lockf is not available.
  124. core-autopatch-two-rebar: init
  125. $i "Bootstrap a new OTP library named $(APP)"
  126. $t mkdir $(APP)/
  127. $t cp ../erlang.mk $(APP)/
  128. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  129. $i "Add two Rebar projects to the list of dependencies"
  130. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = epgsql mochiweb\n"}' $(APP)/Makefile
  131. $i "Build the application"
  132. $t $(MAKE) -C $(APP) $v