Yocto include cmake project with custom steps - cmake

I am trying to include this simple cmake-based project to my image: https://github.com/MatrixOrbital/HTT-Utility
The steps to build in Linux are:
mkdir build
cd build
cmake ..
make
I am trying to reproduce these steps within my Yocto recipe. The generated binary (./build/htt_util) should be installed in /usr/bin.
So far with the help of devtool and some manual tuning I ended up with this recipe:
LICENSE = "MIT & Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=ff75ee274f4c77abeee3db089083fec7 \
file://hidapi/LICENSE.txt;md5=7c3949a631240cb6c31c50f3eb696077"
SRC_URI = "git://github.com/MatrixOrbital/HTT-Utility.git;protocol=https"
SRC_URI += "file://0001-Adding-ctype.patch;"
PATCHTOOL = "git"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "2045d5eacc67b89a02dafe41edfd032179333aee"
S = "${WORKDIR}/git"
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""
DEPENDS += "udev"
What should I add to my recipe to achieve the goal of generating a binary and installing into /usr/bin?
I have been trying to play with:
do_configure() {
...
}
do_compile() {
...
}
do_install() {
...
}
But so far I did not manage to do anything useful.
Any help would be appreciated.

do_install() {
install -m 0644 mybinary ${D}${bindir}
}
FILES_${PN} = " \
${bindir} \
"

Related

getting weird "missing output " error when running a nextflow pipeline

For my data analysis pipeline I am using nextflow (which is a workflow management system) and I gave all the required arguments in the main command but I am getting a weird error. Basically in the output section I introduce the output but the error is missing output. I have made 3 files to run the pipeline including:
1- the module containing the main code to run the tool (ASEReadCounter) and named ASEReadCounter.nf :
process ASEReadCounter {
input:
file vcf_file
file bam_file
path(genome_fasta)
output:
file "${vcf_file}.ASE.csv"
script:
"""
gatk ASEReadCounter \\
-R ${params.genome} \\
-V ${params.vcf_infile} \\
-O ${params.vcf_infile}.txt \\
-I ${params.bam_infile}
"""
}
2- the main file which is used to run the pipeline named main.nf :
#!/usr/bin/env nextflow
nextflow.preview.dsl=2
include ASEReadCounter from './modules/ASEReadCounter.nf'
genome_ch = Channel.fromPath(params.genome)
vcf_file_ch=Channel.fromPath(params.vcf_infile)
bam_infile_ch=Channel.fromPath(params.bam_infile)
workflow {
count_ch=ASEReadCounter(genome_ch, vcf_file_ch, bam_infile_ch)
}
3- config file which is named nextflow.config :
params {
genome = '/hpc/hg38_genome/GRCh38.p13.genome.fa'
vcf_infile = '/hpc/test_data/test/test.vcf.gz'
bam_infile = ‘/hpc/test_data/test/test.sorted.bam'
}
process {
shell = ['/bin/bash', '-euo', 'pipefail']
withName: ASEReadCounter {
container = 'broadinstitute/gatk:latest'
}
}
singularity {
enabled = true
runOptions = '-B /hpc:/hpc -B $TMPDIR:$TMPDIR'
autoMounts = true
cacheDir = '/hpc/diaggen/software/singularity_cache'
}
here is the command I use to run the whole pipeline:
nextflow run -ansi-log false main.nf
Here is the error I am getting:
Error executing process > 'ASEReadCounter (1)'
Caused by:
Missing output file(s) `GRCh38.p13.genome.fa.ASE.csv` expected by process `ASEReadCounter (1)`
Command executed:
gatk ASEReadCounter -R /hpc/hg38_genome/GRCh38.p13.genome.fa \
-V /hpc/test_data/test/test.vcf.gz \
-O /hpc/test_data/test/test.vcf.gz.txt \
-I /hpc/test_data/test/test.sorted.bam
Do you know how I can fix the error?
Your ASEReadCounter process expects a file with the pattern ${vcf_file}.ASE.csv as output, as defined at:
output:
file "${vcf_file}.ASE.csv"
I assume the line -O ${params.vcf_infile}.txt makes it so your gatk ASEReadCounter command writes its output to a file with the pattern $params.vcf_infile}.txt. The expected output and the actual output filenames don't match and nextflow throws an error because it doesn't want to contine since a downstream process might need the output file. You can fix it by matching the expected output and actual output patterns,

Bitbake LibSocketCAN

