Search code examples
yoctobitbakeopenembedded

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


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.


Solution

  • 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.