aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Yann E. MORIN <yann.morin.1998@free.fr>2014-05-15 19:37:03 +0200
committerGravatar Peter Korsgaard <peter@korsgaard.com>2014-05-21 00:19:45 +0200
commit91169d3346e543be18139e18bdcc52a2345e0d16 (patch)
tree04f91f01176f24164bb40c3d92c04dc20f61dfd5
parent6a6962fd82ca92f2e7ad7be07cf6a986d5224a61 (diff)
downloadbuildroot-91169d3346e543be18139e18bdcc52a2345e0d16.tar.gz
buildroot-91169d3346e543be18139e18bdcc52a2345e0d16.tar.bz2
infra/pkg-virtual: validate only one provider provides an implementation
Currently, it is possible that more than one provider of a virtual package is selected in the menuconfig. This leads to autobuild failures, and we do not protect the user from making a mistake in the configuration. The failure is then hard to troubleshoot in any case. We can't use kconfig constructs to prevent this, since kconfig does not tell how many options did a select on another option. This change introduces a new variable a provider *must* define to include all the virtual packages it is an implementation of. Then, when evaluating the package's rules, we check that the provider is indeed the declared one for each virtual package it claims to be an implementation of. This works by taking advantage that when more than one provider is selected, only one of them will 'win' in setting the _PROVIDES_FOO option. Thus any provider just has to check it is indeed the declared provider. If not, it means that one or more other provider is selected. This gives the opportunity to the user to change its configuration, and we can match the error message in the autobuilders to skip those failures (we can skip them instead of reporting them, since they are obviously configuration errors that should not happen in the first place.) [Note: kudos to Arnout for suggesting this actual implementation. :-)] Fixes: http://autobuild.buildroot.org/results/285/2851069d6964aa46d26b4aabe7d84e8c0c6c72ce http://autobuild.buildroot.net/results/9b7/9b7870354d70e27e42d3d9c1f131ab54706bf20e [...] Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Peter Korsgaard <jacmet@uclibc.org> Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com> Cc: Arnout Vandecappelle <arnout@mind.be> Cc: Samuel Martin <s.martin49@gmail.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
-rw-r--r--package/pkg-generic.mk26
1 files changed, 26 insertions, 0 deletions
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 426d269971..260f37425e 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -241,6 +241,25 @@ $(BUILD_DIR)/%/.stamp_dircleaned:
rm -Rf $(@D)
################################################################################
+# virt-provides-single -- check that provider-pkg is the declared provider for
+# the virtual package virt-pkg
+#
+# argument 1 is the lower-case name of the virtual package
+# argument 2 is the upper-case name of the virtual package
+# argument 3 is the lower-case name of the provider
+#
+# example:
+# $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
+################################################################################
+define virt-provides-single
+ifneq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),$(3))
+$$(error Configuration error: both "$(3)" and $$(BR2_PACKAGE_PROVIDES_$(2))\
+are selected as providers for virtual package "$(1)". Only one provider can\
+be selected at a time. Please fix your configuration)
+endif
+endef
+
+################################################################################
# inner-generic-package -- generates the make targets needed to build a
# generic package
#
@@ -626,6 +645,13 @@ endif # ifneq ($(call qstrip,$$($(2)_SOURCE)),)
# configuration
ifeq ($$($$($(2)_KCONFIG_VAR)),y)
+# Ensure the calling package is the declared provider for all the virtual
+# packages it claims to be an implementation of.
+ifneq ($$($(2)_PROVIDES),)
+$$(foreach pkg,$$($(2)_PROVIDES),\
+ $$(eval $$(call virt-provides-single,$$(pkg),$$(call UPPERCASE,$$(pkg)),$(1))$$(sep)))
+endif
+
TARGETS += $(1)
PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)