core_makedep.mk 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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-import: 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 $(MAKE) -C $(APP) $v
  30. $i "Check that all compiled files exist"
  31. $t test -f $(APP)/$(APP).d
  32. $t test -f $(APP)/ebin/$(APP).app
  33. $t test -f $(APP)/ebin/boy.beam
  34. $t test -f $(APP)/ebin/human.beam
  35. $i "Confirm the file was added by makedep"
  36. $t grep COMPILE_FIRST $(APP)/$(APP).d | grep -q core/human
  37. core-makedep-non-usascii-paths: NON_USASCII_DIR = $(APP)/héhé
  38. core-makedep-non-usascii-paths: init
  39. $i "Create working directory with non-US-ASCII characters"
  40. $t mkdir -p $(NON_USASCII_DIR)
  41. $i "Bootstrap a new OTP library named my_dep"
  42. $t mkdir $(NON_USASCII_DIR)/my_dep/
  43. $t cp ../erlang.mk $(NON_USASCII_DIR)/my_dep/
  44. $t $(MAKE) -C $(NON_USASCII_DIR)/my_dep -f erlang.mk bootstrap-lib $v
  45. $t mkdir $(NON_USASCII_DIR)/my_dep/include
  46. $i "Bootstrap a new OTP application named my_app"
  47. $t mkdir $(NON_USASCII_DIR)/my_app/
  48. $t cp ../erlang.mk $(NON_USASCII_DIR)/my_app/
  49. $t $(MAKE) -C $(NON_USASCII_DIR)/my_app -f erlang.mk bootstrap $v
  50. $i "Add my_dep to the list of dependencies"
  51. $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
  52. $i "Generate related .hrl/.erl files"
  53. $t printf "%s\n" "-define(HELLO, hello)." > $(NON_USASCII_DIR)/my_dep/include/hello.hrl
  54. $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
  55. $t $(MAKE) -C $(NON_USASCII_DIR)/my_app $v
  56. $i "Check that all compiled files exist"
  57. $t test -f $(NON_USASCII_DIR)/my_app/my_app.d
  58. $t grep -qw $(NON_USASCII_DIR) $(NON_USASCII_DIR)/my_app/my_app.d
  59. $t test -f $(NON_USASCII_DIR)/my_app/ebin/my_app.app
  60. $t test -f $(NON_USASCII_DIR)/my_app/ebin/hello.beam