From 724521b68c19f107437db9fa2ee8def6ff604e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Fri, 12 May 2017 10:19:24 +0200 Subject: Support plugins local to the application If the application's Makefile specify either: DEP_PLUGINS = $(PROJECT) or e.g.: DEP_PLUGINS = $(PROJECT)/mk/dist.mk then load the plugin from the application instead of a dependency. This helps when you have an application with common Erlang modules and Erlang.mk plugins: your common application can load Erlang.mk plugins exactly like other applications depending on the common application. --- test/core_plugins.mk | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/core_plugins.mk b/test/core_plugins.mk index 060999a..508012b 100644 --- a/test/core_plugins.mk +++ b/test/core_plugins.mk @@ -1,6 +1,6 @@ # Core: External plugins. -CORE_PLUGINS_CASES = all early one templates test +CORE_PLUGINS_CASES = all early early-local local one templates test CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES)) .PHONY: core-plugins $(CORE_PLUGINS_TARGETS) @@ -65,6 +65,48 @@ core-plugins-early: build clean $t test -e $(APP)/deps/cowlib $t test -e $(APP)/deps/ranch +core-plugins-early-local: build clean + + $i "Bootstrap a new OTP library named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v + + $i "Create two internal plugin makefiles" + $t mkdir -p $(APP)/mk + $t echo "plugin1: ; @echo \$$@" > $(APP)/mk/plugin1.mk + $t echo "plugin2: ; @echo \$$@" > $(APP)/early-plugins.mk + + $i "Add dependency and plugins to the Makefile" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DEP_EARLY_PLUGINS = \$$(PROJECT) \$$(PROJECT)/mk/plugin1.mk\n"}' $(APP)/Makefile + + $i "Run 'make plugin1' and check that it prints plugin1" + $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1 + + $i "Run 'make plugin2' and check that it prints plugin2" + $t $(MAKE) --no-print-directory -C $(APP) plugin2 | grep -qw plugin2 + +core-plugins-local: build clean + + $i "Bootstrap a new OTP library named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v + + $i "Create two internal plugin makefiles" + $t mkdir -p $(APP)/mk + $t echo "plugin1: ; @echo \$$@" > $(APP)/mk/plugin1.mk + $t echo "plugin2: ; @echo \$$@" > $(APP)/plugins.mk + + $i "Add dependency and plugins to the Makefile" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DEP_PLUGINS = \$$(PROJECT) \$$(PROJECT)/mk/plugin1.mk\n"}' $(APP)/Makefile + + $i "Run 'make plugin1' and check that it prints plugin1" + $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1 + + $i "Run 'make plugin2' and check that it prints plugin2" + $t $(MAKE) --no-print-directory -C $(APP) plugin2 | grep -qw plugin2 + core-plugins-one: build clean $i "Bootstrap a new OTP library named $(APP)" -- cgit v1.2.3