plugin_escript.mk 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # Escript plugin.
  2. ESCRIPT_TARGETS = $(call list_targets,escript)
  3. .PHONY: escript $(ESCRIPT_TARGETS)
  4. escript: $(ESCRIPT_TARGETS)
  5. escript-build: 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 "Generate a module containing a function main/1"
  11. $t printf "%s\n" \
  12. "-module($(APP))." \
  13. "-export([main/1])." \
  14. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  15. $i "Build the escript"
  16. $t $(MAKE) -C $(APP) escript $v
  17. $i "Check that the escript exists"
  18. $t test -f $(APP)/$(APP)
  19. $i "Check that the escript runs"
  20. $t $(APP)/$(APP) | grep -q good
  21. $i "Distclean the application"
  22. $t $(MAKE) -C $(APP) distclean $v
  23. $i "Check that the escript was removed"
  24. $t test ! -e $(APP)/$(APP)
  25. escript-deps: build clean
  26. $i "Bootstrap a new OTP library named $(APP)"
  27. $t mkdir $(APP)/
  28. $t cp ../erlang.mk $(APP)/
  29. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  30. $i "Add Ranch to the list of dependencies"
  31. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = ranch\n"}' $(APP)/Makefile
  32. $i "Generate a module containing a function main/1"
  33. $t printf "%s\n" \
  34. "-module($(APP))." \
  35. "-export([main/1])." \
  36. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  37. $i "Build the escript"
  38. $t $(MAKE) -C $(APP) escript $v
  39. $i "Check that the escript runs"
  40. $t $(APP)/$(APP) | grep -q good
  41. $i "Check that the escript contains the dependency"
  42. $t zipinfo $(APP)/$(APP) 2> /dev/null | grep -q ranch
  43. escript-distclean: build clean
  44. $i "Bootstrap a new OTP library named $(APP)"
  45. $t mkdir $(APP)/
  46. $t cp ../erlang.mk $(APP)/
  47. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  48. $i "Use a non-standard name for the escript"
  49. $t perl -ni.bak -e 'print;if ($$.==1) {print "ESCRIPT_FILE = real-escript\n"}' $(APP)/Makefile
  50. $i "Generate a module containing a function main/1"
  51. $t printf "%s\n" \
  52. "-module($(APP))." \
  53. "-export([main/1])." \
  54. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  55. $i "Build the escript"
  56. $t $(MAKE) -C $(APP) escript $v
  57. $i "Check that the escript runs"
  58. $t test ! -f $(APP)/$(APP)
  59. $t $(APP)/real-escript | grep -q good
  60. $i "Check that make distclean removes the generated escript"
  61. $t $(MAKE) -C $(APP) distclean $v
  62. $t test ! -f $(APP)/$(APP)
  63. $t test ! -f $(APP)/real-escript
  64. escript-extra: build clean
  65. $i "Bootstrap a new OTP library named $(APP)"
  66. $t mkdir $(APP)/
  67. $t cp ../erlang.mk $(APP)/
  68. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  69. $i "Instruct Erlang.mk to add extra files to the escript"
  70. $t printf "%s\n" \
  71. "escript-zip::" \
  72. ' $$(verbose) $$(ESCRIPT_ZIP) $$(ESCRIPT_ZIP_FILE) Makefile erlang.mk' >> $(APP)/Makefile
  73. $i "Generate a module containing a function main/1"
  74. $t printf "%s\n" \
  75. "-module($(APP))." \
  76. "-export([main/1])." \
  77. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  78. $i "Build the escript"
  79. $t $(MAKE) -C $(APP) escript $v
  80. $i "Check that the escript runs"
  81. $t $(APP)/$(APP) | grep -q good
  82. $i "Check that the escript contains the extra files"
  83. $t zipinfo $(APP)/$(APP) 2> /dev/null | grep -q Makefile
  84. $t zipinfo $(APP)/$(APP) 2> /dev/null | grep -q erlang.mk