We do "wrap" classes in our own proprietary layer.
In a layer called meta-abc, we name the wrapper-class
classname-abc.bbclass. For instance, we wrap cmake.bbclass as follows:
# cmake-abc.bbclass
inherit cmake
# Additions to cmake behaviour go here
...
Our meta-abc recipes inherit cmake-abc. In this way, the wrapper-class
behaves very much like a bbappend.
On 20/10/21 10:09 pm, Peter Kjellerstedt wrote:
I thought of another problem with the wrapper class solution: if we
need to actually backport a newer version of the class from, e.g.,
Poky master, then there is now no natural place for it since it is
occupied by the wrapper class. That means we would either have to
rename the backported class, or put it somewhere else than in
“classes”. It also means backporting a class requires the wrapper
class to be modified.
Here is a question for Richard: what do you think of an idea I had to
add support in bitbake for extending classes? I do not mean to add
something like bbclassappend, as I know that is troublesome. My idea
instead is something like the prefuncs/postfuncs that we have for
functions. I.e., before actually doing the inherit of a class foo,
bitbake would inherit anything specified in BBCLASS_PRE_INHERIT:foo,
and after inheriting the class it would automatically inherit anything
in BBCLASS_POST_INHERIT:foo. That way one can simply extend a class
through normal variable operations, making it easy to do, e.g., in the
distro configuration.
//Peter
*From:*[email protected]
<[email protected]> *On Behalf Of *Peter
Kjellerstedt
*Sent:* den 20 oktober 2021 03:32
*To:* Jose Quaresma <[email protected]>
*Cc:* OE-core <[email protected]>
*Subject:* Re: [OE-core] [PATCH] externalsrc.bbclass: Allow
externalsrc to be extended with extra classes
Well, I had not considered that option. I can’t say I am to keen on
having wrapper classes with the same name as the upstream classes as I
think it leads to confusion. And the solution doesn’t scale very well
(what if two layers want to override the same class?). But on the
positive side it works for any class without requiring changes to
OE-Core. And I guess the latter wins. I wish there was a more bitbakey
way to add to classes though (bbclassappend anyone? 😉).
//Peter
*From:*Jose Quaresma <[email protected]>
*Sent:* den 19 oktober 2021 19:15
*To:* Peter Kjellerstedt <[email protected]>
*Cc:* OE-core <[email protected]>
*Subject:* Re: [OE-core] [PATCH] externalsrc.bbclass: Allow
externalsrc to be extended with extra classes
Hi Peter,
require the class on the new one will do the same
and we don't need any changes for that
but I may not be seeing everything
require ${COREBASE}/meta/classes/externalsrc.bbclass
Jose
Peter Kjellerstedt <[email protected]> escreveu no dia
terça, 19/10/2021 à(s) 18:03:
The EXTERNALSRC_EXTENSIONS variable holds a list of additional classes
that will be inherited when externalsrc is inherited.
Signed-off-by: Peter Kjellerstedt <[email protected]>
---
We have had a local copy of this class for a long time since we need
to make it suppport a local class when checking BBCLASSEXTEND. And
now we wanted to add some more functionality that should be active
when externalsrc is in use. So instead of forking the class even
more, I thought it would be better to make the upstream class
extendable. The solution was inspired by USERADDEXTENSION in
useradd.bbclass.
meta/classes/externalsrc.bbclass | 5 +++++
meta/conf/documentation.conf | 1 +
2 files changed, 6 insertions(+)
diff --git a/meta/classes/externalsrc.bbclass
b/meta/classes/externalsrc.bbclass
index abfe24bace..488d75760f 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -265,3 +265,8 @@ def srctree_configure_hash_files(d):
return ' '.join(out_items)
EXPORT_FUNCTIONS do_buildclean
+
+# Use the following to extend externalsrc with custom functionality
+EXTERNALSRC_EXTENSIONS ??= ""
+
+inherit ${EXTERNALSRC_EXTENSIONS}
diff --git a/meta/conf/documentation.conf
b/meta/conf/documentation.conf
index 80ad8e10d5..6d5b734b02 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -160,6 +160,7 @@ EXTENDPE[doc] = "Used with file and pathnames
to create a prefix for a recipe's
EXTENDPKGV[doc] = "The full package version specification as it
appears on the final packages produced by a recipe."
EXTERNALSRC[doc] = "If externalsrc.bbclass is inherited, this
variable points to the source tree, which is outside of the
OpenEmbedded build system."
EXTERNALSRC_BUILD[doc] = "If externalsrc.bbclass is inherited,
this variable points to the directory in which the recipe's source
code is built, which is outside of the OpenEmbedded build system."
+EXTERNALSRC_EXTENSIONS[doc] = "A list of additional classes that
will be inherited when externalsrc is inherited."
EXTRA_IMAGE_FEATURES[doc] = "The list of additional features to
include in an image. Configure this variable in the
conf/local.conf file in the Build Directory."
EXTRA_IMAGEDEPENDS[doc] = "A list of recipes to build that do not
provide packages for installing into the root filesystem. Use this
variable to list recipes that are required to build the final
image, but not needed in the root filesystem."
EXTRA_OECMAKE[doc] = "Additional cmake options."
--
Best regards,
José Quaresma
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#157269):
https://lists.openembedded.org/g/openembedded-core/message/157269
Mute This Topic: https://lists.openembedded.org/mt/86444902/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-