Sharing Functionality
- BitBake allows for metadata sharing through include files and
- class files (.bbclass).
+ BitBake allows for metadata sharing through include files
+ (.inc) and class files
+ (.bbclass).
For example, suppose you have a piece of common functionality
such as a task definition that you want to share between
more than one recipe.
In this case, creating a .bbclass
- file that contains the common functionality and uses the
- inherit directive would be a common
- way to share the task.
+ file that contains the common functionality and then using
+ the inherit directive in your recipes to
+ inherit the class would be a common way to share the task.
@@ -504,19 +505,24 @@
allow you to share functionality between recipes.
Specifically, the mechanisms include include,
inherit, INHERIT, and
- require statements.
+ require directives.
Locating Include and Class Files
- BitBake uses the BBPATH variable
- to locate needed class and configuration files.
+ BitBake uses the
+ BBPATH
+ variable to locate needed include and class files.
The BBPATH variable is analogous to
the environment variable PATH.
- Use of BBPATH is specific to the build
- environment (e.g. Yocto Project, OpenEmbedded, and so forth).
+
+
+
+ In order for include and class files to be found by BitBake,
+ they need to be located in a "classes" subdirectory that can
+ be found in BBPATH.
@@ -527,27 +533,36 @@
When writing a recipe or class file, you can use the
inherit directive to inherit the
functionality of a class (.bbclass).
- BitBake only supports this directive when used within these
- two types of files (i.e. .bb and
- .bbclass files).
+ BitBake only supports this directive when used within recipe
+ and class files (i.e. .bb and
+ .bbclass).
The inherit directive is a rudimentary
means of specifying what classes of functionality your
- recipe requires.
+ recipes require.
For example, you can easily abstract out the tasks involved in
building a package that uses Autoconf and Automake and put
those tasks into a class file that can be used by your package.
- As an example, an autotools.bbclass file
- could use the following directive to inherit needed
- site information:
+
+
+
+ As an example, your recipes could use the following directive
+ to inherit an autotools.bbclass file.
+ The class file would contain common functionality for using
+ Autotools that could be shared across recipes:
- inherit siteinfo
+ inherit autotools
In this case, BitBake would search for the directory
- classes/siteinfo.bbclass
+ classes/autotools.bbclass
in BBPATH.
+
+ You can override any values and functions of the
+ inherited class within your recipe by doing so
+ after the "inherit" statement.
+
@@ -566,9 +581,9 @@
As an example, suppose you needed a recipe to include some
- self-test files:
+ self-test definitions:
- include test_recipe.inc
+ include test_defs.inc
The include directive does not
@@ -598,17 +613,28 @@
- Similar to how BitBake uses include,
+ Similar to how BitBake uses
+ include,
if the path specified
on the require line is a relative path, BitBake locates
the first file it can find within BBPATH.
- As an example, suppose you needed a recipe to require some
- self-test files:
+ As an example, suppose you have two versions of a recipe
+ (e.g. foo_1.2.2.bb and
+ foo_2.0.0.bb) where
+ each version contains some identical functionality that could be
+ shared.
+ You could create an include file named foo.inc
+ that contains the common definitions needed to build "foo".
+ You need to be sure foo.inc is located in the
+ same directory as your two recipe files as well.
+ Once these conditions are set up, you can share the functionality
+ using a require directive from within each
+ recipe:
- require test_recipe.inc
+ require foo.inc
@@ -625,12 +651,25 @@
- Suppose you needed to inherit a multilib global class.
+ As an example, suppose you needed to inherit a class
+ file called abc.bbclass from a
+ configuration file as follows:
- INHERIT += "multilib_global"
+ INHERIT += "abc"
- This configuration directive causes the named class to be inherited
- at the point of the directive during parsing.
+ This configuration directive causes the named
+ class to be inherited at the point of the directive
+ during parsing.
+ As with the inherit directive, the
+ .bbclass file must be located in a
+ "classes" subdirectory in one of the directories specified
+ in BBPATH.
+
+ Because .conf files are parsed
+ first during BitBake's execution, using
+ INHERIT to inherit a class effectively
+ inherits the class globally (i.e. for all recipes).
+