plugin_escript.mk 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Escript plugin.
  2. ESCRIPT_CASES = build deps extra
  3. ESCRIPT_TARGETS = $(addprefix escript-,$(ESCRIPT_CASES))
  4. .PHONY: escript $(ESCRIPT_TARGETS)
  5. escript: $(ESCRIPT_TARGETS)
  6. escript-build: build clean
  7. $i "Bootstrap a new OTP library named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  11. $i "Generate a module containing a function main/1"
  12. $t printf "%s\n" \
  13. "-module($(APP))." \
  14. "-export([main/1])." \
  15. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  16. $i "Build the escript"
  17. $t $(MAKE) -C $(APP) escript $v
  18. $i "Check that the escript exists"
  19. $t test -f $(APP)/$(APP)
  20. $i "Check that the escript runs"
  21. $t $(APP)/$(APP) | grep -q good
  22. $i "Distclean the application"
  23. $t $(MAKE) -C $(APP) distclean $v
  24. $i "Check that the escript was removed"
  25. $t test ! -e $(APP)/$(APP)
  26. escript-deps: build clean
  27. $i "Bootstrap a new OTP library named $(APP)"
  28. $t mkdir $(APP)/
  29. $t cp ../erlang.mk $(APP)/
  30. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  31. $i "Add Ranch to the list of dependencies"
  32. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = ranch\n"}' $(APP)/Makefile
  33. $i "Generate a module containing a function main/1"
  34. $t printf "%s\n" \
  35. "-module($(APP))." \
  36. "-export([main/1])." \
  37. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  38. $i "Build the escript"
  39. $t $(MAKE) -C $(APP) escript $v
  40. $i "Check that the escript runs"
  41. $t $(APP)/$(APP) | grep -q good
  42. $i "Check that the escript contains the dependency"
  43. $t zipinfo $(APP)/$(APP) 2> /dev/null | grep -q ranch
  44. escript-extra: build clean
  45. $i "Bootstrap a new OTP library named $(APP)"
  46. $t mkdir $(APP)/
  47. $t cp ../erlang.mk $(APP)/
  48. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  49. $i "Instruct Erlang.mk to add extra files to the escript"
  50. $t printf "%s\n" \
  51. "escript-zip::" \
  52. ' $$(verbose) $$(ESCRIPT_ZIP) $$(ESCRIPT_ZIP_FILE) Makefile erlang.mk' >> $(APP)/Makefile
  53. $i "Generate a module containing a function main/1"
  54. $t printf "%s\n" \
  55. "-module($(APP))." \
  56. "-export([main/1])." \
  57. 'main(_) -> io:format("good~n").' > $(APP)/src/$(APP).erl
  58. $i "Build the escript"
  59. $t $(MAKE) -C $(APP) escript $v
  60. $i "Check that the escript runs"
  61. $t $(APP)/$(APP) | grep -q good
  62. $i "Check that the escript contains the extra files"
  63. $t zipinfo $(APP)/$(APP) 2> /dev/null | grep -q Makefile
  64. $t zipinfo $(APP)/$(APP) 2> /dev/null | grep -q erlang.mk