Build custom Yocto recipe with meson and ninja

3.2k views Asked by At

I'm trying to write a custom recipe for a library from github (Aravis). The build/install steps are done using meson and ninja.

$ meson build
$ cd build
$ ninja
$ ninja install

Before writing/adding the recipe, I've added meson, ninja and dependencies in my custom layer.conf. Then, on system, I've cloned the library, compiled it and run some test. Everything works fine, so I'm sure meson, ninja and all dependencies are in place (at system level).

Now I've wrote the recipe

SUMMARY = "Aravis, Your industrial vision library"

LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/LGPL-2.1-only;md5=1a6d268fd218675ffea8be556788b780"

inherit systemd

SRC_URI = "https://github.com/AravisProject/aravis/archive/refs/tags/0.8.22.tar.gz"
SRC_URI[md5sum] = "8d24f794b1c5160f21c2b0d77764c86d"

DEPENDS=" \
  gstreamer1.0 \
  gstreamer1.0-plugins-base \
  libxml2 \
  glib-2.0 \
  glib-2.0-native \
  zlib \
  libusb1 \
  gtk-doc \
  gobject-introspection \
  intltool-native \
  meson \
"

S = "${WORKDIR}/aravis-0.8.22"

do_configure() {
    ( cd ${S}
    meson build )
}

do_build() {
    ( cd ${S}/build
    ninja )
}

do_install () {
    ( cd ${S}/build
    ninja install )
}

The do_configure() step fails with a meson: not found error. I don't know about ninja yet (didn't reach the do_build()), but it will probably fail, too.

How to have meson and ninja tools available at compile level?

As a blind test, I tried rebuilding the toolchain (bitbake meta-toolchain-qt5), hoping those tools will be added for the next image build, but with no luck.

EDIT

I've also noticed that meson and ninja are already available in my sdk (the one installed on host for cross-compilation after build with mentioned command bitbake meta-toolchain-qt5).

mix@SWDEV1:/opt/fsl-imx-xwayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux$ find . -name ninja
./usr/bin/ninja
mix@SWDEV1:/opt/fsl-imx-xwayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux$ find . -name meson
./usr/share/meson
./usr/bin/meson

The tools are available. I just need to understand how to use them.

2

There are 2 answers

0
il_mix On

Found the problem.

Another test I did was adding inherit meson and removing the custom tasks, but without luck.

Testing it a little more, I discovered the the problem was the recipe name, that was aravis_%.bb. Since I didn't define a recipe version, the resulting build path was tmp/work/cortexa53-crypto-poky-linux/aravis/%_r0/, and it looks like meson doesn't like the character %.

So I've edited my recipe so that the version is defined

SUMMARY = "Aravis, Your industrial vision library"

LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/LGPL-2.1-only;md5=1a6d268fd218675ffea8be556788b780"

PV = "0.8.22"

SRC_URI = "https://github.com/AravisProject/aravis/archive/refs/tags/${PV}.tar.gz"
SRC_URI[md5sum] = "8d24f794b1c5160f21c2b0d77764c86d"

DEPENDS=" \
  gstreamer1.0 \
  gstreamer1.0-plugins-base \
  libxml2 \
  glib-2.0 \
  glib-2.0-native \
  zlib \
  libusb1 \
  gtk-doc \
  gobject-introspection \
  intltool-native \
"

S = "${WORKDIR}/aravis-${PV}"

inherit meson

Now the library will be compiled and installed.

0
Sheffield Dong On

Thanks for your initial answer il_mix, that helped me make an updated version of the recipe that works with Yocto 4.0 (Kirkstone).

I've labelled the file aravis_git.bb and placed in my own layer under recipes-multimedia.

This version uses updated licensing and SRCREV commit instead of .tar.gz archives.

EXTRA_OEMESON is used as a way to turn on/off options provided by Aravis. I have turned off documentation, fast-heartbeat, introspection, tests, viewer.

FILES is needed if you are going to enable the gst-plugin option which provides libgstaravis.0.8.so.

SUMMARY = "Video acquisition for Genicam compliant cameras"
DESCRIPTION = "Aravis is a glib/gobject based library for video acquisition using Genicam compliant cameras. It currently implements the gigabit ethernet and USB3 protocols used by industrial cameras."

LICENSE = "LGPL-2.1-only"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/LGPL-2.1-only;md5=1a6d268fd218675ffea8be556788b780"

# Modify these as desired
# Current Aravis version = 0.8.26
PV = "1.0+git${SRCPV}"
SRC_URI = "git://github.com/AravisProject/aravis.git;branch=main;protocol=https"
SRCREV = "e977fa4eedc8c4f4747ff370d53621b369930fe9"

S = "${WORKDIR}/git"

DEPENDS = " \
    zlib \
    libxml2 \
    glib-2.0 \
    glib-2.0-native \
    libusb1 \
    gstreamer1.0 \
    gstreamer1.0-plugins-base \
"

# These options are found in AravisProject/aravis meson_options.txt
EXTRA_OEMESON += "-Ddocumentation=disabled \
          -Dfast-heartbeat=false \
          -Dgst-plugin=enabled \
          -Dintrospection=disabled \
          -Dpacket-socket=enabled \
          -Dtests=false \
          -Dusb=enabled \
          -Dviewer=disabled"

#gst-plugin = Do we want to make a gstreamer plugin version of Aravis for GStreamer use?

FILES:${PN} += " \
   ${libdir}/gstreamer-1.0/libgstaravis.0.8.so \
"

inherit meson pkgconfig