4.1.9. Creating a General Layer Using the bitbake-layers Script

The bitbake-layers script with the create-layer subcommand simplifies creating a new general layer.

Note

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 with this subcommand is to create a layer with the following:

In its simplest form, you can use the following command form to create a layer. The command creates a layer whose name corresponds to your_layer_name in the current directory:

     $ bitbake-layers create-layer your_layer_name
                

If you want to set the priority of the layer to other than the default value of "6", you can either use the ‐‐priority option or you can edit the BBFILE_PRIORITY value in the conf/layer.conf after the script creates it. Furthermore, if you want to give the example recipe file some name other than the default, you can use the ‐‐example-recipe-name option.

The easiest way to see how the bitbake-layers create-layer command works is to experiment with the script. You can also read the usage information by entering the following:

     $ bitbake-layers create-layer --help
     NOTE: Starting bitbake server...
     usage: bitbake-layers create-layer [-h] [--priority PRIORITY]
                                        [--example-recipe-name EXAMPLERECIPE]
                                        layerdir

     Create a basic layer

     positional arguments:
       layerdir              Layer directory to create

     optional arguments:
       -h, --help            show this help message and exit
       --priority PRIORITY, -p PRIORITY
                             Layer directory to create
       --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE
                             Filename of the example recipe
                

Once you create your general layer, you must add it to your bblayers.conf file. You can add your layer by using the bitbake-layers add-layer command:

     $ bitbake-layers add-layer your_layer_name
                

Here is an example where a layer named meta-scottrif is added and then the layers are shown using the bitbake-layers show-layers command:

     $ bitbake-layers add-layer meta-scottrif
     NOTE: Starting bitbake server...
     Loading cache: 100% |############################################| Time: 0:00:00
     Loaded 1275 entries from dependency cache.
     Parsing recipes: 100% |##########################################| Time: 0:00:00
     Parsing of 819 .bb files complete (817 cached, 2 parsed). 1276 targets, 44 skipped, 0 masked, 0 errors.
     $ bitbake-layers show-layers
     NOTE: Starting bitbake server...
     layer                 path                                      priority
     ==========================================================================
     meta                  /home/scottrif/poky/meta                  5
     meta-poky             /home/scottrif/poky/meta-poky             5
     meta-yocto-bsp        /home/scottrif/poky/meta-yocto-bsp        5
     meta-mylayer          /home/scottrif/meta-mylayer               6
     workspace             /home/scottrif/poky/build/workspace       99
     meta-scottrif         /home/scottrif/poky/build/meta-scottrif   6
                

Adding the layer to this file enables the build system to locate the layer during the build.