Bitbake Example Recipes

Single File C Recipe

meta-newlayer/recipes-example/example/example_0.1.bb:

SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "CLOSED"
SECTION = "examples"
SRC_URI = "file://example.c"
S = "${WORKDIR}"
INSANE_SKIP:${PN} += "ldflags"

do_compile() {
  ${CC} example.c -o example
}

do_install() {
  install -D -m 0755 example ${D}${bindir}/helloworld
}

python do_display_banner() {
    bb.plain("***********************************************");
    bb.plain("*                                             *");
    bb.plain("*  Example recipe created by bitbake-layers   *");
    bb.plain("*                                             *");
    bb.plain("***********************************************");
}

addtask display_banner before do_build

meta-newlayer/recipes-example/example/files/example.c:

#include "stdio.h"


int main(int argc, char**argv) {

        printf("Hello, World!");
        return 0;
}

Setting-up New Recipe using devtool

DevTool is a tool shipped by Yocto used to help with many operations. One of such operations is creating a Recipe from git repository.

To register a repository we first need to add repository by following command:

devtool add https://github.com/OSSystems/bbexample

Once the repository is reigstered, we need to add it to recipe by using the following command:

devtool finish bbexample meta-newlayer/

Enabling Extra Package feature via build/config/local.conf

# replace `pn` with package name and ' feature2' with the name of feature we wish to enable
PACKAGECONFIG:pn-<recipename>:append = ' feature2'.

Configuring Kernel (menuconfig)

bitbake $(bitbake -e |grep -F 'PREFERRED_PROVIDER_virtual/kernel'|sed -n '2,$p' |awk -F '"' '{print $2}') -c menuconfig

But changes made here do not persist. For that a .bbappend needs to be created or existing recipe updated.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *