aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Martin <[email protected]>2014-09-03 17:42:53 -0600
committerRob Martin <[email protected]>2014-09-08 09:27:12 -0600
commit889f959855de39323802791d02d0164df21d0a2c (patch)
treec229b703c4b664c3271e136674df239a0e3f812a
parent3b096b6e500298df128a9295075a98ee46de2d77 (diff)
downloaderlang.mk-889f959855de39323802791d02d0164df21d0a2c.tar.gz
erlang.mk-889f959855de39323802791d02d0164df21d0a2c.tar.bz2
erlang.mk-889f959855de39323802791d02d0164df21d0a2c.zip
Created shell target
-rw-r--r--README.md16
-rw-r--r--build.config1
-rw-r--r--erlang.mk30
-rw-r--r--plugins/shell.mk28
4 files changed, 75 insertions, 0 deletions
diff --git a/README.md b/README.md
index 793b790..a574239 100644
--- a/README.md
+++ b/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
------------
diff --git a/build.config b/build.config
index 7440d0d..7bc09ff 100644
--- a/build.config
+++ b/build.config
@@ -16,3 +16,4 @@ plugins/dialyzer
plugins/erlydtl
plugins/edoc
plugins/relx
+plugins/shell
diff --git a/erlang.mk b/erlang.mk
index fcd8eaf..16f3a96 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -742,3 +742,33 @@ distclean-relx-rel:
distclean-relx:
$(gen_verbose) rm -rf $(RELX)
+
+# Copyright (c) 2014, M Robert Martin <[email protected]>
+# 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)
+
diff --git a/plugins/shell.mk b/plugins/shell.mk
new file mode 100644
index 0000000..9cbee2e
--- /dev/null
+++ b/plugins/shell.mk
@@ -0,0 +1,28 @@
+# Copyright (c) 2014, M Robert Martin <[email protected]>
+# 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)