core_makedep.mk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Core: COMPILE_FIRST dependencies generation.
  2. CORE_MAKEDEP_TARGETS = $(call list_targets,core-makedep)
  3. .PHONY: core-makedep $(CORE_MAKEDEP_TARGETS)
  4. core-makedep: $(CORE_MAKEDEP_TARGETS)
  5. core-makedep-behavior: 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. $t mkdir $(APP)/src/core
  11. $i "Generate related .erl files"
  12. $t printf "%s\n" "-module(human)." "-callback live() -> 'ok'." > $(APP)/src/core/human.erl
  13. $t printf "%s\n" "-module(boy)." "-behavior(human)." "-export([live/0])." "live() -> ok." > $(APP)/src/boy.erl
  14. $t $(MAKE) -C $(APP) $v
  15. $i "Check that all compiled files exist"
  16. $t test -f $(APP)/$(APP).d
  17. $t test -f $(APP)/ebin/$(APP).app
  18. $t test -f $(APP)/ebin/boy.beam
  19. $t test -f $(APP)/ebin/human.beam
  20. core-makedep-ignore-special-files: init
  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. $t mkdir $(APP)/src/core
  26. $i "Generate related .erl files"
  27. $t printf "%s\n" "-module(human)." "-export([live/0])." "live() -> ok." > $(APP)/src/core/human.erl
  28. $t printf "%s\n" "-module(boy)." "-import(human,[live/0])." > $(APP)/src/boy.erl
  29. $t printf "%s\n" "-module(boy)." "-import(human,[live/0])." > $(APP)/src/.#boy.erl
  30. $t $(MAKE) -C $(APP) $v
  31. $i "Check that all compiled files exist"
  32. $t test -f $(APP)/$(APP).d
  33. $t test -f $(APP)/ebin/$(APP).app
  34. $t test -f $(APP)/ebin/boy.beam
  35. $t test -f $(APP)/ebin/human.beam
  36. core-makedep-import: init
  37. $i "Bootstrap a new OTP library named $(APP)"
  38. $t mkdir $(APP)/
  39. $t cp ../erlang.mk $(APP)/
  40. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  41. $t mkdir $(APP)/src/core
  42. $i "Generate related .erl files"
  43. $t printf "%s\n" "-module(human)." "-export([live/0])." "live() -> ok." > $(APP)/src/core/human.erl
  44. $t printf "%s\n" "-module(boy)." "-import(human,[live/0])." > $(APP)/src/boy.erl
  45. $t $(MAKE) -C $(APP) $v
  46. $i "Check that all compiled files exist"
  47. $t test -f $(APP)/$(APP).d
  48. $t test -f $(APP)/ebin/$(APP).app
  49. $t test -f $(APP)/ebin/boy.beam
  50. $t test -f $(APP)/ebin/human.beam
  51. $i "Confirm the file was added by makedep"
  52. $t grep COMPILE_FIRST $(APP)/$(APP).d | grep -q core/human
  53. core-makedep-non-usascii-paths: NON_USASCII_DIR = $(APP)/héhé
  54. core-makedep-non-usascii-paths: init
  55. $i "Create working directory with non-US-ASCII characters"
  56. $t mkdir -p $(NON_USASCII_DIR)
  57. $i "Bootstrap a new OTP library named my_dep"
  58. $t mkdir $(NON_USASCII_DIR)/my_dep/
  59. $t cp ../erlang.mk $(NON_USASCII_DIR)/my_dep/
  60. $t $(MAKE) -C $(NON_USASCII_DIR)/my_dep -f erlang.mk bootstrap-lib $v
  61. $t mkdir $(NON_USASCII_DIR)/my_dep/include
  62. $i "Bootstrap a new OTP application named my_app"
  63. $t mkdir $(NON_USASCII_DIR)/my_app/
  64. $t cp ../erlang.mk $(NON_USASCII_DIR)/my_app/
  65. $t $(MAKE) -C $(NON_USASCII_DIR)/my_app -f erlang.mk bootstrap $v
  66. $i "Add my_dep to the list of dependencies"
  67. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(NON_USASCII_DIR)/my_dep/\n"}' $(NON_USASCII_DIR)/my_app/Makefile
  68. $i "Generate related .hrl/.erl files"
  69. $t printf "%s\n" "-define(HELLO, hello)." > $(NON_USASCII_DIR)/my_dep/include/hello.hrl
  70. $t printf "%s\n" "-module(hello)." "-include_lib(\"my_dep/include/hello.hrl\")." "-export([hello/0])." "hello() -> ?HELLO." > $(NON_USASCII_DIR)/my_app/src/hello.erl
  71. $t $(MAKE) -C $(NON_USASCII_DIR)/my_app $v
  72. $i "Check that all compiled files exist"
  73. $t test -f $(NON_USASCII_DIR)/my_app/my_app.d
  74. $t grep -qw $(NON_USASCII_DIR) $(NON_USASCII_DIR)/my_app/my_app.d
  75. $t test -f $(NON_USASCII_DIR)/my_app/ebin/my_app.app
  76. $t test -f $(NON_USASCII_DIR)/my_app/ebin/hello.beam