Yocto access sysroot files from another recipee - yocto

Say that I have two recipe's
baselib and mylib
baselib installs /etc/baseversion.txt
1.2.3.4
mylib Should generate /etc/myversion.txt
1.2.3.4-myrev1
Where 1.2.3.4 is taken from baselib.
How do I access the version from baselib?

Related

python setup.py install won't keep data_files

I am currently so confused about installation of my own Python packages... Between setup.pys, sdists and wheels, no matter what I do, I can't seem to achieve what I want - which is to have a bunch of non-.py data files installed and kept in the virtual environment with the same structure I have in my project folder after the installation.
I've read all kinds of documentations, and created a setup.py file that has a data_files field that contains all the data files I need in my installation.
I have the following structure:
.
|__ requirements.txt
setup.py
hr_datapool
|__ __init__.py
|__ data_needed
|__ needed_folder
|__ needed_file.notpy
|__ one_module
|__ __init__.py
|__ misc_tools.py
|__tests
|__ test_tools.py
|__ other_module
...
And data_needed contains non-.py data files that are needed for misc_tools.py (and thus tests.py) to run.
Because of this, I added a data_files into my setup.py that contains all the folders and files I need. This I confirmed, everything is there what should be.
And yet, if I do any variation of pip install ., python setup.py install or the likes, the data_files are completely ignored, and/or placed in the wrong directory and don't appear anywhere in the created build or dist folders. And because of this, obviously all my tests fail, since they can't load files that are not there. Neither are they stored in the installation folder on the venv when I sometimes do succeed in copying them, but rather in the root of the venv.
The funny thing is, the files are handled while installing, I keep getting console output when installing with python setup.py install like:
copying data_needed/needed_folder/needed_file.notpy-> /Users/.../venv/hr_datapool/data_needed/needed_folder/
but only if I use python setup.py install, (not when using pip install .).
According to the documentation:
The directory should be a relative path. It is interpreted relative to the installation prefix (Python’s sys.prefix for system
installations; site.USER_BASE for user installations). Distutils
allows directory to be an absolute installation path, but this is
discouraged since it is incompatible with the wheel packaging format.
No directory information from files is used to determine the final
location of the installed file; only the name of the file is used.
Notice the highlights. However, in my example, it doesn't install relative to the directory containing the package, but it installs into its own folder in the root of the virtual environment, making it practically unreachable from within my code. I made sure I se relative paths in my setup.py, but still this happens.
How can I make sure the required data_files install within the target directory of the module, and not separately into the root of the virtual environment?

Yocto custom application through custom layer does not copy source files to destination rootfs

