All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 08/19] packages: add infrastructure for virtual packages
Date: Sun,  2 Mar 2014 17:52:49 +0100	[thread overview]
Message-ID: <fae93e88e0b58edfd4431d2b4e3abc5afc995ebd.1393778339.git.yann.morin.1998@free.fr> (raw)
In-Reply-To: <cover.1393778339.git.yann.morin.1998@free.fr>

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

The virtual-package infrastructure allows to easily define a
virtual package in a single line:

    $ package/some-virtual-package/some-virtual-package.mk:
    $(eval $(virtual-package))

And that's all. :-)

Thanks to ?ric for his work on the manual, that prompted the
idea for this virtual-package infrastructure! ;-)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Mike Zick <minimod@morethan.org>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
---
 package/Makefile.in    |  1 +
 package/pkg-virtual.mk | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 package/pkg-virtual.mk

diff --git a/package/Makefile.in b/package/Makefile.in
index 454f614..c5cdf5a 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -362,4 +362,5 @@ include package/pkg-cmake.mk
 include package/pkg-luarocks.mk
 include package/pkg-perl.mk
 include package/pkg-python.mk
+include package/pkg-virtual.mk
 include package/pkg-generic.mk
diff --git a/package/pkg-virtual.mk b/package/pkg-virtual.mk
new file mode 100644
index 0000000..9b206ea
--- /dev/null
+++ b/package/pkg-virtual.mk
@@ -0,0 +1,66 @@
+################################################################################
+# Virtual package infrastructure
+#
+# This file implements an infrastructure that eases development of
+# package .mk files for virtual packages. It should be used for all
+# virtual packages.
+#
+# See the Buildroot documentation for details on the usage of this
+# infrastructure
+#
+# In terms of implementation, this virtual infrastructure requires
+# the .mk file to only call the 'virtual-package' macro.
+#
+################################################################################
+
+
+################################################################################
+# inner-virtual-package -- defines the dependency rules of the virtual
+# package against its provider.
+#
+#  argument 1 is the lowercase package name
+#  argument 2 is the uppercase package name, including an HOST_ prefix
+#             for host packages
+#  argument 3 is the uppercase package name, without the HOST_ prefix
+#             for host packages
+#  argument 4 is the type (target or host)
+################################################################################
+
+# Note: putting this comment here rather than in the define block, otherwise
+# make would try to expand the $(error ...) in the comment, which is not
+# really what we want.
+# We need to use second-expansion for the $(error ...) call, below,
+# so it is not evaluated now, but as part of the generated make code.
+
+define inner-virtual-package
+
+# Ensure the virtual package has an implementation defined.
+ifeq ($(BR2_PACKAGE_HAS_$(2)),y)
+ifeq ($(call qstrip,$(BR2_PACKAGE_PROVIDES_$(2))),)
+$$(error No implementation selected for virtual package $(1). Configuration error)
+endif
+endif
+
+# A virtual package does not have any source associated
+$(2)_SOURCE =
+
+# This must be repeated from inner-generic-package, otherwise we get an empty
+# _DEPENDENCIES
+$(2)_DEPENDENCIES ?= $(filter-out host-toolchain $(1),\
+	$(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
+
+# Add dependency against the provider
+$(2)_DEPENDENCIES += $(call qstrip,$(BR2_PACKAGE_PROVIDES_$(2)))
+
+# Call the generic package infrastructure to generate the necessary
+# make targets
+$(call inner-generic-package,$(1),$(2),$(3),$(4))
+
+endef
+
+################################################################################
+# virtual-package -- the target generator macro for virtual packages
+################################################################################
+
+virtual-package = $(call inner-virtual-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
+host-virtual-package = $(call inner-virtual-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
-- 
1.8.3.2

  parent reply	other threads:[~2014-03-02 16:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-02 16:52 [Buildroot] [PATCH 0/19 v3] Add new virtual-package infrastructure Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 01/19] package/libgles: rename package and the _HAS and _PROVIDES variables Yann E. MORIN
2014-03-02 17:26   ` Samuel Martin
2014-03-02 16:52 ` [Buildroot] [PATCH 02/19] package/libegl: " Yann E. MORIN
2014-03-02 17:27   ` Samuel Martin
2014-03-02 16:52 ` [Buildroot] [PATCH 03/19] package/libopenmax: rename " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 04/19] package/libopenvg: " Yann E. MORIN
2014-03-02 22:39   ` Jerzy Grzegorek
2014-03-02 16:52 ` [Buildroot] [PATCH 05/19] package/luainterpreter: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 06/19] package/lua: rename config options Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 07/19] manual: add virtual package tutorial Yann E. MORIN
2014-03-02 16:52 ` Yann E. MORIN [this message]
2014-03-02 16:52 ` [Buildroot] [PATCH 09/19] manual: update the virtual package section with the new infrastructure Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 10/19] package/powervr: convert to the virtual-package infrastructure Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 11/19] package/opengl-libgles: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 12/19] package/opengl-libegl: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 13/19] package/libopenmax: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 14/19] package/libopenvg: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 15/19] package/luainterpreter: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 16/19] package/jpeg: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 17/19] package/cryptodev: " Yann E. MORIN
2014-03-02 16:52 ` [Buildroot] [PATCH 18/19] virtual-package: fake a version string for virtual packages Yann E. MORIN
2014-03-02 17:29   ` Samuel Martin
2014-03-02 16:53 ` [Buildroot] [PATCH 19/19] FOO: tentative target and host virt packages Yann E. MORIN
2014-03-03 17:19 ` [Buildroot] [PATCH 0/19 v3] Add new virtual-package infrastructure Yann E. MORIN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fae93e88e0b58edfd4431d2b4e3abc5afc995ebd.1393778339.git.yann.morin.1998@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.