I can't get flatc installed into my yocto based SDK - yocto

I am doing bitbake image -c populate_sdk to get my SDK but I can't find a way to get the flatc binary included in the SDK.
I have tried a do_install_append in my flatbuffers.bb file and I have put dependencies on various flatbuffers things in another .bb file. I have added to TOOLCHAIN_HOST_TASK_append in my machine .conf file.
I do get the flatbuffers header files in the SDK but only the ARM flatc not the native one.
Here is the dependency I put in the .bb file for a custom binary we have:
DEPENDS += "yaml-cpp libevent protobuf python3 nativesdk-flatbuffers flatbuffers-native flatbuffers"
DEPENDS_append_class-nativesdk = " flatbuffers"
Here is my flatbuffers .bb file
SUMMARY = "Memory Efficient Serialization Library"
HOMEPAGE = "https://github.com/google/flatbuffers"
SECTION = "console/tools"
LICENSE = "Apache-2.0"
PACKAGE_BEFORE_PN = "${PN}-compiler"
RDEPENDS_${PN}-compiler = "${PN}"
RDEPENDS_${PN}-dev += "${PN}-compiler"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=a873c5645c184d51e0f9b34e1d7cf559"
SRCREV = "c0698cc33f1e534bb59c455909b88cc2726089af"
SRC_URI = "git://github.com/google/flatbuffers.git"
# Make sure C++11 is used, required for example for GCC 4.9
CXXFLAGS += "-std=c++11"
BUILD_CXXFLAGS += "-std=c++11"
# BUILD_TYPE=Release is required, otherwise flatc is not installed
EXTRA_OECMAKE += "\
-DCMAKE_BUILD_TYPE=Release \
-DFLATBUFFERS_BUILD_TESTS=OFF \
-DFLATBUFFERS_BUILD_SHAREDLIB=ON \
"
# -DFLATBUFFERS_BUILD_FLATC=ON
#do_install_append() {
# install -d ${$D}/${bindir}
# install ${B}/flatc ${D}${bindir}
#}
inherit cmake
S = "${WORKDIR}/git"
FILES_${PN}-compiler = "${bindir}"
FILES_${PN} += "/usr/lib/*"
FILES_${PN} += "/opt/ousteros/2019.7/sysroots/*"
#FILES_${PN} += "${WORKDIR}/${SDK_ARCH}/usr/bin/flatc"
BBCLASSEXTEND = "native nativesdk"
I get the ARM flatc but not the x86_64 flatc which I need to build a header file that my other binary will need. My other binary doesn't yet require that header file, I first want to generate an SDK with flatc in it.

Don't mix target and nativesdk packages in DEPENDS.
To add native tools to the SDK you need to add nativesdk-flatbuffers-compiler to TOOLCHAIN_HOST_TASK in the image recipe that the SDK is created from.

Related

meson find_program() not finding python program in yocto environment

I have an external application that converted to an exe using pyinstaller. This needs to be added in yocto framework. But the application has a dependency on pylint & pyinstaller. pylint is already part of yocto framework. I used meson.build file in my application and have a recipe file in yocto that will source the entire application from git repo and builds using instructions in meson.build. In my application meson build file uses find_program() to find pylint program installation. It works currently on my laptop, but when I build my application recipe in yocto environment, it is unable to find pylint. Even though I added "python3-pylint" in IMAGE_INSTALL_append.
| Program python3 found: YES (.../usr/bin/python3-native/python3)
| Program python3 (pylint) found: NO
|
| ../git/src/meson.build:10:0: ERROR: python3 is missing modules: pylint
pyinst = find_program('pylint') // as per meson this is probably searching in /usr/local/bin. But this is not the case in yocto. How can I modify find_program() call to find this in the right location in yocto framework. Or is there any method to handle this?
meson.build under source file folder:
# get & run pylint to check for errors
prog = import('python').find_installation('python3', modules: ['pylint'])
if not prog.found()
message('pylint not found')
else
message(prog.path())
cmd = find_program('pylint', prog.path())
message('Running pylint on src files')
foreach each : src_files
run_command(cmd, '--confidence=HIGH', each)
endforeach
endif
project's meson.build
project('proj_name',
['cpp'],
version : '0.1',
license : 'MIT',
default_options: [
'cpp_std=c++11']
)
project_pretty_name = 'proj_name'
project_url = '<git repo of project>'
python = import('python')
python3 = python.find_installation('python3', required: false)
subdir('src')
subdir('tools') # cpp tools
subdir('build')
yocto recipe file:
inherit meson pkgconfig python3native
DEPENDS += "${PYTHON_PN}-distro-native"
DEPENDS += "zlib"
RDEPENDS:${PN} += "${PYTHON_PN}-requests \
${PYTHON_PN}-pylint"
SRC_URI += "<git branch>"
SRCREV = "<src-rev>"
S = "${WORKDIR}/git"
FILES:${PN}:append = " ${bindir}/mesonexe"
Your Meson build requires pylint to be available during compilation, therefore you need to add:
DEPENDS += "${PYTHON_PN}-pylint-native"
and then you will need to ensure the pylint recipe is available in one of your configured Yocto layers. It's in meta-openembedded/meta-python.
Finally, the python3-pylint recipe and one of its dependencies (python3-astroid) do not have native support enabled, so you'll need to create the followin .bbappends as well:
# python3-pylint_%.bbappend
BBCLASSEXTEND += "native"
# python3-astroid_%.bbappend
BBCLASSEXTEND += "native"
You should then see the following line in the Meson output:
Program pylint found: YES (.../recipe-sysroot-native/usr/bin/pylint)
As a suggestion - if this recipe is building your own source code, I'd suggest linting the code as it is pushed into the repository (via a CI job), rather than at compile-time. This will reduce the dependencies required to build your project.
Of course, there would still be an optional Meson target for developers to lint their code before they push new code. Perhaps something that is enabled for non-release builds by default.

