Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between SRC_URI and FILESEXTRAPATHS_prepend in bitbake

Tags:

yocto

bitbake

Why do we need to give path of files in SRC_URI even though we are including the files path in FILESEXTRAPATHS_prepend variable? For example:

SUMMARY = "Simple Hello application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI = "file://Hello_1.c \
           file://Hello_2.c \
              "

do_compile() {
         oe_runmake
}

do_install() {
         install -d ${D}${bindir}
         install -m 0755 Hello ${D}${bindir}
}

In the "files" folder I have two files: hello1.c and hello2.c. When I remove SRC_URI it outputs the following error,

ERROR: Hello-1.0-r0 do_compile: oe_runmake failed

But if I remove FILESEXTRAPATHS_prepend it is working fine.

What is the purpose of the variable FILESEXTRAPATHS_prepend?

Why error occurs when I remove SRC_URI even though I'm including my files path in FILESEXTRAPATHS_prepend?

like image 645
vivek Avatar asked Sep 21 '17 11:09

vivek


2 Answers

Simple way let assume meta-layer/recipes-core/example

  1. In above path created hello and hello.bb
  2. Here hello is a directory having your source and other data and hello.bb is recipe.

Now

SRC_URI : The SRC_URI variable always checks the data in hello dir only. FILESEXTRAPATHS_prepend := "${THISDIR}:" : if you add this line in your recipe, then the SRC_URI variable checks the data in present directory where the hello.bb file present.

In your case

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

The SRC_URI variable checks the data in files dir where the hello.bb is present.

Note: Most of the time people will use this FILESEXTRAPATHS variable in .bbappend files to apply patches and other files to the recipe.

For every .bb file, the SRC_URI variable is used to specify which files to fetch the source from - either from an online repository or a local one, and the FILESEXTRAPATHS specifies where these files are looked for, and depends on your source path.

like image 74
yoctotutor.com Avatar answered Oct 16 '22 15:10

yoctotutor.com


BitBake uses the SRC_URI variable to point to source files regardless of their location. Each recipe must have a SRC_URI variable that points to the source.

SRC_URI = file:// Fetches files, which are usually files shipped with the Metadata, from the local machine. The path is relative to the FILESPATH variable. Thus, the build system searches, in order, from the following directories, which are assumed to be a subdirectories of the directory in which the recipe file (.bb) or append file (.bbappend) resides:

FILESPATH: The default set of directories the OpenEmbedded build system uses when searching for patches and files. During the build process, BitBake searches each directory in FILESPATH in the specified order when looking for files and patches specified by each file:// URI in a recipe.

The default value for the FILESPATH variable is defined in the base.bbclass class found in meta/classes in the Source Directory:

 FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", \
    "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}"

Do not hand-edit the FILESPATH variable; The default directories BitBake uses when it processes recipes are initially defined by the FILESPATH variable. You can extend FILESPATH variable by using FILESEXTRAPATHS.

> Best practices dictate that you accomplish this by using FILESEXTRAPATHS from within a .bbappend file

FILESEXTRAPATHS: Extends the search path the OpenEmbedded build system uses when looking for files and patches as it processes recipes and append files. The default directories BitBake uses when it processes recipes are initially defined by the FILESPATH variable.

If you want the build system to pick up files specified through a SRC_URI statement from your append file, you need to be sure to extend the FILESPATH variable by also using the FILESEXTRAPATHS variable from within your append file.

http://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-FILESPATH

Back to your error, since each recipe MUST have a SRC_URI; it will not work if you delete it;

Since your recipe is not an .bbappend, adding FILESEXTRAPATHS is not appropriate and not necessary.

like image 34
Charles C. Avatar answered Oct 16 '22 16:10

Charles C.