plugin_shell.mk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Shell plugin.
  2. SHELL_TARGETS = $(call list_targets,shell)
  3. .PHONY: shell $(C_SRC_TARGETS)
  4. shell: $(SHELL_TARGETS)
  5. shell-compile: build clean
  6. $i "Bootstrap a new OTP application named $(APP)"
  7. $t mkdir $(APP)/
  8. $t cp ../erlang.mk $(APP)/
  9. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  10. $i "Ensure our application is recompiled before the shell runs"
  11. $t perl -ni.bak -e 'print;if ($$.==1) {print "shell:: app\n"}' $(APP)/Makefile
  12. $i "Run the shell"
  13. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval 'halt()'" $v
  14. $i "Check that all compiled files exist"
  15. $t test -f $(APP)/$(APP).d
  16. $t test -f $(APP)/ebin/$(APP).app
  17. $t test -f $(APP)/ebin/$(APP)_app.beam
  18. $t test -f $(APP)/ebin/$(APP)_sup.beam
  19. shell-default: build clean
  20. $i "Bootstrap a new OTP library named $(APP)"
  21. $t mkdir $(APP)/
  22. $t cp ../erlang.mk $(APP)/
  23. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  24. $i "Run the shell"
  25. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval 'halt()'" $v
  26. shell-kjell: 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 Kjell to the list of shell dependencies and set as default shell"
  32. $t perl -ni.bak -e 'print;if ($$.==1) {print "SHELL_DEPS = kjell\nSHELL_ERL = \$$(DEPS_DIR)/kjell/bin/kjell\n"}' $(APP)/Makefile
  33. $i "Run the shell"
  34. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval 'halt()'" $v
  35. shell-test-dir: build clean
  36. $i "Bootstrap a new OTP library named $(APP)"
  37. $t mkdir $(APP)/
  38. $t cp ../erlang.mk $(APP)/
  39. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  40. $i "Generate a module in TEST_DIR"
  41. $t mkdir $(APP)/test
  42. $t printf "%s\n" \
  43. "-module(foo)." > $(APP)/test/foo.erl
  44. $i "Build the test files"
  45. $t $(MAKE) -C $(APP) test-build $v
  46. $i "Check that the module is visible"
  47. $t $(MAKE) -C $(APP) shell SHELL_OPTS="-eval 'foo:module_info()' -eval 'halt()'" $v