I am trying to build libsocketcan into my image. To add libsocketcan In my main application recipe I added IMAGE_INSTALL_append += " libsocketcan ". When debugging my application with Eclipse this works perfectly. When I attempt to bitbake my application I am told
fatal error: libsocketcan.h: No such file or directory
I am not sure where I am missing my dependency.
Makefile.am
AUTOMAKE_OPTIONS = foreign subdir-objects
bin_PROGRAMS = MAIN_Application
MAIN_Application_LDADD = -lsocketcan -lpthread
AM_CPPFLAGS = \
-I$(srcdir)/include \
-I$(srcdir)/include/utilities \
-I$(srcdir)/include/comms
MAIN_Application_SOURCES = \
src/main.c \
src/scheduler.c \
src/utilities/time_conversions.c \
src/utilities/ring_buffer.c \
src/utilities/logger.c \
src/comms/can.c
I believe this is the only file that would make a difference. Has anyone else ever faced this? What else do I need to do to allow my bitbake to find the include?
Edit: recipe as requestes
LICENSE = "MIT"
IMAGE_LINGUAS = " "
# Base image Install
IMAGE_INSTALL = " packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
# Configure image base size
IMAGE_ROOTFS_SIZE ?= "4096"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${#bb.utils.contains("DISTRO_FEATURES", "systemd", " + 2048", "", d)}"
# User preferences
inherit core-image
inherit extrausers
# Change root password (note the capital -P)
EXTRA_USERS_PARAMS = "\
usermod -P toor root; \
useradd -P michael -G sudo michael; \
"
# uncomment the line %sudo ALL=(ALL) ALL in /etc/sudoers
modify_sudoers() {
sed 's/# %sudo/%sudo/' < ${IMAGE_ROOTFS}${sysconfdir}/sudoers > ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp
mv ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp ${IMAGE_ROOTFS}${sysconfdir}/sudoers
}
ROOTFS_POSTPROCESS_COMMAND_append = " modify_sudoers;"
# Dependencies
DEPENDS = " libsocketcan "
# Install necessary libraries
IMAGE_INSTALL_append += " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append += " can-utils "
IMAGE_INSTALL_append += " libsocketcan"
IMAGE_INSTALL_append += " sudo "
IMAGE_INSTALL_append += " iw wireless-tools wpa-supplicant "
# Install SMG applications
IMAGE_INSTALL_append += " udevrules "
IMAGE_INSTALL_append += " mainapplication "
# Apply kernel customizations
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://kernel_customization.cfg"
# Remove image features
IMAGE_INSTALL_remove += " packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS = " udev-hwdb"
#MKUBIFS_ARGS="--leb-size 126976 --min-io-size 2048 --max-leb-cnt 3600"
#UBINIZE_ARGS="--peb-size 128KiB --min-io-size 2048 --sub-page-size 2048"
#IMAGE_FSTYPES += " ubi ubifs"
Edit 2: main application recipe
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "\
file://MAIN_Application \
file://services \
"
inherit autotools systemd
S = "${WORKDIR}/MAIN_Application"
SYSTEMD_SERVICE_${PN} = "MAINapplication.service"
do_install_append () {
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/services/MAINapplication.service ${D}${systemd_system_unitdir}
sed -i -e 's,#BINDIR#,${bindir},g' ${D}${systemd_system_unitdir}/MAINapplication.service
}
libsocketcan provides these packages:
tmp/work/aarch64-poky-linux/libsocketcan/0.0.11-r0/image
└── usr
├── include
│   ├── can_netlink.h
│   └── libsocketcan.h
├── lib
│   ├── libsocketcan.so -> libsocketcan.so.2.3.0
│   ├── libsocketcan.so.2 -> libsocketcan.so.2.3.0
│   ├── libsocketcan.so.2.3.0
│   └── pkgconfig
│   └── libsocketcan.pc
Adding DEPENDS += "libsocketcan" will cause all those files to be populated into your custom layer's working directory.
NOTE
Your recipe seems to do not install your MAIN_Application output binary file. So your recipe should look like:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "\
file://MAIN_Application \
file://services \
"
inherit autotools systemd
S = "${WORKDIR}/MAIN_Application"
DEPENDS += "libsocketcan"
SYSTEMD_SERVICE_${PN} = "MAINapplication.service"
do_install_append () {
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/services/MAINapplication.service ${D}${systemd_system_unitdir}
sed -i -e 's,#BINDIR#,${bindir},g' ${D}${systemd_system_unitdir}/MAINapplication.service
install -m 0644 ${S}/MAIN_Application ${D}${bindir}
}
Just make sure that MAIN_Application is the right binary name.
IMAGE_INSTALL_append adds package to image.
It has not much to do with build-time dependencies of your application.
What you should add to you app.bb is:
DEPENDS = "libsocketcan"
This is an answer just to help you fix some issues related to your image recipe:
Here are some important comment:
IMAGE_INSTALL
IMAGE_INSTALL = " packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
...
inherit core-image
Never and never override IMAGE_INSTALL before core-image, because IMAGE_INSTALL of core-image will not take effect.
Variable assignement
IMAGE_INSTALL_append += " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append += " can-utils "
IMAGE_INSTALL_append += " libsocketcan"
IMAGE_INSTALL_append += " sudo "
IMAGE_INSTALL_append += " iw wireless-tools wpa-supplicant "
Do not use append with += , use one of them only.
DEPENDS ??
Image recipes are just dedicated to collect recipes and create image rootfs and final image type (wic, ...)
You do not need DEPENDS.
SRC_URI ??
This is also a non-image recipe variable, did it even took effect ?
Move the kernel configuration fragment to your custom virtual/kernel package recipe.
I recommend your image recipe to look like:
LICENSE = "MIT"
IMAGE_LINGUAS = " "
# Configure image base size
IMAGE_ROOTFS_SIZE ?= "4096"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${#bb.utils.contains("DISTRO_FEATURES", "systemd", " + 2048", "", d)}"
# User preferences
inherit core-image extrausers
# Change root password (note the capital -P)
EXTRA_USERS_PARAMS = "\
usermod -P toor root; \
useradd -P michael -G sudo michael; \
"
# uncomment the line %sudo ALL=(ALL) ALL in /etc/sudoers
modify_sudoers() {
sed 's/# %sudo/%sudo/' < ${IMAGE_ROOTFS}${sysconfdir}/sudoers > ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp
mv ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp ${IMAGE_ROOTFS}${sysconfdir}/sudoers
}
ROOTFS_POSTPROCESS_COMMAND_append = " modify_sudoers;"
# Install necessary libraries
IMAGE_INSTALL_append = " packagegroup-core-ssh-openssh \
can-utils \
libsocketcan \
sudo \
iw wireless-tools wpa-supplicant"
# Install SMG applications
IMAGE_INSTALL_append = " udevrules \
mainapplication"
# Remove image features
IMAGE_INSTALL_remove += " packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS = " udev-hwdb"
#MKUBIFS_ARGS="--leb-size 126976 --min-io-size 2048 --max-leb-cnt 3600"
#UBINIZE_ARGS="--peb-size 128KiB --min-io-size 2048 --sub-page-size 2048"
#IMAGE_FSTYPES += " ubi ubifs"

Kotlin/Native project built without errors, but fails to run

I create a Kotlin/Native project with gradle init, and follow the instructions from here, managed to build the project without problems, being generated a build/bin/native/debugExecutable/executable.kexe executable file.
But when I try to run the project, I got the message:
/build/bin/native/debugExecutable/executable.kexe: error while loading shared libraries: libone.so: cannot open shared object file: No such file or directory
I am using a C library, located in the directory ../libone/libone.so (relative to the project folder). I have this *.dex file on the directory src/nativeInterop/cinterop of my project:
headers = libone.h
package = libone
compilerOpts.linux = -I/.../libone
linkerOpts.linux = -L/.../libone -lone
I have tried put the executable (executable.kexe) and the library (libone.so) in the same directory, but do not work either (same error occurs). What I am missing here?
UPDATE I made work manually setting the linux environment variable LD_LIBRARY_PATH to the library directory. I wonder if I could make work without this change in the system.
build.gradle
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.5.31'
}
repositories {
mavenCentral()
}
kotlin {
def hostOs = System.getProperty("os.name")
def isMingwX64 = hostOs.startsWith("Windows")
def nativeTarget
if (hostOs == "Mac OS X") nativeTarget = macosX64('native')
else if (hostOs == "Linux") nativeTarget = linuxX64("native")
else if (isMingwX64) nativeTarget = mingwX64("native")
else throw new FileNotFoundException("Host OS is not supported in Kotlin/Native.")
nativeTarget.with {
compilations.main { // NL
cinterops { // NL
libone // NL
} // NL
} // NL
binaries {
executable {
entryPoint = 'main'
}
}
}
sourceSets {
nativeMain {
}
nativeTest {
}
}
}
Makefile for libone
all: libone
libone: libone.o
gcc -shared -o libone.so libone.o -Wl,--out-implib,libone.a
libone.o: libone.c
gcc -fPIC -c libone.c -o libone.o
You can try changing the path in the def file to an absolute path, in my project I usually generate the def dynamically and make it a gradle task. But I still recommend you to use absolute paths anyway, there are enough examples here kotlin native samples

How to use Facebook BUCK with DTrace files?

So, if you open https://github.com/airbnb/BuckSample
And will try to install with cocoaPods https://github.com/ReactiveCocoa/ReactiveObjC
and after you'll add a new BUCK build rule like
apple_third_party_lib(
name = "ReactiveObjC",
visibility = ["PUBLIC"],
srcs = glob([
"ReactiveObjC/**/*.m",
]),
exported_headers = glob([
"ReactiveObjC/**/*.h",
]),
frameworks = [
"$PLATFORM_DIR/Developer/Library/Frameworks/Foundation.framework",
],
)
buck build //Pods:ReactiveObjC will fail with error like this
Pods/ReactiveObjC/ReactiveObjC/RACPassthroughSubscriber.m:12:9: fatal error: 'RACSignalProvider.h' file not found
If we go further we'll see that RACSignalProvider.h is not in the Pod sources, but there is RACSignalProvider.d which is DTrace source file.
When we try to compile it with XCode we can see that there is an extra step before compiling actual framwork
CompileDTraceScript /*user folder*/Pods/ReactiveObjC/ReactiveObjC/RACSignalProvider.d (in target 'ReactiveObjC' from project 'Pods')
cd /*user folder*/Pods
/usr/sbin/dtrace -h -s /*user folder*/Pods/ReactiveObjC/ReactiveObjC/RACSignalProvider.d -o /*user folder*/Library/Developer/Xcode/DerivedData/Odnoklassniki-gsukbcogkxolydbhlpglswzdhhpg/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactiveObjC.build/DerivedSources/RACSignalProvider.h
which is not happening when we run buck build
Is there something missing from config? Or this just not supported by BUCK?
So the answer is, you need to use a genrule() to process your DTrace files
It should look like
genrule(
name = "ReactiveObjC_DTrace",
srcs = [
"ReactiveObjC/ReactiveObjC/RACSignalProvider.d",
"ReactiveObjC/ReactiveObjC/RACCompoundDisposableProvider.d",
],
bash =
"""
mkdir -p $OUT
/usr/sbin/dtrace -h -s $SRCDIR/ReactiveObjC/ReactiveObjC/RACSignalProvider.d -o $OUT/RACSignalProvider.h
/usr/sbin/dtrace -h -s $SRCDIR/ReactiveObjC/ReactiveObjC/RACCompoundDisposableProvider.d -o $OUT/RACCompoundDisposableProvider.h
""",
out = "ReactiveObjC_DTrace",
visibility = ["PUBLIC"]
)
And then modify your ReactiveObjC rule to look like
apple_third_party_lib(
name = "ReactiveObjC",
visibility = ["PUBLIC"],
srcs = glob([
"ReactiveObjC/**/*.m",
]),
deps = [
"//Pods:ReactiveObjC_DTrace",
],
exported_headers = glob([
"ReactiveObjC/**/*.h",
"$(location :ReactiveObjC_DTrace)/**/*.h"
]),
frameworks = [
"$PLATFORM_DIR/Developer/Library/Frameworks/Foundation.framework",
],
)

qmake .pro file could not be parsed

I'm running OS X Mavericks and trying to convert a Qt4 application to Qt5. I've also never compiled the application on this machine before. I have Qt 5.1.* installed on this machine, which parses the file just fine. As soon as I switch over to my Qt 5.2.0 kit and look at the run settings, underneath my "Run configuration" there's a warning: "The .pro file '.pro' could not be parsed.".
I've looked at other solutions on SO and the qt-project website -- none of which have helped. My Qt 5.2.0 kit is a manually-added kit since I installed it using Homebrew.
Here is a screenshot of my settings:
Note that if I run qmake (/usr/local/opt/qt5/bin/qmake) in the project directory, no errors are output.
Here is my .pro file:
QT += core widgets concurrent
TARGET = Up
TEMPLATE = app
CONFIG += c++11
SOURCES += main.cpp\
MainForm.cpp \
AboutForm.cpp \
progressdialog.cpp
HEADERS += MainForm.h \
AboutForm.h \
progressdialog.h
FORMS += MainForm.ui \
AboutForm.ui \
progressdialog.ui
INCLUDEPATH += $$PWD/../FATX/FATX
RESOURCES += \
MainForm.qrc
CONFIG(debug, debug|release) {
macx: LIBS += -L$$PWD/../FATX-BUILD-OSX/debug/ -lFATX
INCLUDEPATH += $$PWD/../FATX-BUILD-OSX/debug
DEPENDPATH += $$PWD/../FATX-BUILD-OSX/debug
macx: PRE_TARGETDEPS += $$PWD/../FATX-BUILD-OSX/debug/libFATX.a
} else {
macx: LIBS += -L$$PWD/../FATX-OSX/release/ -lFATX
INCLUDEPATH += $$PWD/../FATX-BUILD-OSX/release
DEPENDPATH += $$PWD/../FATX-BUILD-OSX/release
macx: PRE_TARGETDEPS += $$PWD/../FATX-OSX/release/libFATX.a
}
cache()
The solution was to update Qt Creator to Qt 3.0.0.