aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/bootstrap.mk
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/bootstrap.mk')
-rw-r--r--plugins/bootstrap.mk27
1 files changed, 18 insertions, 9 deletions
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index dbd115f..d608d28 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -11,8 +11,8 @@ help::
" bootstrap Generate a skeleton of an OTP application" \
" bootstrap-lib Generate a skeleton of an OTP library" \
" bootstrap-rel Generate the files needed to build a release" \
- " new-app n=NAME Create a new local OTP application NAME" \
- " new-lib n=NAME Create a new local OTP library NAME" \
+ " new-app in=NAME Create a new local OTP application NAME" \
+ " new-lib in=NAME Create a new local OTP library NAME" \
" new t=TPL n=NAME Generate a module NAME based on the template TPL" \
" new t=T n=N in=APP Generate a module NAME based on the template TPL in APP" \
" list-templates List available templates"
@@ -49,6 +49,8 @@ define bs_appsrc_lib
]}.
endef
+# To prevent autocompletion issues with ZSH, we add "include erlang.mk"
+# separately during the actual bootstrap.
ifdef SP
define bs_Makefile
PROJECT = $p
@@ -58,17 +60,21 @@ PROJECT_VERSION = 0.0.1
# Whitespace to be used when creating files from templates.
SP = $(SP)
-include erlang.mk
endef
else
define bs_Makefile
PROJECT = $p
-include erlang.mk
+PROJECT_DESCRIPTION = New project
+PROJECT_VERSION = 0.0.1
+
endef
endif
define bs_apps_Makefile
PROJECT = $p
+PROJECT_DESCRIPTION = New project
+PROJECT_VERSION = 0.0.1
+
include $(call core_relpath,$(dir $(ERLANG_MK_FILENAME)),$(APPS_DIR)/app)/erlang.mk
endef
@@ -166,6 +172,11 @@ code_change(_OldVsn, State, _Extra) ->
{ok, State}.
endef
+define tpl_module
+-module($(n)).
+-export([]).
+endef
+
define tpl_cowboy_http
-module($(n)).
-behaviour(cowboy_http_handler).
@@ -344,7 +355,7 @@ endef
# Plugin-specific targets.
define render_template
- $(verbose) echo "$${_$(1)}" > $(2)
+ $(verbose) printf -- '$(subst $(newline),\n,$(subst %,%%,$(subst ','\'',$(subst $(tab),$(WS),$(call $(1))))))\n' > $(2)
endef
ifndef WS
@@ -355,10 +366,6 @@ WS = $(tab)
endif
endif
-$(foreach template,$(filter bs_% tpl_%,$(.VARIABLES)), \
- $(eval _$(template) = $$(subst $$(tab),$$(WS),$$($(template)))) \
- $(eval export _$(template)))
-
bootstrap:
ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
@@ -366,6 +373,7 @@ endif
$(eval p := $(PROJECT))
$(eval n := $(PROJECT)_sup)
$(call render_template,bs_Makefile,Makefile)
+ $(verbose) echo "include erlang.mk" >> Makefile
$(verbose) mkdir src/
ifdef LEGACY
$(call render_template,bs_appsrc,src/$(PROJECT).app.src)
@@ -379,6 +387,7 @@ ifneq ($(wildcard src/),)
endif
$(eval p := $(PROJECT))
$(call render_template,bs_Makefile,Makefile)
+ $(verbose) echo "include erlang.mk" >> Makefile
$(verbose) mkdir src/
ifdef LEGACY
$(call render_template,bs_appsrc_lib,src/$(PROJECT).app.src)