yocto recipe gives error -dev package contains non-symlink .so

I am trying to copy some of the precompiled libraries to my core-image-minimal using a recipe.
I am getting error below
-dev package contains non-symlink .so:scripts-dev path '/work/armv7ahf-neon-poky-linux-gnueabi/scripts/1.0-r0/packages-split/scripts-dev/usr/lib/libasm-0.148.so'
I am having some libraries like libasm-0.148.so, few .so which are not having any softlink to respective versioned libraries.
SOLIBS = ".so"
SOLIBS += ".so.*"
FILES_SOLIBSDEV = ""
INSANE_SKIP_${PN} += "dev-so"
I tried many changes in the recipe like below still getting same error or different error like added to package but not shipped. Above flags I tried in the recipe.
When dealing with pre-compiled packages take a look at:
https://wiki.yoctoproject.org/wiki/TipsAndTricks/Packaging_Prebuilt_Libraries
Usually the following configs fix this type of issue:
INSANE_SKIP_${PN} += " ldflags"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
SOLIBS = ".so"
FILES_SOLIBSDEV = ""

How to package CMake Module in NativeSDK?

I am trying to install a set of CMake utilty functions under /usr/share/cmake-3.4/Modules/MYMODULES/useful.cmake within a Yocto build.
Here is my current (sanitized) recipe (call it my-useful-modules.bb)
SECTION = "devel"
LICENSE = "CLOSED"
inherit cmake
EXTERNALSRC := "path/to/source/code"
do_compile() {
:
}
FILES_${PN} += "${datadir}/cmake-3.4/Modules/MYMODULES/*"
BBCLASSEXTEND = "nativesdk"
The configure and install tasks work fine, and if I look under image in tmp/work/..., I see the full tree (including all my host directories as expected).
But I keep getting the following error
ERROR: nativesdk-my-useful-modules-1.0-r0 do_package: QA Issue:
nativesdk-my-useful-modules: Files/directories were installed but not
shipped in any package:
Followed by a long list of files which basically includes everything under image.
These modules need to be available both in the native sysroot during the build, and in the standard SDK built with populate_sdk.
Which package should I be specifying with FILES_${PN} to get them packaged?
I'd also appreciate knowing how to either avoid specifying the cmake version in the FILES statement, or get it from the build system.
Updating FILES_${PN} will resolve your error and also there is no need to provide cmake version in this case.
FILES_${PN} += "${datadir}/*"

bitbake recipe for installing deb package

