core_autopatch.mk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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-no-autopatch: build clean
  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 Cowboy to the list of dependencies and Cowlib to the NO_AUTOPATCH list"
  11. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nNO_AUTOPATCH = cowlib\n"}' $(APP)/Makefile
  12. $i "Build the application"
  13. $t $(MAKE) -C $(APP) $v
  14. $i "Check that all dependencies were fetched"
  15. $t test -d $(APP)/deps/cowboy
  16. $t test -d $(APP)/deps/cowlib
  17. $t test -d $(APP)/deps/ranch
  18. $i "Check that Cowlib was not autopatched"
  19. $t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
  20. core-autopatch-no-autopatch-erlang-mk: build clean
  21. $i "Bootstrap a new OTP library named $(APP)"
  22. $t mkdir $(APP)/
  23. $t cp ../erlang.mk $(APP)/
  24. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  25. $i "Add Cowlib to the list of dependencies and set NO_AUTOPATCH_ERLANG_MK=1"
  26. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\nNO_AUTOPATCH_ERLANG_MK = 1\n"}' $(APP)/Makefile
  27. $i "Build the application"
  28. $t $(MAKE) -C $(APP) $v
  29. $i "Check that all dependencies were fetched"
  30. $t test -d $(APP)/deps/cowlib
  31. $i "Check that Erlang.mk was not autopatched"
  32. $t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
  33. core-autopatch-no-autopatch-rebar: build clean
  34. $i "Bootstrap a new OTP library named $(APP)"
  35. $t mkdir $(APP)/
  36. $t cp ../erlang.mk $(APP)/
  37. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  38. $i "Add Lager to the list of dependencies and to the NO_AUTOPATCH list"
  39. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nNO_AUTOPATCH = lager\n"}' $(APP)/Makefile
  40. $i "Build the application"
  41. $t $(MAKE) -C $(APP) $v
  42. $i "Check that all dependencies were fetched"
  43. $t test -d $(APP)/deps/goldrush
  44. $t test -d $(APP)/deps/lager
  45. $i "Check that Lager was not autopatched"
  46. $t if grep -q erlang\.mk $(APP)/deps/goldrush/Makefile; then false; fi
  47. $t if grep -q erlang\.mk $(APP)/deps/lager/Makefile; then false; fi
  48. core-autopatch-port_env: build clean
  49. $i "Bootstrap a new OTP library named $(APP)"
  50. $t mkdir $(APP)/
  51. $t cp ../erlang.mk $(APP)/
  52. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  53. $i "Bootstrap a new NIF named my_dep inside $(APP) that uses rebar"
  54. $t mkdir $(APP)/my_dep
  55. $t cp ../erlang.mk $(APP)/my_dep/
  56. $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
  57. $t $(MAKE) -C $(APP)/my_dep/ new-nif n=my_dep $v
  58. $t rm $(APP)/my_dep/erlang.mk $(APP)/my_dep/Makefile
  59. $i "Add a rebar.config file with port_env to my_dep"
  60. $t echo "{port_env, [" >> $(APP)/my_dep/rebar.config
  61. $t echo "{\"CFLAGS\", \"\$$CFLAGS \$$(pkg-config --cflags domain-classifier 2>/dev/null)\"}," >> $(APP)/my_dep/rebar.config
  62. $t echo "{\"LDFLAGS\", \"\$$LDFLAGS \$$(pkg-config --libs domain-classifier 2>/dev/null)\"}" >> $(APP)/my_dep/rebar.config
  63. $t echo "]}." >> $(APP)/my_dep/rebar.config
  64. $i "Add my_dep to the list of dependencies"
  65. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
  66. ifdef LEGACY
  67. $i "Add my_dep to the applications key in the .app.src file"
  68. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
  69. endif
  70. $i "Build the application"
  71. $t $(MAKE) -C $(APP) $v
  72. $i "Check that all dependencies were fetched"
  73. $t test -d $(APP)/deps/my_dep
  74. $i "Confirm that the port_env configuration was expanded properly"
  75. $t grep -q "shell pkg-config" $(APP)/deps/my_dep/c_src/Makefile.erlang.mk
  76. core-autopatch-rebar: build clean
  77. $i "Bootstrap a new OTP library named $(APP)"
  78. $t mkdir $(APP)/
  79. $t cp ../erlang.mk $(APP)/
  80. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  81. $i "Add erlsha2 to the list of dependencies"
  82. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlsha2\n"}' $(APP)/Makefile
  83. $i "Build the application"
  84. $t $(MAKE) -C $(APP) $v
  85. $i "Check that erlsha2 was fetched and built"
  86. $t test -d $(APP)/deps/erlsha2
  87. $t test -f $(APP)/deps/erlsha2/ebin/erlsha2.beam
  88. ifneq ($(PLATFORM),msys2)
  89. $t test -f $(APP)/deps/erlsha2/priv/erlsha2_nif.so
  90. endif
  91. # This test is expected to fail when run in parallel and flock/lockf is not available.
  92. core-autopatch-two-rebar: build clean
  93. $i "Bootstrap a new OTP library named $(APP)"
  94. $t mkdir $(APP)/
  95. $t cp ../erlang.mk $(APP)/
  96. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  97. $i "Add two Rebar projects to the list of dependencies"
  98. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = epgsql mochiweb\n"}' $(APP)/Makefile
  99. $i "Build the application"
  100. $t $(MAKE) -C $(APP) $v