Skip to content

Latest commit

 

History

History
172 lines (136 loc) · 4.1 KB

2-writing-recipes.org

File metadata and controls

172 lines (136 loc) · 4.1 KB

Yocto Project Training

1 Recipe example: Shell

1.1 Recipe: Shell script example:

DESCRIPTION = "Shell script example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://${BPN}"

S = "${WORKDIR}"

do_install() {
    install -Dm 0755 ${PN} ${D}${bindir}/${PN}
}

1.2 Directories installation variables: Reference

./images/install_dirs.png

1.3 What do I need to know?

  • Where is the sh file?
  • Where are the S and WORKDIR?
  • Why there is only do_install task?
  • Look at build history!!!
  • Inspect all variables with ye
  • Run QEMU

2 Recipe example: C - Source Code

2.1 Recipe: C example

DESCRIPTION = "Simple C code example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;md5=838c366f69b72c5df05c96dff79b35f2"

SRCREV = "e53d5cd4498c76ca8c58e18d0d14891d20f67eab"
SRC_URI = "git://github.com/fbertux/${BPN}.git;protocol=https"

S = "${WORKDIR}/git"

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

do_install() {
    install -Dm 0755 ${PN} ${D}${bindir}/${PN}
}

2.2 What do I need to know?

  • Where is the source code?
  • Where are the S and WORKDIR?
  • How to compile and install C code
  • Look at build history!!!
  • Inspect all variables with ye
  • Run QEMU

2.3 There’s more:

  • Others variables needed to build a C code:
${CFLAGS}
${LDFLAGS}

3 Recipe example: Makefile

3.1 Recipe: Makefile example

DESCRIPTION = "Makefile example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;md5=838c366f69b72c5df05c96dff79b35f2"

SRCREV = "2c0f9eacec6c886991563f092519a55e1c74dc92"
SRC_URI = "git://github.com/fbertux/${BPN}.git;protocol=https"

S = "${WORKDIR}/git"

do_configure[noexec] = "1"

do_compile() {
    oe_runmake
}

do_install() {
    oe_runmake DESTDIR=${D} install
}

3.2 What do I need to know?

  • How to compile and install Makefile based projects
  • What is oe_runmake?
  • Look at build history!!!
  • Inspect all variables with ye
  • Run QEMU

4 Recipe example: Autotools

4.1 Recipe: Autotools example

DESCRIPTION = "Autotools example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;md5=838c366f69b72c5df05c96dff79b35f2"

SRCREV = "1ee6714b88df91dd44c9aae6d9264a7e7325ce3e"
SRC_URI = "git://github.com/fbertux/${BPN}.git;protocol=https"

S = "${WORKDIR}/git"

inherit autotools

4.2 What do I need to know?

  • How the task are running?
  • Look at autotools class
  • Look at build history!!!
  • Inspect all variables with ye
  • Run QEMU

5 Recipe example: SDL

5.1 How depends works

  • Why does a package need a dependency?
  • Where the build system find the dependencies?
  • Looking at sysroot

5.2 Recipe: SDL example

DESCRIPTION = "SDL example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;md5=838c366f69b72c5df05c96dff79b35f2"

DEPENDS = "libsdl2"

SRCREV = "4610fe3841f99d8c24d9417f585cd2df0544fe72"
SRC_URI = "git://github.com/fbertux/${BPN}.git;protocol=https"

S = "${WORKDIR}/git"

inherit pkgconfig

do_compile() {
    oe_runmake
}

do_install() {
    install -Dm 0755 ${S}/main ${D}${bindir}/${PN}
    install -Dm 0644 ${S}/grumpy-cat.bmp ${D}${datadir}/${PN}/grumpy-cat.bmp
}

FILES_${PN} += "${datadir}"

5.3 What do I need to know?

  • Why do I need to use DEPENDS?
  • Where are the includes and libs file?
  • Inspect recipes-sysroot
  • Look at build history!!!
  • Inspect all variables with ye
  • Run QEMU

6 Recipe example: RDEPENDS

6.1 Why does a package need a runtime dependency?

6.2 Where the package find the dependencies?

6.3 Example: curl example