diff --git a/documentation/dev-manual/dev-manual-common-tasks.xml b/documentation/dev-manual/dev-manual-common-tasks.xml index 24faf8bd76..02d1dd22b4 100644 --- a/documentation/dev-manual/dev-manual-common-tasks.xml +++ b/documentation/dev-manual/dev-manual-common-tasks.xml @@ -17,25 +17,34 @@ Understanding and Creating Layers - The OpenEmbedded build system supports organizing metadata - into multiple layers. - Layers allow you to isolate different types of customizations from each other. - You might find it tempting to keep everything in one layer when working on a single project. - However, the more modular you organize your metadata, the easier it is to cope with future changes. + The OpenEmbedded build system supports organizing + Metadata into multiple layers. + Layers allow you to isolate different types of customizations from + each other. + You might find it tempting to keep everything in one layer when + working on a single project. + However, the more modular you organize your Metadata, the easier + it is to cope with future changes. - To illustrate how layers are used to keep things modular, consider machine customizations. - These types of customizations typically reside in a BSP Layer. - Furthermore, the machine customizations should be isolated from recipes and metadata that support - a new GUI environment, for example. - This situation gives you a couple of layers: one for the machine configurations, and one for the - GUI environment. - It is important to understand, however, that the BSP layer can still make machine-specific - additions to recipes within the GUI environment layer without polluting the GUI layer itself + To illustrate how layers are used to keep things modular, consider + machine customizations. + These types of customizations typically reside in a special layer, + rather than a general layer, called a Board Specific Package (BSP) + Layer. + Furthermore, the machine customizations should be isolated from + recipes and Metadata that support a new GUI environment, + for example. + This situation gives you a couple of layers: one for the machine + configurations, and one for the GUI environment. + It is important to understand, however, that the BSP layer can + still make machine-specific additions to recipes within the GUI + environment layer without polluting the GUI layer itself with those machine-specific changes. You can accomplish this through a recipe that is a BitBake append - (.bbappend) file, which is described later in this section. + (.bbappend) file, which is described later + in this section. @@ -45,8 +54,8 @@ Layers - The Source Directory contains several layers right out of the - box. + The Source Directory contains both general layers and BSP + layers right out of the box. You can easily identify layers that ship with a Yocto Project release in the Source Directory by their folder names. @@ -56,20 +65,25 @@ It is not a requirement that a layer begins with the string meta. - For example, when you set up the Source Directory - structure, you will see several layers: meta, - meta-hob, meta-skeleton, - meta-yocto, and meta-yocto-bsp. + For example, when you set up the + Source Directory + structure, you will see several layers: + meta, meta-hob, + meta-skeleton, + meta-yocto, and + meta-yocto-bsp. Each of these folders is a layer. - Furthermore, if you set up a local copy of the meta-intel Git repository - and then explore that folder, you will discover many BSP layers within the - meta-intel layer. + Furthermore, if you set up a local copy of the + meta-intel Git repository + and then explore the folder of that general layer, + you will discover many BSP layers inside. For more information on BSP layers, see the "BSP Layers" - section in the Yocto Project Board Support Package (BSP) Developer's Guide. + section in the Yocto Project Board Support Package (BSP) + Developer's Guide. @@ -77,32 +91,54 @@ Creating Your Own Layer - It is very easy to create your own layer to use with the OpenEmbedded build system. + It is very easy to create your own layers to use with the + OpenEmbedded build system. + The Yocto Project ships with scripts that speed up creating + general layers and BSP layers. + This section describes the steps you perform by hand to create + a layer so that you can better understand them. + For information about the layer-creation scripts, see the + "Creating a New BSP Layer Using the yocto-bsp Script" + section in the Yocto Project Board Support Package (BSP) + Developer's Guide and the + "Creating a General Layer Using the yocto-layer Script" + section further down in this manual. + + + Follow these general steps to create your layer: - Check Existing Layers: Before creating a new layer, - you should be sure someone has not already created a layer containing the metadata + Check Existing Layers: + Before creating a new layer, you should be sure someone + has not already created a layer containing the Metadata you need. You can see the - OpenEmbedded metadata index - for a list of layers from the OpenEmbedded community that can be used in the - Yocto Project. + OpenEmbedded Metadata Index + for a list of layers from the OpenEmbedded community + that can be used in the Yocto Project. + Create a Directory: Create the directory for your layer. While not strictly required, prepend the name of the - folder with the string meta. + folder with the string meta-. For example: meta-mylayer meta-GUI_xyz meta-mymachine - - Create a Layer Configuration File: Inside your new - layer folder, you need to create a conf/layer.conf file. - It is easiest to take an existing layer configuration file and copy that to your - layer's conf directory and then modify the file as needed. - The meta-yocto-bsp/conf/layer.conf file demonstrates the - required syntax: + + + Create a Layer Configuration + File: + Inside your new layer folder, you need to create a + conf/layer.conf file. + It is easiest to take an existing layer configuration + file and copy that to your layer's + conf directory and then modify the + file as needed. + The + meta-yocto-bsp/conf/layer.conf file + demonstrates the required syntax: # We have a conf and classes directory, add to BBPATH BBPATH .= ":${LAYERDIR}" @@ -161,73 +197,95 @@ Note the use of the LAYERDIR - variable, which expands to the directory of the current layer. - Through the use of the BBPATH variable, - BitBake locates .bbclass files, configuration - files, and files that are included with include - and require statements. - For these cases, BitBake uses the first file with the matching name found in - BBPATH. - This is similar to the way the PATH variable is used for binaries. - We recommend, therefore, that you use unique .bbclass - and configuration file names in your custom layer. - Add Content: Depending on the type of layer, - add the content. - If the layer adds support for a machine, add the machine configuration in - a conf/machine/ file within the layer. - If the layer adds distro policy, add the distro configuration in a - conf/distro/ file with the layer. - If the layer introduces new recipes, put the recipes you need in - recipes-* subdirectories within the layer. - In order to be compliant with the Yocto Project, a layer must contain - a README file. + variable, which expands to the directory of the current + layer. + Through the use of the BBPATH + variable, BitBake locates .bbclass + files, configuration files, and files that are included + with include and + require statements. + For these cases, BitBake uses the first file that + matches the name found in BBPATH. + This is similar to the way the PATH + variable is used for binaries. + We recommend, therefore, that you use unique + .bbclass and configuration + filenames in your custom layer. + Add Content: Depending + on the type of layer, add the content. + If the layer adds support for a machine, add the machine + configuration in a conf/machine/ + file within the layer. + If the layer adds distro policy, add the distro + configuration in a conf/distro/ + file with the layer. + If the layer introduces new recipes, put the recipes + you need in recipes-* + subdirectories within the layer. + In order to be compliant with the Yocto Project, + a layer must contain a + README file. - To create layers that are easier to maintain, you should consider the following: + To create layers that are easier to maintain, you should + consider the following: - Avoid "overlaying" entire recipes from other layers in your - configuration. - In other words, don't copy an entire recipe into your layer and then modify it. - Use .bbappend files to override the parts of the - recipe you need to modify. + Avoid "overlaying" entire recipes from + other layers in your configuration. + In other words, don't copy an entire recipe into your + layer and then modify it. + Use .bbappend files to override the + parts of the recipe you need to modify. + Avoid duplicating include files. - Use .bbappend files for each recipe that uses an include - file. - Or, if you are introducing a new recipe that requires the included file, use the - path relative to the original layer directory to refer to the file. - For example, use require recipes-core/somepackage/somefile.inc + Use .bbappend files for each recipe + that uses an include file. + Or, if you are introducing a new recipe that requires + the included file, use the path relative to the original + layer directory to refer to the file. + For example, use + require recipes-core/somepackage/somefile.inc instead of require somefile.inc. - If you're finding you have to overlay the include file, it could indicate a - deficiency in the include file in the layer to which it originally belongs. - If this is the case, you need to address that deficiency instead of overlaying - the include file. - For example, consider how Qt 4 database support plug-ins are configured. - The Source Directory does not have - MySQL or PostgreSQL, however OpenEmbedded's - layer meta-oe does. - Consequently, meta-oe uses .bbappend - files to modify the QT_SQL_DRIVER_FLAGS variable to enable - the appropriate plugins. - This variable was added to the qt4.inc include file in - the Source Directory specifically to allow the meta-oe layer - to be able to control which plugins are built. + If you're finding you have to overlay the include file, + it could indicate a deficiency in the include file in + the layer to which it originally belongs. + If this is the case, you need to address that deficiency + instead of overlaying the include file. + For example, consider how Qt 4 database support plug-ins + are configured. + The Source Directory does not have MySQL or PostgreSQL, + however OpenEmbedded's layer + meta-oe does. + Consequently, meta-oe uses + .bbappend files to modify the + QT_SQL_DRIVER_FLAGS variable to + enable the appropriate plugins. + This variable was added to the + qt4.inc include file in the Source + Directory specifically to allow the + meta-oe layer to be able to control + which plugins are built. We also recommend the following: - Store custom layers in a Git repository that uses the - meta-<layer_name> format. - Clone the repository alongside other meta - directories in the - Source Directory. + Store custom layers in a Git repository + that uses the + meta-<layer_name> format. + + Clone the repository alongside other + meta directories in the + Source Directory. + Following these recommendations keeps your Source Directory and - its configuration entirely inside the Yocto Project's core base. + its configuration entirely inside the Yocto Project's core + base. @@ -235,12 +293,15 @@ Enabling Your Layer - Before the OpenEmbedded build system can use your new layer, you need to enable it. + Before the OpenEmbedded build system can use your new layer, + you need to enable it. To enable your layer, simply add your layer's path to the BBLAYERS - variable in your conf/bblayers.conf file, which is found in the + variable in your conf/bblayers.conf file, + which is found in the Build Directory. - The following example shows how to enable a layer named meta-mylayer: + The following example shows how to enable a layer named + meta-mylayer: LCONF_VERSION = "6" @@ -262,12 +323,13 @@ - BitBake parses each conf/layer.conf file as specified in the - BBLAYERS variable within the conf/bblayers.conf - file. - During the processing of each conf/layer.conf file, BitBake adds the - recipes, classes and configurations contained within the particular layer to the source - directory. + BitBake parses each conf/layer.conf file + as specified in the BBLAYERS variable + within the conf/bblayers.conf file. + During the processing of each + conf/layer.conf file, BitBake adds the + recipes, classes and configurations contained within the + particular layer to the source directory. @@ -275,48 +337,58 @@ Using .bbappend Files - Recipes used to append metadata to other recipes are called BitBake append files. - BitBake append files use the .bbappend file type suffix, while - the corresponding recipes to which metadata is being appended use the - .bb file type suffix. + Recipes used to append Metadata to other recipes are called + BitBake append files. + BitBake append files use the .bbappend file + type suffix, while the corresponding recipes to which Metadata + is being appended use the .bb file type + suffix. - A .bbappend file allows your layer to make additions or - changes to the content of another layer's recipe without having to copy the other - recipe into your layer. - Your .bbappend file resides in your layer, while the underlying - .bb recipe file to which you are appending metadata - resides in a different layer. + A .bbappend file allows your layer to make + additions or changes to the content of another layer's recipe + without having to copy the other recipe into your layer. + Your .bbappend file resides in your layer, + while the main .bb recipe file to + which you are appending Metadata resides in a different layer. - Append files must have the same root name as the corresponding recipe. - For example, the append file someapp_&DISTRO;.bbappend must - apply to someapp_&DISTRO;.bb. - This means the original recipe and append file names are version number-specific. - If the corresponding recipe is renamed to update to a newer version, the - underlying .bbappend file must be renamed as well. - During the build process, BitBake displays an error on starting if it detects a - .bbappend file that does not have a corresponding recipe - with a matching name. + Append files must have the same root name as the corresponding + recipe. + For example, the append file + someapp_&DISTRO;.bbappend must apply to + someapp_&DISTRO;.bb. + This means the original recipe and append file names are version + number-specific. + If the corresponding recipe is renamed to update to a newer + version, the underlying .bbappend file must + be renamed as well. + During the build process, BitBake displays an error on starting + if it detects a .bbappend file that does + not have a corresponding recipe with a matching name. See the BB_DANGLINGAPPENDS_WARNONLY variable for information on how to handle this error. - Being able to append information to an existing recipe not only avoids duplication, - but also automatically applies recipe changes in a different layer to your layer. - If you were copying recipes, you would have to manually merge changes as they occur. + Being able to append information to an existing recipe not only + avoids duplication, but also automatically applies recipe + changes in a different layer to your layer. + If you were copying recipes, you would have to manually merge + changes as they occur. - As an example, consider the main formfactor recipe and a corresponding formfactor - append file both from the + As an example, consider the main formfactor recipe and a + corresponding formfactor append file both from the Source Directory. - Here is the main formfactor recipe, which is named formfactor_0.0.bb and - located in the "meta" layer at meta/recipes-bsp/formfactor: + Here is the main formfactor recipe, which is named + formfactor_0.0.bb and located in the + "meta" layer at + meta/recipes-bsp/formfactor: DESCRIPTION = "Device formfactor information" SECTION = "base" @@ -340,8 +412,10 @@ fi } - Here is the append file, which is named formfactor_0.0.bbappend and is from the - Crown Bay BSP Layer named meta-intel/meta-crownbay. + Here is the append file, which is named + formfactor_0.0.bbappend and is from the + Crown Bay BSP Layer named + meta-intel/meta-crownbay. The file is in recipes-bsp/formfactor: FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" @@ -350,20 +424,24 @@ This example adds or overrides files in SRC_URI - within a .bbappend by extending the path BitBake uses to search for files. + within a .bbappend by extending the path + BitBake uses to search for files. The most reliable way to do this is by prepending the FILESEXTRAPATHS variable. - For example, if you have your files in a directory that is named the same as your package + For example, if you have your files in a directory that is named + the same as your package (PN), - you can add this directory by adding the following to your .bbappend file: + you can add this directory by adding the following to your + .bbappend file: FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" - Using the immediate expansion assignment operator := is important because - of the reference to THISDIR. - The trailing colon character is important as it ensures that items in the list remain - colon-separated. + Using the immediate expansion assignment operator + := is important because of the reference to + THISDIR. + The trailing colon character is important as it ensures that + items in the list remain colon-separated. BitBake automatically defines the THISDIR variable. You should never set this variable yourself. @@ -383,13 +461,15 @@ Each layer is assigned a priority value. - Priority values control which layer takes precedence if there are recipe files with - the same name in multiple layers. - For these cases, the recipe file from the layer with a higher priority number takes precedence. - Priority values also affect the order in which multiple .bbappend files - for the same recipe are applied. - You can either specify the priority manually, or allow the build system to calculate it - based on the layer's dependencies. + Priority values control which layer takes precedence if there + are recipe files with the same name in multiple layers. + For these cases, the recipe file from the layer with a higher + priority number takes precedence. + Priority values also affect the order in which multiple + .bbappend files for the same recipe are + applied. + You can either specify the priority manually, or allow the + build system to calculate it based on the layer's dependencies. @@ -406,8 +486,9 @@ It is possible for a recipe with a lower version number PV in a layer that has a higher priority to take precedence. - Also, the layer priority does not currently affect the precedence order of - .conf or .bbclass files. + Also, the layer priority does not currently affect the + precedence order of .conf + or .bbclass files. Future versions of BitBake might address this. @@ -416,11 +497,12 @@ Managing Layers - You can use the BitBake layer management tool to provide a view into the structure of - recipes across a multi-layer project. - Being able to generate output that reports on configured layers with their paths and - priorities and on .bbappend files and their applicable recipes - can help to reveal potential problems. + You can use the BitBake layer management tool to provide a view + into the structure of recipes across a multi-layer project. + Being able to generate output that reports on configured layers + with their paths and priorities and on + .bbappend files and their applicable + recipes can help to reveal potential problems. @@ -431,46 +513,64 @@ The following list describes the available commands: help: - Displays general help or help on a specified command. + Displays general help or help on a specified command. + show-layers: - Show the current configured layers. + Show the current configured layers. + show-recipes: Lists available recipes and the layers that provide them. show-overlayed: Lists overlayed recipes. - A recipe is overlayed when a recipe with the same name exists in another layer - that has a higher layer priority. + A recipe is overlayed when a recipe with the same name + exists in another layer that has a higher layer + priority. show-appends: - Lists .bbappend files and the recipe files to which - they apply. + Lists .bbappend files and the + recipe files to which they apply. + show-cross-depends: - Lists dependency relationships between recipes that cross layer boundaries. + Lists dependency relationships between recipes that + cross layer boundaries. flatten: - Flattens the layer configuration into a separate output directory. - Flattening your layer configuration builds a "flattened" directory that contains - the contents of all layers, with any overlayed recipes removed and any - .bbappend files appended to the corresponding recipes. - You might have to perform some manual cleanup of the flattened layer as follows: + Flattens the layer configuration into a separate output + directory. + Flattening your layer configuration builds a "flattened" + directory that contains the contents of all layers, + with any overlayed recipes removed and any + .bbappend files appended to the + corresponding recipes. + You might have to perform some manual cleanup of the + flattened layer as follows: - Non-recipe files (such as patches) are overwritten. - The flatten command shows a warning for these files. - Anything beyond the normal layer setup has been added to - the layer.conf file. - Only the lowest priority layer's layer.conf is used. + Non-recipe files (such as patches) + are overwritten. + The flatten command shows a warning for these + files. - Overridden and appended items from .bbappend - files need to be cleaned up. - The contents of each .bbappend end up in the + Anything beyond the normal layer + setup has been added to the + layer.conf file. + Only the lowest priority layer's + layer.conf is used. + + Overridden and appended items from + .bbappend files need to be + cleaned up. + The contents of each + .bbappend end up in the flattened recipe. - However, if there are appended or changed variable values, you need to tidy - these up yourself. + However, if there are appended or changed + variable values, you need to tidy these up + yourself. Consider the following example. - Here, the bitbake-layers command adds the line - #### bbappended ... so that you know where the following - lines originate: + Here, the bitbake-layers + command adds the line + #### bbappended ... so that + you know where the following lines originate: ... DESCRIPTION = "A useful utility" @@ -483,7 +583,8 @@ DESCRIPTION = "Customized utility" EXTRA_OECONF += "--enable-somethingelse" - Ideally, you would tidy up these utilities as follows: + Ideally, you would tidy up these utilities as + follows: ... DESCRIPTION = "Customized utility" @@ -495,6 +596,134 @@ + +
+ Creating a General Layer Using the yocto-layer Script + + + The yocto-layer script simplifies + creating a new general layer. + + For information on BSP layers, see the + "BSP Layers" + section in the Yocto Project Board Specific (BSP) + Developer's Guide. + + The default mode of the script's operation is to prompt you for + information needed to generate the layer: + + The layer priority + + Whether or not to create a sample recipe. + + Whether or not to create a sample + append file. + + + + + + You use the yocto-layer create sub-command + to create a new general layer. + In its simplest form, you can create a layer as follows: + + $ yocto-layer create mylayer + + The previous example creates a layer named + meta-mylayer in the current directory. + + + + As the yocto-layer create command runs, + default values for the prompts appear in brackets. + Pressing enter without supplying anything on the command line + or pressing enter and providing an invalid response causes the + script to accept the default value. + Once the script completes, the new layer + is created in the current working directory. + The script names the layer according to the string you provide + and the prepended meta- string. + + + + If you choose to not generate a sample recipe or append file, + the script creates the following within the layer: + + The conf + directory: + This directory contains the layers + .conf. + The root name for the file is the same as the root name + your provided for the layer. + + The + COPYING.MIT: + The copyright and use notice for the software. + + The README + file: + A file describing the contents of your new layer. + + + + + + If you choose to generate a sample recipe file, the script + prompts you for the name for the recipe and then creates it + in <layer>/recipes-example/example/. + in a directory named recipes-example. + The script creates a .bb file and a + directory, which contains a sample + helloworld.csource file and along with + a sample patch file. + If you do not provide a recipe name, the script uses + "example". + + + + If you choose to generate a sample append file, the script + prompts you for the name for the file and then creates it + in <layer>/recipes-example-bbappend/example-bbappend/. + The script creates a .bbappend file and a + directory, which contains a sample patch file. + If you do not provide a recipe name, the script uses + "example". + The script also prompts you for the version of the append file. + The version should match the recipe to which the append file + is associated. + + + + The easiest way to see how the yocto-layer + script works is to experiment with the script. + You can also read the usage information by entering the + following: + + $ yocto-layer help + + + + + Once you create your general layer, you must add it to your + bblayers.conf file. + Here is an example: + + BBLAYERS = ?" \ + /usr/local/src/yocto/meta \ + /usr/local/src/yocto/meta-yocto \ + /usr/local/src/yocto/meta-yocto-bsp \ + /usr/local/src/yocto/meta-mylayer \ + " + + BBLAYERS_NON_REMOVABLE ?= " \ + /usr/local/src/yocto/meta \ + /usr/local/src/yocto/meta-yocto \ + " + + Adding the layer to this file enables the build system to + the layer during the build. + +