aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-26 17:18:44 +0100
committerLoïc Hoguin <[email protected]>2018-11-26 17:18:44 +0100
commit06b5c19d63ac6d26543301ed70d6dfb637363016 (patch)
tree46b3db2275672d42025612b70ee1e84aa3c5c39a
parentf1ff84ab745b0dfacd56be0fb41f035e764240a3 (diff)
downloaderlang.mk-06b5c19d63ac6d26543301ed70d6dfb637363016.tar.gz
erlang.mk-06b5c19d63ac6d26543301ed70d6dfb637363016.tar.bz2
erlang.mk-06b5c19d63ac6d26543301ed70d6dfb637363016.zip
Rename render_template to core_render and move into core
Also remove the last instance of an "eval export" that pollutes the environment and use the new core_render for it instead. core_render does not include $(verbose) as this needs to be different depending on who calls it. It's now set explicitly everywhere required.
-rw-r--r--core/compat.mk5
-rw-r--r--core/core.mk4
-rw-r--r--plugins/bootstrap.mk38
-rw-r--r--plugins/c_src.mk4
-rw-r--r--plugins/sfx.mk2
5 files changed, 25 insertions, 28 deletions
diff --git a/core/compat.mk b/core/compat.mk
index 37a73a7..906faac 100644
--- a/core/compat.mk
+++ b/core/compat.mk
@@ -28,8 +28,5 @@ $(call comma_list,$(foreach d,$(DEPS),\
{erl_opts, $(call compat_erlc_opts_to_list,$(ERLC_OPTS))}.
endef
-$(eval _compat_rebar_config = $$(compat_rebar_config))
-$(eval export _compat_rebar_config)
-
rebar.config:
- $(gen_verbose) echo "$${_compat_rebar_config}" > rebar.config
+ $(gen_verbose) $(call core_render,compat_rebar_config,rebar.config)
diff --git a/core/core.mk b/core/core.mk
index 0d0fd90..bc4d306 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -182,6 +182,10 @@ core_ls = $(filter-out $(1),$(shell echo $(1)))
# @todo Use a solution that does not require using perl.
core_relpath = $(shell perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV) . "\n"' $1 $2)
+define core_render
+ printf -- '$(subst $(newline),\n,$(subst %,%%,$(subst ','\'',$(subst $(tab),$(WS),$(call $(1))))))\n' > $(2)
+endef
+
# Automated update.
ERLANG_MK_REPO ?= https://github.com/ninenines/erlang.mk
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index 52ff72f..c182152 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -398,10 +398,6 @@ endef
# Plugin-specific targets.
-define render_template
- $(verbose) printf -- '$(subst $(newline),\n,$(subst %,%%,$(subst ','\'',$(subst $(tab),$(WS),$(call $(1))))))\n' > $(2)
-endef
-
ifndef WS
ifdef SP
WS = $(subst a,,a $(wordlist 1,$(SP),a a a a a a a a a a a a a a a a a a a a))
@@ -418,14 +414,14 @@ endif
$(if $(shell echo $p | grep -x "[a-z0-9_]*"),,\
$(error Error: Invalid characters in the application name))
$(eval n := $(PROJECT)_sup)
- $(call render_template,bs_Makefile,Makefile)
+ $(verbose) $(call core_render,bs_Makefile,Makefile)
$(verbose) echo "include erlang.mk" >> Makefile
$(verbose) mkdir src/
ifdef LEGACY
- $(call render_template,bs_appsrc,src/$(PROJECT).app.src)
+ $(verbose) $(call core_render,bs_appsrc,src/$(PROJECT).app.src)
endif
- $(call render_template,bs_app,src/$(PROJECT)_app.erl)
- $(call render_template,tpl_supervisor,src/$(PROJECT)_sup.erl)
+ $(verbose) $(call core_render,bs_app,src/$(PROJECT)_app.erl)
+ $(verbose) $(call core_render,tpl_supervisor,src/$(PROJECT)_sup.erl)
bootstrap-lib:
ifneq ($(wildcard src/),)
@@ -434,11 +430,11 @@ endif
$(eval p := $(PROJECT))
$(if $(shell echo $p | grep -x "[a-z0-9_]*"),,\
$(error Error: Invalid characters in the application name))
- $(call render_template,bs_Makefile,Makefile)
+ $(verbose) $(call core_render,bs_Makefile,Makefile)
$(verbose) echo "include erlang.mk" >> Makefile
$(verbose) mkdir src/
ifdef LEGACY
- $(call render_template,bs_appsrc_lib,src/$(PROJECT).app.src)
+ $(verbose) $(call core_render,bs_appsrc_lib,src/$(PROJECT).app.src)
endif
bootstrap-rel:
@@ -449,10 +445,10 @@ ifneq ($(wildcard rel/),)
$(error Error: rel/ directory already exists)
endif
$(eval p := $(PROJECT))
- $(call render_template,bs_relx_config,relx.config)
+ $(verbose) $(call core_render,bs_relx_config,relx.config)
$(verbose) mkdir rel/
- $(call render_template,bs_sys_config,rel/sys.config)
- $(call render_template,bs_vm_args,rel/vm.args)
+ $(verbose) $(call core_render,bs_sys_config,rel/sys.config)
+ $(verbose) $(call core_render,bs_vm_args,rel/vm.args)
new-app:
ifndef in
@@ -466,12 +462,12 @@ endif
$(error Error: Invalid characters in the application name))
$(eval n := $(in)_sup)
$(verbose) mkdir -p $(APPS_DIR)/$p/src/
- $(call render_template,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
+ $(verbose) $(call core_render,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
ifdef LEGACY
- $(call render_template,bs_appsrc,$(APPS_DIR)/$p/src/$p.app.src)
+ $(verbose) $(call core_render,bs_appsrc,$(APPS_DIR)/$p/src/$p.app.src)
endif
- $(call render_template,bs_app,$(APPS_DIR)/$p/src/$p_app.erl)
- $(call render_template,tpl_supervisor,$(APPS_DIR)/$p/src/$p_sup.erl)
+ $(verbose) $(call core_render,bs_app,$(APPS_DIR)/$p/src/$p_app.erl)
+ $(verbose) $(call core_render,tpl_supervisor,$(APPS_DIR)/$p/src/$p_sup.erl)
new-lib:
ifndef in
@@ -484,9 +480,9 @@ endif
$(if $(shell echo $p | grep -x "[a-z0-9_]*"),,\
$(error Error: Invalid characters in the application name))
$(verbose) mkdir -p $(APPS_DIR)/$p/src/
- $(call render_template,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
+ $(verbose) $(call core_render,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
ifdef LEGACY
- $(call render_template,bs_appsrc_lib,$(APPS_DIR)/$p/src/$p.app.src)
+ $(verbose) $(call core_render,bs_appsrc_lib,$(APPS_DIR)/$p/src/$p.app.src)
endif
new:
@@ -500,9 +496,9 @@ ifndef n
$(error Usage: $(MAKE) new t=TEMPLATE n=NAME [in=APP])
endif
ifdef in
- $(call render_template,tpl_$(t),$(APPS_DIR)/$(in)/src/$(n).erl)
+ $(verbose) $(call core_render,tpl_$(t),$(APPS_DIR)/$(in)/src/$(n).erl)
else
- $(call render_template,tpl_$(t),src/$(n).erl)
+ $(verbose) $(call core_render,tpl_$(t),src/$(n).erl)
endif
list-templates:
diff --git a/plugins/c_src.mk b/plugins/c_src.mk
index 71c0099..11aab91 100644
--- a/plugins/c_src.mk
+++ b/plugins/c_src.mk
@@ -233,6 +233,6 @@ ifdef in
$(verbose) $(MAKE) -C $(APPS_DIR)/$(in)/ new-nif n=$n in=
else
$(verbose) mkdir -p $(C_SRC_DIR) src/
- $(call render_template,bs_c_nif,$(C_SRC_DIR)/$n.c)
- $(call render_template,bs_erl_nif,src/$n.erl)
+ $(verbose) $(call core_render,bs_c_nif,$(C_SRC_DIR)/$n.c)
+ $(verbose) $(call core_render,bs_erl_nif,src/$n.erl)
endif
diff --git a/plugins/sfx.mk b/plugins/sfx.mk
index e2aecad..dad4020 100644
--- a/plugins/sfx.mk
+++ b/plugins/sfx.mk
@@ -38,7 +38,7 @@ __ARCHIVE_BELOW__
endef
sfx:
- $(call render_template,sfx_stub,$(SFX_OUTPUT_FILE))
+ $(verbose) $(call core_render,sfx_stub,$(SFX_OUTPUT_FILE))
$(gen_verbose) cat $(SFX_ARCHIVE) >> $(SFX_OUTPUT_FILE)
$(verbose) chmod +x $(SFX_OUTPUT_FILE)