Rob Martin 10 лет назад
Родитель
Сommit
889f959855
4 измененных файлов с 75 добавлено и 0 удалено
  1. 16 0
      README.md
  2. 1 0
      build.config
  3. 30 0
      erlang.mk
  4. 28 0
      plugins/shell.mk

+ 16 - 0
README.md

@@ -328,6 +328,22 @@ If `RELX_OPTS` includes the `-o` option (instead of using
 the list, otherwise erlang.mk will fail to find it and
 will not be able to clean up the release directory.
 
+Shell plugin
+------------
+
+This plugin is available by default.
+
+`SHELL_DEPS` adds the specified modules only when `make shell`
+or `make build-shell-deps` is run. For example, to include a module
+reloader and TDD test runner, one might add `SHELL_DEPS = tddreloader`
+to the Makefile.
+
+You can add extra `erl` options by defining the `SHELL_OPTS` variable.
+For more information please see `erl -man erl`.
+
+`SHELL_PATH` adds paths to the shell's library search path. By default
+this option sets the path to `-pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin`.
+
 Contributing
 ------------
 

+ 1 - 0
build.config

@@ -16,3 +16,4 @@ plugins/dialyzer
 plugins/erlydtl
 plugins/edoc
 plugins/relx
+plugins/shell

+ 30 - 0
erlang.mk

@@ -742,3 +742,33 @@ distclean-relx-rel:
 
 distclean-relx:
 	$(gen_verbose) rm -rf $(RELX)
+
+# Copyright (c) 2014, M Robert Martin <rob@version2beta.com>
+# This file is contributed to erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: shell
+
+# Configuration.
+
+SHELL_PATH ?= -pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin
+SHELL_OPTS ?=
+
+ALL_SHELL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(SHELL_DEPS))
+
+# Core targets
+
+help::
+	@printf "%s\n" "" \
+		"Shell targets:" \
+		"  shell              Run an erlang shell with SHELL_OPTS or reasonable default"
+
+# Plugin-specific targets.
+
+$(foreach dep,$(SHELL_DEPS),$(eval $(call dep_target,$(dep))))
+
+build-shell-deps: $(ALL_SHELL_DEPS_DIRS)
+	@for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done
+
+shell: build-shell-deps
+	$(gen_verbose) erl $(SHELL_PATH) $(SHELL_OPTS)
+

+ 28 - 0
plugins/shell.mk

@@ -0,0 +1,28 @@
+# Copyright (c) 2014, M Robert Martin <rob@version2beta.com>
+# This file is contributed to erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: shell
+
+# Configuration.
+
+SHELL_PATH ?= -pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin
+SHELL_OPTS ?=
+
+ALL_SHELL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(SHELL_DEPS))
+
+# Core targets
+
+help::
+	@printf "%s\n" "" \
+		"Shell targets:" \
+		"  shell              Run an erlang shell with SHELL_OPTS or reasonable default"
+
+# Plugin-specific targets.
+
+$(foreach dep,$(SHELL_DEPS),$(eval $(call dep_target,$(dep))))
+
+build-shell-deps: $(ALL_SHELL_DEPS_DIRS)
+	@for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done
+
+shell: build-shell-deps
+	$(gen_verbose) erl $(SHELL_PATH) $(SHELL_OPTS)