I want to install my own custom deb package in yocto image. For this I am using following mydebpkg.bb recipe using ROOTFS_POSTPROCESS_COMMAND
SUMMARY = "Recipe for installing deb package"
DESCRIPTION = "It installs own deb package"
HOMEPAGE = ""
LICENSE = "CLOSED"
inherit bin_package
my_install_pkg_deb() {
${STAGING_BINDIR_NATIVE}/dpkg \
--root=${IMAGE_ROOTFS}/ --admindir=${IMAGE_ROOTFS}/var/lib/dpkg/ \
-i /home/pi1/install/own_1.3-07u_armhf.deb
}
ROOTFS_POSTPROCESS_COMMAND += "my_install_pkg_deb; "
But while building image the process fails with following error cannot install package mydebpkg and Function failed: do_rootfs. Where I am making mistake and what will be the correct recipe for installing any deb package.
Installing precompiled .deb is an awful decision, you should avoid doing so anytime you are able to compile the package from source code. If this isn't the case, I'd suggest doing something like this:
SUMMARY = "Recipe for installing deb package"
DESCRIPTION = "It installs own deb package"
HOMEPAGE = ""
LICENSE = "CLOSED"
DEPENDS += " dpkg-native "
SRC_URI += " \
file://own_1.3-07u_armhf.deb.zip \
"
do_install_append() {
touch ${STAGING_DIR_NATIVE}/var/lib/dpkg/status
${STAGING_BINDIR_NATIVE}/dpkg --instdir=${D}/ \
--admindir=${STAGING_DIR_NATIVE}/var/lib/dpkg/ \
-i ${WORKDIR}/own_1.3-07u_armhf.deb
}
So: use SRC_URI variable to let bitbake copy your .deb file to the working dir. I suggest you zip the file as bitbake tries to unpack all the archives you supply him, and .deb is just another archive. So pack it to zip and let bitbake bring your .deb file to the working directory. Place your .deb.zip file by /path/to/your/recipe/files folder. Remember: never use absolute paths in yocto!
Then in do_install function invoke dpkg to install your .deb file into deploy dir of your package. This code is not complete as in case of a successful installation (don't forget about conflict resolution), you will get a list of files and directories that installed but not shipped in any package. You will need to add to your recipe FILES_${PN} variable:
FILES_${PN} += " \
/usr/bin/some_file \
/etc/some_config_file \
/and_so_on \
"
The complete list what you need to add you can get from the error message.
And remember: this method will only work if your target architecture is the same as your host architecture. Regarding that you used STAGING_BINDIR_NATIVE variable this is the case, regarding that your package contains arm, this isn't.

Bitbake does not populate so symlinks to shared libaries

In my Yocto layer I have such bitbake recipe for Qt Gstreamer libraries:
SUMMARY = "QtGStreamer libraries for Qt5"
DESCRIPTION = "QtGStreamer is a set of libraries and plugins providing C++ bindings for GStreamer with a Qt-style API plus some helper classes for integrating GStreamer better in Qt applications."
SECTION = "multimedia"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=2d5025d4aa3495befef8f17206a5b0a1"
SRC_URI[md5sum] = "fd794045a828c184acc1794b08a463fd"
SRC_URI[sha256sum] = "9f3b492b74cad9be918e4c4db96df48dab9c012f2ae5667f438b64a4d92e8fd4"
SRC_URI = "http://gstreamer.freedesktop.org/src/qt-gstreamer/${PN}-${PV}.tar.xz"
RDEPENDS_${PN} = "libgstpbutils-1.0 \
gstreamer1.0 \
qtdeclarative \
glib-2.0 \
libgstvideo-1.0 \
libgstapp-1.0 \
libgstaudio-1.0 \
qtbase \
"
inherit cmake_qt5
export EXTRA_OECMAKE = "-DQT_VERSION=5 \
-DHW_PLATFORM=imx6 \
-DOE_QMAKE_PATH_EXTERNAL_HOST_BINS=${STAGING_DIR_NATIVE}/usr/bin/qt5/ \
-DUSE_QT_PLUGIN_DIR=OFF \
-DCMAKE_SKIP_INSTALL_RPATH=YES \
-DCMAKE_SKIP_RPATH=YES \
-DCMAKE_INSTALL_PREFIX="/" \
"
FILES_${PN} += "\
${libdir}/gstreamer-1.0/* \
"
INSANE_SKIP_qt-gstreamer = "installed-vs-shipped"
EXTRA_OECONF += "--disable-rpath"
As a result of this recipe in temporary build directory I have 3 files for each shared library created- one actual library and two symlinks like so:
libQt5GStreamer-1.0.so -> libQt5GStreamer-1.0.so.0
libQt5GStreamer-1.0.so.0 -> libQt5GStreamer-1.0.so.1.2.0
libQt5GStreamer-1.0.so.1.2.0
Now I wonder why in package ${PN} I have files libQt5GStreamer-1.0.so.0 and libQt5GStreamer-1.0.so.1.2.0 but no libQt5GStreamer-1.0.so ?
On the other hand I have this file included in package ${PN}-dev.
I tried to copy this file to package ${PN} by using FILES_${PN} but then I get QA error that I cannot have so symlinks in non-dev package.
My Qt application to play video depends on these *.so files so I need to have them on my target rootfs.
How to add those file to the image?
My Qt application to play video depends on these *.so
This is probably the problem you should be solving: the .so should not be needed by the application at runtime. The way Yocto installs libraries and symlinks is quite standard: You will find this same division in Ubuntu and other distros.
You can silence the QA warning with INSANE_SKIP_${PN} += "dev-so" but that won't change the fact that the bug is probably in the application.
Alternatively you could of course make your application depend on the -dev package.