From cd99adbb98d8965c65f68da2853f14506756d7b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Fri, 12 May 2017 09:30:45 +0200 Subject: Support early-stage plugins through `$(DEP_EARLY_PLUGINS)` Regular plugins (`$(DEP_PLUGINS)`) are loaded near the end of Erlang.mk. This is fine when you want to modify variables initialized earlier in Erlang.mk or add new targets and variables. However, it doesn't allow you to declare more dependencies because they are loaded too late for that. This commit introduces a new variable, `$(DEP_EARLY_PLUGINS)`, which can be used to list plugins meant to be loaded near the beginning of Erlang.mk. Those allow to append to the list of dependencies. They work exactly like regular plugins otherwise. The default filename loaded is `early-plugins.mk`. --- test/core_plugins.mk | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'test/core_plugins.mk') diff --git a/test/core_plugins.mk b/test/core_plugins.mk index c58b063..060999a 100644 --- a/test/core_plugins.mk +++ b/test/core_plugins.mk @@ -1,6 +1,6 @@ # Core: External plugins. -CORE_PLUGINS_CASES = all one templates test +CORE_PLUGINS_CASES = all early one templates test CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES)) .PHONY: core-plugins $(CORE_PLUGINS_TARGETS) @@ -39,6 +39,32 @@ core-plugins-all: build clean $i "Run 'make plugin2' and check that it prints plugin2" $t test -n "`$(MAKE) -C $(APP) plugin2 | grep plugin2`" +core-plugins-early: 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 "Write external plugin adddep_plugin" + $t mkdir $(APP)/adddep_plugin + $t echo -e "DEPS += cowlib" >> $(APP)/adddep_plugin/early-plugins.mk + + $i "Inject external plugin dependencies into $(APP)" + $t echo 'DEPS = ranch' >>$(APP)/Makefile.tmp + $t echo 'BUILD_DEPS = adddep_plugin' >>$(APP)/Makefile.tmp + $t echo 'DEP_EARLY_PLUGINS = adddep_plugin' >>$(APP)/Makefile.tmp + $t echo 'dep_adddep_plugin = cp adddep_plugin' >>$(APP)/Makefile.tmp + $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp + $t mv $(APP)/Makefile.tmp $(APP)/Makefile + + $i "Build the application" + $t $(MAKE) -C $(APP) $v + + $i "Check that all dependencies were fetched" + $t test -e $(APP)/deps/cowlib + $t test -e $(APP)/deps/ranch + core-plugins-one: build clean $i "Bootstrap a new OTP library named $(APP)" -- cgit v1.2.3