Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4CB6C4332F for ; Wed, 1 Nov 2023 08:42:08 +0000 (UTC) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mx.groups.io with SMTP id smtpd.web11.2269.1698828125763858005 for ; Wed, 01 Nov 2023 01:42:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OuHHkSM6; spf=pass (domain: gmail.com, ip: 209.85.218.50, mailfrom: bhstalel@gmail.com) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-9d0b4dfd60dso709119666b.1 for ; Wed, 01 Nov 2023 01:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698828123; x=1699432923; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EXHz4iRzUpt+gN0vQQyPmtDkwK0AUDRAKl/j8rLwA/U=; b=OuHHkSM6Iu1uoL49W4eL9z3sUXM6ulR+Bk5j+zxf6HCriHtlfOmhgQoJ+fFkf3gnr0 O1mY3FVLLgiIK09NF/WboOjEzEiIW9N8J2TVAm4nB4sAmqtZ3/Dsr9evp/R0h7D/ebkb zhcX/lJ0meIEDkJaTjLZawO7u05K0WF1N5PG87M3NFpByffo3FoT/uIWbYcWxSSGjS1K IOJB9si++xzbbJ0lqS9bENfukOrWjzxaTurR18ECuBMZERWifcAp295arbq8dFMxHxdb BqoI70NkiU++a8TQwhl1mxg8mYI5DiRrSksZUbD45gNOo9a+ra9AwkvPMohqjNI1z0Op bIDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698828123; x=1699432923; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EXHz4iRzUpt+gN0vQQyPmtDkwK0AUDRAKl/j8rLwA/U=; b=vUVDLUc7xns0uzrKWIZ3ozUkJDoa6QAfPy2W5AvMj2ULzR0PrvSJlHDvD+QkIW793e QUkBHCXjiDrNoO9DYSCMNuIHlf6sUij5xRW8utvCjrWeQh2pIU27GV1HuTF6paPfcqgg ea76hEW49uszW9IxmvAa1ikHgcX5EGMDLUK6GJjPjPyMK1QdZDLK+ZH0lqpTwlFQSSI4 zRN8e36J7p80cl9NAYxllk8r/y+m05C6hufGLl1RaLEKhuN/Nju12zEqz+ddPzy3gdAl lMmMwt9ZXerQC3jVw5Q311tLvsRfIRybVZ1fQDBV4p65Hr/CHI6VlpV6rdsJVGiOanZE XLfQ== X-Gm-Message-State: AOJu0YxF3ky1odETdPHf7Ms8vINNGq9pR++12NB2AlW+u6a5Mjs/cClU jVii/HLoEcP2hFqWBq9igrEPDw7nSC21+A== X-Google-Smtp-Source: AGHT+IGXU9K8VGvsbdjk9xvKjc+6ChnWBfKsrF+Et3Wu+O+ecsUHMw7lAXDYb2X/fOtENy759jKNUA== X-Received: by 2002:a17:907:9448:b0:9ad:be8a:a588 with SMTP id dl8-20020a170907944800b009adbe8aa588mr1280478ejc.1.1698828122666; Wed, 01 Nov 2023 01:42:02 -0700 (PDT) Received: from talel.sofia.local ([41.225.25.106]) by smtp.gmail.com with ESMTPSA id p16-20020a1709060e9000b009786c8249d6sm2155558ejf.175.2023.11.01.01.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 01:42:02 -0700 (PDT) From: Talel BELHAJSALEM To: docs@lists.yoctoproject.org Cc: Talel BELHAJSALEM Subject: [PATCH v2] overview-manual: concepts: Add Bitbake Tasks Map Date: Wed, 1 Nov 2023 09:40:20 +0100 Message-Id: <20231101084020.92934-1-bhstalel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 01 Nov 2023 08:42:08 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/docs/message/4545 Create a Map to detail how BitBake handles a recipe's tasks and its compile/runtime dependencies along with detailed comments. Signed-off-by: Talel BELHAJSALEM --- documentation/overview-manual/concepts.rst | 166 ++++++++++++++++++ .../overview-manual/svg/bitbake_tasks_map.svg | 4 + 2 files changed, 170 insertions(+) create mode 100644 documentation/overview-manual/svg/bitbake_tasks_map.svg diff --git a/documentation/overview-manual/concepts.rst b/documentation/ove= rview-manual/concepts.rst index 4e3f6425a..0f12030ba 100644 --- a/documentation/overview-manual/concepts.rst +++ b/documentation/overview-manual/concepts.rst @@ -2189,3 +2189,169 @@ For more information, see the BitBake User Manual. You can also reference the "`Why Not Fakeroot? `__" article for background information on Fakeroot and Pseudo. + +BitBake Tasks Map +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +To understand how BitBake operates in the build directory and environment +we can consider the following recipes and diagram, to have full picture +about the tasks that BitBake runs to generate the final package file +for the recipe. + +We will have two recipes as an example: + +- ``libhello``: A recipe that provides a shared library +- ``sayhello``: A recipe that uses ``libhello`` library to do its job + +.. note:: + + ``sayhello`` depends on ``libhello`` at compile time as it needs the sh= ared + library to do the dynamic linking process. It also depends on it at run= time + as the shared library loader needs to find the library. + For more details about dependencies check :ref:`ref-varlocality-recipe-= dependencies`. + +``libhello`` sources are as follows: + +- ``LICENSE``: This is the license associated with this library +- ``Makefile``: The file used by ``make`` to build the library +- ``hellolib.c``: The implementation of the library +- ``hellolib.h``: The C header of the library + +``sayhello`` sources are as follows: + +- ``LICENSE``: This is the license associated with this project +- ``Makefile``: The file used by ``make`` to build the project +- ``sayhello.c``: The source file of the project + +Before presenting the contents of each file, here are the steps +that we need to follow to accomplish what we want in the first place, +which is integrating ``sayhello`` in our root file system: + +#. Create a Git repository for each project with the corresponding files +#. Create a recipe for each project +#. Make sure that ``sayhello`` recipe :term:`DEPENDS` on ``libhello`` +#. Make sure that ``sayhello`` recipe :term:`RDEPENDS` on ``libhello`` +#. Add ``sayhello`` to :term:`IMAGE_INSTALL` to integrate it into + the root file system + +The following are the contents of ``libhello/Makefile``:: + + LIB=3Dlibhello.so + + all: $(LIB) + + $(LIB): hellolib.o + $(CC) $< -Wl,-soname,$(LIB).1 -fPIC $(LDFLAGS) -shared -o $(LIB).1.0 + + %.o: %.c + $(CC) -c $< + + clean: + rm -rf *.o *.so* + +.. note:: + + When creating shared libraries, it is strongly recommended to follow th= e Linux + conventions and guidelines. (see `this article + `__ + for some background). + +.. note:: + + When creating ``Makefile`` files, it is strongly recommended to use ``C= C``, ``LDFLAGS`` + and ``CFLAGS`` as BitBake will set them as environment variables accord= ing + to your build configuration. + +The following are the contents of ``libhello/hellolib.h``:: + + #ifndef HELLOLIB_H + #define HELLOLIB_H + + void Hello(); + + #endif + +The following are the contents of ``libhello/hellolib.c``:: + + #include + + void Hello(){ + puts("Hello from a Yocto demo \n"); + } + +The following are the contents of ``sayhello/Makefile``:: + + EXEC=3Dsayhello + LDFLAGS +=3D -lhello + + all: $(EXEC) + + $(EXEC): sayhello.c + $(CC) $< $(LDFLAGS) $(CFLAGS) -o $(EXEC) + + clean: + rm -rf $(EXEC) *.o + +The following are the contents of ``sayhello/sayhello.c``:: + + #include + + int main(){ + Hello(); + return 0; + } + +The following are the contents of ``libhello_0.1.bb``:: + + SUMMARY =3D "Hello demo library" + DESCRIPTION =3D "Hello shared library used in Yocto demo" + + # NOTE: Set the License according to the LICENSE file of your project + # and then add LIC_FILES_CHKSUM accordingly + LICENSE =3D "CLOSED" + + # Assuming the branch is main + # Change accordingly + SRC_URI =3D "git://github.com//libhello;branch=3Dmain;protoco= l=3Dhttps" + + S =3D "${WORKDIR}/git" + + do_install(){ + install -d ${D}${includedir} + install -d ${D}${libdir} + + install hellolib.h ${D}${includedir} + oe_soinstall ${PN}.so.${PV} ${D}${libdir} + } + +The following are the contents of ``sayhello_0.1.bb``:: + + SUMMARY =3D "SayHello demo" + DESCRIPTION =3D "SayHello project used in Yocto demo" + + # NOTE: Set the License according to the LICENSE file of your project + # and then add LIC_FILES_CHKSUM accordingly + LICENSE =3D "CLOSED" + + # Assuming the branch is main + # Change accordingly + SRC_URI =3D "git://github.com//sayhello;branch=3Dmain;protoco= l=3Dhttps" + + DEPENDS +=3D "libhello" + RDEPENDS:${PN} +=3D "libhello" + + S =3D "${WORKDIR}/git" + + do_install(){ + install -d ${D}/usr/bin + install -m 0700 sayhello ${D}/usr/bin + } + +After placing the recipes in a custom layer we can run ``bitbake sayhello`` +to build the recipe. + +The following diagram shows the sequences of tasks that BitBake +executes to accomplish that. + +.. image:: svg/bitbake_tasks_map.svg + :width: 100% diff --git a/documentation/overview-manual/svg/bitbake_tasks_map.svg b/docu= mentation/overview-manual/svg/bitbake_tasks_map.svg new file mode 100644 index 000000000..09ef36faa --- /dev/null +++ b/documentation/overview-manual/svg/bitbake_tasks_map.svg @@ -0,0 +1,4 @@ + + + +
tmp
tmp
work
wo= rk
${MULTIMACH_TA= RGET_OS}
${MULTIMACH_TARGET_OS}
libhello
libhello
say= hello
sayhello
<= switch>
0.1-r0
0.1-r0
0.1-r0
0.1-r0
=
d= ownloads
downloads
git2
git2=
github.com.= <username>.sayhello
github.com.<username>.sayhello
= github.com.<username>.libhello
github.com.<username>.libhe= llo
git
git
Makefile
Makefile
LICENSE
LICENSE
fix.= patch
fix.patch
hellolib.c
hellolib.= c
<= div style=3D"display: inline-block; font-size: 12px; font-family: "Lib= eration Sans"; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: = all; white-space: normal; overflow-wrap: normal;">temp
temp
sysroot-des= tdir
sysroot-destdir
=
recipe-sysroo= t
recipe-sysroot
<= div style=3D"display: inline-block; font-size: 12px; font-family: "Lib= eration Sans"; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: = all; white-space: normal; overflow-wrap: normal;">image
image
<= rect x=3D"3029" y=3D"2720" width=3D"174" height=3D"160" rx=3D"24" ry=3D"24"= fill=3D"rgb(255, 255, 255)" stroke=3D"rgb(0, 0, 0)" stroke-width=3D"4" poi= nter-events=3D"all"/>=
usr
usr
<= /g>
include
include
lib
=
= lib
hellolib.h
hellolib.h
libhello.so.1
libhello.so.1
li= bhello.so.1.0
libhello.so.1.0
Everything in image fol= der that is present in SYSROOT_DIRS will be copied here.
=
Every= thing in image...
= <= switch>
do_install
= do_install
libhello.so.1.0
libhello.so.1.0
<= /g>
do_configure
do_configure
hellolib.h
he= llolib.h
<= div data-drawio-colors=3D"color: rgb(0, 0, 0); " style=3D"box-sizing: borde= r-box; font-size: 0px; text-align: center;">
do_patch
do_patch
do_unpack
do_unpack
6
=
6
<= b style=3D"font-size: 15px;">7
= 7
8
8
do_compile
do_compile
9
9
10
10
<= div style=3D"display: inline-block; font-size: 12px; font-family: "Lib= eration Sans"; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: = all; white-space: nowrap;">do_populate_sysroot
do_p= opulate_sysroot
11
11
gi= t
git
Makefile
Makefile<= /text>
LICENSE
<= text x=3D"1757" y=3D"724" fill=3D"#333333" font-family=3D"Liberation Sans" = font-size=3D"12px" text-anchor=3D"middle">LICENSE
=
sayhello.c
sayhello.c
=
sayhell= o
sayhello
image
image
usr
usr<= rect x=3D"7608.52" y=3D"3080" width=3D"215" height=3D"160" rx=3D"24" ry=3D"= 24" fill=3D"rgb(255, 255, 255)" stroke=3D"rgb(0, 0, 0)" stroke-width=3D"4" = pointer-events=3D"all"/>
bin
bin
libhello-0.1
libhello-0.1
S =3D "${WORKDIR}/git"
=
S =3D = "${WORKDIR}/git"
<= foreignObject pointer-events=3D"none" width=3D"100%" height=3D"100%" requir= edFeatures=3D"http://www.w3.org/TR/SVG11/feature#Extensibility" style=3D"ov= erflow: visible; text-align: left;">
WORKDIR
WORKDIR
D
D
<= switch>
S=
S
B=
B
S=
S
T=
T
libdir
libdir
includedir
includedir
RECIPE_SYSROOT
RE= CIPE_SYSROOT
S
S<= /switch>
B
B<= /switch>
D
D<= /switch>
WORKDIR
WOR= KDIR
do_prepare_recipe_sysroot
do_prepare_recipe_sysroot
sayhello
sayhello
usr
usr
include
include
lib
<= /div>lib
hellolib.h
hellolib.h
libhello.so.1
libhello.so.1
libh= ello.so.1.0
libhello.so.1.0
<= g transform=3D"translate(-0.5 -0.5)scale(4)">
This also contains other files from other=C2=A0
= dependencies. Default dependencies are:
basically gcc= , compilerlibs and libc
This also contains other files from other.= ..
SYSROOT_DESTDIR
<= /div>
SYSROOT_DESTDIR=
Github
=
Github<= /text>
do_= fetch
do_fetch
<= font data-font-src=3D"https://fonts.googleapis.com/css?family=3DArchitects+= Daughter" color=3D"#ffffff" size=3D"1">1<= /font>
1
do_fetch
do_fetch
5
5
do_configure
=
do_configur= e
12
12
do_compi= le
do_compile
13<= /b>
13
do_unpack
do_unpack
2
2
conf
co= nf=
local.conf
local.conf
bblayers.conf
bblayers.conf
S defaults generally to ${WORKDIR}/${BPN}-${PV}
In git recipes change it to ${WORKDIR}/git<= /font>
S defaults generally to ${WORKDIR}/${B...
<= rect x=3D"6228" y=3D"2700" width=3D"440" height=3D"160" fill=3D"#eeeeee" st= roke=3D"#36393d" stroke-width=3D"4" pointer-events=3D"all"/>
do_patch
(No= patches)
do_patch...
3
3
4
4
do_install
do_install
14
14
pa= ckage
package
PKGD
PKGD
A copy of=C2=A0${D}
excludi= ng
/sysroot-only
A copy of=C2=A0${D}...
do_package
do_package
= 15
15
<= switch>
packages-split
=
packages-split
16
deploy-<= i>pkg
PKGDEST
PKGDEST
sayhello
s= ayhello
usr
usr
bin<= /font>
bin
Folders created here are present in = PACKAGES variable, BitBake knows what and where to put things us= ing the FILES variable, example: FILES:${PN} fi= les will go to ${PN}=C2=A0folder which is in PACKAGES
Folders created here are present in PACKAGES variable..= .
do_package
do_package
16
deploy-pkg
${PAC= KAGE_ARCH}
${PACKAGE_ARCH}
<= foreignObject pointer-events=3D"none" width=3D"100%" height=3D"100%" requir= edFeatures=3D"http://www.w3.org/TR/SVG11/feature#Extensibility" style=3D"ov= erflow: visible; text-align: left;">
This can be rpms, d= ebs or ipks....
sayhello-0.1-r0.${PACKAGE_ARCH}.pkg
sayhello-0.1-r0.= ${PACKAGE_ARCH}.pkg
This task also depends on PACKAGE_CLASSES,
pkg=C2=A0can be rpm, deb<= /u> or ipk for package_rpm,
pack= age_deb or package_ipk=C2=A0res= pectively.
The generated package generally named using:
${P= N}, ${PR}, ${PACKAGE_ARCH} and=C2=A0= pkg
This task also depends on PACKAGE_= CLASSES,...
deploy
deploy
=
${DEPLOY_DIR_pkg}
${DEPLOY_DIR_pkg= }
do_package_write_pkg
do_package_write_pkg <= /text>
17
17=
${PACKAGE_ARCH}
${PACKAGE_ARCH}=
For packages, this can be I= PK, RPM or DEB (check step 17)
For packages, this can be IPK, RPM or DEB (check step 17)
=
DEPLOY_DIR
<= /foreignObject>DEPLOY_DIR
TMPDIR
TMPDIR
DL_DIR
DL_DIR
<= div data-drawio-colors=3D"color: rgb(0, 0, 0); " style=3D"box-sizing: borde= r-box; font-size: 0px; text-align: center;">
do_package_write_pkg
do_package_write_pkg=
18
18
=
This can be PKGWRITEDIR= RPM, PKGWRITEDIRDEB or PKGWRITEDIRIPK f= or package_rpm, package_deb
or packa= ge_ipk respectively
<= text x=3D"2615" y=3D"244" fill=3D"rgb(0, 0, 0)" font-family=3D"Liberation S= ans" font-size=3D"12px" text-anchor=3D"middle">This can be PKGWRITEDIRRPM, = PKGWRITEDIRDEB or PKGWRITEDIRIPK for pack...
License checking happens in do_populate_lic after do_patch
and before th= at a checksum check
happends on=C2=A0LIC_FILES_CHKSUM if= the
license is not CLOSED
License che= cking happens in do_populate_lic after do_pa...
This variable is us= ed to separate recipes
based on their target. This has value of
<= b>${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}
This variable is used to separate recipes...
=
conf-notes.txt
conf-notes.txt
sstate-cache
sstate-cache
SSTATE_DIR
SSTATE_DIR
sayhello
sayhello
=
This = folder contains cache for recipes build output, this is used by BitBake, if= the recipe checksum did not change it knows that the output to use is the = same.
This folder contains cache for recipes build output= , this is used by...
These directories can be shared accross builds to = save disk space and build time
These directories ca= n be shared accross builds to save disk space an...
<= switch>
This = directory contains other output directories such as images, <= b>sdk and licenses
<= /foreignObject>This directo= ry contains other output directories such as images, sdk...=
This file cont= ains all layers that BitBake should consider when looking for metada= ta.
This file contains all layer...
<= rect x=3D"5396" y=3D"20" width=3D"1760" height=3D"160" fill=3D"none" stroke= =3D"rgb(0, 0, 0)" stroke-width=3D"4" stroke-dasharray=3D"12 12" pointer-eve= nts=3D"all"/>
=
This is base configur= ation file containing essential user config such as MACHINE a= nd DISTRO
This is base configuration file c= ontaining essential user config such as...
The message to show after = source oe-init-build-env
= The message to show after s= ource oe-init...
Text is not SVG - cannot display= \ No newline at end of file --=20 2.25.1
This can be <= b>rpms, debs or ipks.
These are= provided by
package_rpm, package_deb and = package_ipk classes respectively, use PACKAGE_CLASSES for that as
content of PACKAGE_CLASSES will be ap= pended
to INHERIT