5.3.17. Sharing Files Between Recipes

Recipes often need to use files provided by other recipes on the build host. For example, an application linking to a common library needs access to the library itself and its associated headers. The way this access is accomplished is by populating sysroot with files. Each recipe has two sysroots in its work directory, one for target files (recipe-sysroot) and one for files that are native to the build host (recipe-sysroot-native).

Note

You could find the term "staging" used within the Yocto project regarding files populating sysroot (e.g. the STAGING_DIR variable).

Recipes should never populate the sysroot directly (i.e. write files into sysroot). Instead, files should be installed into standard locations during the do_install task within the ${D} directory. The reason for this limitation is that almost all files that populate the sysroot are cataloged in manifests in order to ensure the files can be removed later when a recipe is either modified or removed. Thus, the sysroot is able to remain free from stale files.

A subset of the files installed by the do_install task are used by the do_populate_sysroot task as defined by the the SYSROOT_DIRS variable to automatically populate the sysroot. It is possible to modify the list of directories that populate the sysroot. The following example shows how you could add the /opt directory to the list of directories:

     SYSROOT_DIRS += "/opt"
                

for a more complete description of the do_populate_sysroot task and its associated functions, see the staging class.