Specifying task overrides

All recipes inherit the base.bbclass class, which in turn inherits the patch.bbclass and staging.bbclass, and together define the following tasks:

  • do_build: This is the default task that by default just executes all the rest.
  • do_fetch: This method fetches the source code, selecting the fetcher using the SRC_URI variable. Archive formats are downloaded into DL_DIR while Git formats are cloned into DL_DIR/git2 and tarballed into DL_DIR.
  • do_unpack: This method creates the WORKDIR at TMPDIR/work/<arch>/<PN>/<PV>, and unpacks the code in the working directory to a location specified by the S variable, which is WORKDIR/<PN>-<PV> by default.
  • do_patch: This method applies any specified patch using quilt over the unpacked source.
  • do_configure: This method configures the source code if needed, for example if using the autotools or cmake classes, with configuration files and makefiles written to B, usually WORKDIR/build. It does nothing by default.
  • do_populate_lic: This method populates the TMPDIR/deploy/licenses/<PN> directory with the licensing information.
  • do_compile: This method compiles the source in S and runs the GNU make target by default to create binaries in B. Individual per-recipe sysroot directories are populated at this point.
  • do_install: This method uses pseudo to copy the results of the build from the build directory B to the destination directory D, usually WORKDIR/image. It does nothing by default.
  • do_package: This method splits the deliverables into several packages into WORKDIR/packages-split. It does nothing by default.
  • do_populate_sysroot: This method populates WORKDIR/sysroot-destdir with header files, shared objects, and packageconfig files.
  • do_package_write_rpm: This method creates the RPM packages, assuming the default RPM package class is used, in TMPDIR/deploy/rpm.
  • do_rootfs: For image recipes that inherit image.bbclass, this method installs the RPM packages to create the final rootfs image in TMPDIR/work/<machine>/<image-name>/<PV>/rootfs, as well as copying the final images into TMPDIR/deploy/images/<machine>.

Tasks can be overridden, appended, or prepended. We can also add a new task with addtask, remove a task with deltask, or simply skip it as follows:

do_task[noexec] = "1" 

Usually, only the configuration, compilation, and installation tasks are overridden, and this is mostly done implicitly by inheriting the autotools class. We will discuss different classes used for application development in Chapter 4, Application Development.

For a custom recipe that does not use a build system, you need to provide the required instructions for configuration (if any), compilation, and installation in their corresponding do_configure, do_compile, and do_install overrides. An example of this type of recipe, meta-custom/recipes-example/helloworld/helloworld_1.0.bb, is shown here:

DESCRIPTION = "Simple helloworld application" 
SECTION = "examples" 
LICENSE = "MIT" 
LIC_FILES_CHKSUM = 
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4 f302" SRC_URI = "file://helloworld.c" S = "${WORKDIR}" do_compile() { ${CC} ${LDFLAGS} helloworld.c -o helloworld } do_install() { install -d ${D}${bindir} install -m 0755 helloworld ${D}${bindir} }

The meta-custom/recipes-example/helloworld/helloworld-1.0/helloworld.c source file is the following:

#include <stdio.h> 
 
int main(void) 
{ 
    return printf("Hello World"); 
} 

We will explore example recipes that use the most common build systems in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset