From 889f959855de39323802791d02d0164df21d0a2c Mon Sep 17 00:00:00 2001 From: Rob Martin Date: Wed, 3 Sep 2014 17:42:53 -0600 Subject: Created shell target --- README.md | 16 ++++++++++++++++ build.config | 1 + erlang.mk | 30 ++++++++++++++++++++++++++++++ plugins/shell.mk | 28 ++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 plugins/shell.mk 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 +# 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 +# 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) -- cgit v1.2.3