I am trying to install a custom application on my Yocto build.
I currently use a Raspberry Pi 4 64 bit setup, for which I want PyQt5 to display an application directly on the frame buffer (so no windowing manager or desktop envoirement).
My current build with Yocto completes and boots on the Raspberry Pi. All the Qt5 libraries are also present in the root fs after the bitbake build.
Although, I'm having problems getting a custom layer, that adds a custom recipe with a custom application to also copy over to the destination root fs.
My custom layer is called 'meta-rpikms' with recipe 'recipes-kms-qt-app' which contains the application bb files. This files is called 'basicquick_0.1.bb' and has the following contents (this test application tries to add a EGLFS friendly Qt5 applicaiton, i'll try PyQt5 later):
SUMMARY = "Simple Qt5 Quick application"
#SECTION = "examples"
LICENSE = "MIT"
#PACKAGE_ARCH = "all"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
DEPENDS += "qtbase qtdeclarative qtquickcontrols2"
SRCREV = "${AUTOREV}"
SRC_URI = "git://github.com/shigmas/BasicQuick.git"
S = "${WORKDIR}/git"
require recipes-qt/qt5/qt5.inc
do_install() {
install -d ${D}${bindir_native}
install -m 0755 BasicQuick ${D}${bindir_native}
}
FILES_${PN} += "${bindir_native}"
When I bitbake the custom layer of my meta-rpikms (called 'qt5-kms-rpi-image'), it does compute. When I take a look at the 'image_initial_manifest' file, my custom application does show up, suggesting that it does compile and try to install the application:
# This file was generated automatically and contains the packages
# passed on to the package manager in order to create the rootfs.
# Format:
# <package_type>,<package_name>
# where:
# <package_type> can be:
# 'mip' = must install package
# 'aop' = attempt only package
# 'mlp' = multilib package
# 'lgp' = language package
mip,basicquick
mip,bluez5
mip,bridge-utils
mip,hostapd
mip, bla bla bla etc etc etc.
And if I take a look in: '~/builds/pyqt5_try1/poky/rpi64-build/tmp/work/cortexa72-poky-linux/basicquick/0.1-r0', the expected files do show up. Also suggesting that it does atleast build the application. This makes the think that the 'install' arguments in my .bb file are pointing to the wrong folder.
In my basicquick_*.bb file this is to make the directory and install (copy) the built files:
install -d ${D}${bindir_native}
install -m 0755 BasicQuick ${D}${bindir_native}
I used the 'bitbake -e' command to trace the variable D and bindir_native:
D="/home/mats/builds/pyqt5_try1/poky/rpi64-build/tmp/work/raspberrypi4_64-poky-linux/qt5-kms-rpi-image/1.0-r0/image"
bindir_native="/usr/bin"
This seems okay at first glance, but when I manually follow the destination of the variable 'D', there is no 'images' folder created. I also wonder why everybody installs their custom applications on ${D}/usr/bin? Should this not be written to the build/tmp/deploy directory? Or am I missing a step here.
So, in this 'qt5-kms-rpi-image/1.0-r0' folder, there is a folder called 'deploy-qt5-kms-rpi-image-image-complete', which contains a rootfs. But there also is a rootfs folder in the 'qt5-kms-rpi-image/1.0-r0' folder. Both of these rootfs's do not contain any mention of my basicquick application, or a BasicQuick folder being created in /usr/bin.
Also, the rootfs found in the "build/tmp/deploy/images/raspberrypi4-64/qt5-kms-rpi-image-raspberrypi4-64.tar.bz2" does not contain any mention of the basicquick application being present in the filesystem.
Does anybody have any clues on what I am missing? Am I just not copying my files to the correct location? Or does the final deploy image end up somewhere else from where I am expecting it?
Thanks in advance.
With kind regards,
Mats de Waard

How to include the kernel configuration to my meta-layer and into the build?

I am using cl-som-imx7 board, using gatesgarth branch to setup the yocto env.
I have changed the kernel configurations by
Executing the command
bitbake -c memuconfig virtual/kernel
Rename the .config to defconfig
I don't have any luck in including those changes inside my build. Any suggestion would be appreciated.
The following section of the Yocto Manual illustrates how to do that:
https://www.yoctoproject.org/docs/2.5/kernel-dev/kernel-dev.html#changing-the-configuration
You basically need to rename this .config file to defconfig and add it with your kernel recipe to be as follows
linux_x.x.bb
linux
|
|_ defconfig
and add the following lines to your recipe:
# This to add the package name directory to search paths (i.e. The recipe name which is linux in this example)
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://defconfig"

How to determine dependencies of recipes in yocto?

I want to add gedit to the the image. But i am not able to find the dependencies of gedit package. How to find the dependencies (DEPENDS) in yocto.
You can use the following command which opens up a Dependency explorer that displays dependencies on the packages:
bitbake -g recipe-name -u depexp
or bitbake -g gedit -u depexp, in your case.
On pyro and later use:
bitbake -g recipe-name -u taskexp
Note: this command needs python-gtk2 installed.
You can also use Toaster, which is a web UI that collects information about what you build, including dependencies. This video shows the dependency information provided:
https://www.youtube.com/watch?v=x-6dx4huNnw
Details on how to set up and use Toaster at
https://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html
The list of packages installed in your image is stored in the manifest file (besides of build history which is already mentioned).
Content of the manifest file looks like:
alsa-conf cortexa7hf-neon-vfpv4 1.1.2-r0.1
alsa-conf-base cortexa7hf-neon-vfpv4 1.1.2-r0.1
alsa-lib cortexa7hf-neon-vfpv4 1.1.2-r0.1
alsa-states cortexa7hf-neon-vfpv4 0.2.0-r5.1
alsa-utils-alsactl cortexa7hf-neon-vfpv4 1.1.2-r0.5
alsa-utils-alsamixer cortexa7hf-neon-vfpv4 1.1.2-r0.5
...
The list consists of the package name, architecture and a version.
That manifest is located in the deploy directory (i.e. deploy/images/${MACHINE}/). Here as an example of the directory listing (there are target images and the manifest file)
example-image-genericx86.ext3
example-image-genericx86.manifest
example-image-genericx86.tar.bz2

How to handle CMake ExternalProject when repo (googletest) has multiple libraries?

How can I add external projects in CMake when the project's repo isn't the root of the library I want to use, but in fact contains two directories which are each root directories of repos that I want to use in my project?
I'm working to set up a framework CMake project that uses Google Test and Mock for testing, however when I try to download the google test repo (https://github.com/google/googletest) with ExternalProject_Add, it complains on build that it can't find the source for the project. Well, that's because Google have merged googletest and googlemock into a single project, except it's now two projects.
Some of the repo's file structure:
googletest-master/
├──[...no CMakeFiles.txt exists here...]
├──googletest/
│ ├──src/
│ └──CMakeFiles.txt
└──googlemock/
├──src/
└──CMakeFiles.txt
When I do the following...
ExternalProject_Add(
gtest
GIT_REPOSITORY https://github.com/google/googletest.git
TIMEOUT 10
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
PREFIX "googletest-master"
)
...it downloads the actual repo to googletest-master/src/gtest because I'm prefixing the repo with "googletest-master" to keep it out of my main source code, and it assumes that I'm downloading a project that is only source and that source is in the root directory.
So I'd like to accomplish two things:
Download the repo into the googletest-master directory, exactly as it would be if I cloned the repo there, or downloaded the zip off GitHub and extracted it.
Build and include both googletest and googlemock in my CMake project
You need single download step, but two build steps. Different ExternalProject_add command calls cannot share steps, but you can arrange all these steps into different calls with appropriate dependencies between them:
# Single download(git clone)
ExternalProject_Add(
googletest-master
DOWNLOAD_DIR "googletest-master/src" # The only dir option which is required
GIT_REPOSITORY https://github.com/google/googletest.git
TIMEOUT 10
LOG_DOWNLOAD ON
# Disable all other steps
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
# Build gtest from existing sources
ExternalProject_Add(
gtest
DOWNLOAD_COMMAND "" # No download required
SOURCE_DIR "googletest-master/src/googletest" # Use specific source dir
PREFIX "googletest-master" # But use prefix for compute other dirs
INSTALL_COMMAND ""
LOG_CONFIGURE ON
LOG_BUILD ON
)
# gtest should be build after being downloaded
add_dependencies(gtest googletest-master)
# Build gmock from existing sources
ExternalProject_Add(
gmock
DOWNLOAD_COMMAND "" # No download required
SOURCE_DIR "googletest-master/src/googlemock" # Use specific source dir
PREFIX "googletest-master" # But use prefix for compute other dirs
INSTALL_COMMAND ""
LOG_CONFIGURE ON
LOG_BUILD ON
)
# gmock should be build after being downloaded
add_dependencies(gmock googletest-master)
I have a repository where I import gtest and gmock libraries using CMake, just as you want to, but using the old SVN source repository instead of GIT.
I think the key is getting sources only for gmock, since it includes gtest sources and then export both libraries.
The CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(GMOCK_VERSION "1.7.0")
set(GMOCK_DIR "${CMAKE_CURRENT_BINARY_DIR}/gmock-${GMOCK_VERSION}")
ExternalProject_Add(project_gmock
SVN_REPOSITORY http://googlemock.googlecode.com/svn/tags/release-${GMOCK_VERSION}
PREFIX ${GMOCK_DIR}
CMAKE_ARGS -DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER}
# Disable update step
UPDATE_COMMAND ""
# Disable install step
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(project_gmock source_dir)
ExternalProject_Get_Property(project_gmock binary_dir)
include_directories(${source_dir}/gtest/include)
add_library(gtest STATIC IMPORTED)
set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${binary_dir}/gtest/libgtest.a)
add_dependencies(gtest project_gmock)
add_library(gtest_main STATIC IMPORTED)
set_property(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${binary_dir}/gtest/libgtest_main.a)
add_dependencies(gtest_main project_gmock)
include_directories(${source_dir}/include)
add_library(gmock STATIC IMPORTED)
set_property(TARGET gmock PROPERTY IMPORTED_LOCATION ${binary_dir}/libgmock.a)
add_dependencies(gmock project_gmock)
add_library(gmock_main STATIC IMPORTED)
set_property(TARGET gmock_main PROPERTY IMPORTED_LOCATION ${binary_dir}/libgmock_main.a)
add_dependencies(gmock_main project_gmock)
include_directories(${cpp_utest_SOURCE_DIR}/src)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
#add_executable(utests )
#target_link_libraries(utests gmock_main gmock gtest pthread)