diff mbox series

[meta-oe,dunfell] flatbuffers: adapt for cross-compilation environments

Message ID 20221117115119.11222-1-bindudaniel1996@gmail.com
State Under Review
Delegated to: Armin Kuster
Headers show
Series [meta-oe,dunfell] flatbuffers: adapt for cross-compilation environments | expand

Commit Message

Bhabu Bindu Nov. 17, 2022, 11:51 a.m. UTC
From: Ivan Stepic <Ivan.Stepic@bmw.de>

Flatbuffers contains a library and a schema compiler. The package
contains cmake files to discover the libraries and the compiler tool.
Currently, all of these cmake files are installed into the target
sysroot. However, the compiler utility isn't installed into the sysroot
(as it is not runnable on the build machine).

When an application that depends on flatbuffers gets built, it uses
flatbuffers' exported cmake targets to configure the project. One of the
exported targets is FlatcTarget.cmake which expects to see flatc binary
in /usr/bin of the sysroot. Since binaries for target don't end up in
target sysroot, cmake configuration fails.

This patch addresses this problem of flatbuffers' build infrastructure
in cross-compiling environments. By removing FlatcTarget.cmake for
target builds from the sysroot we essentially skip this step of
flatbuffers' configuration.

Signed-off-by: Ivan Stepic <Ivan.Stepic@bmw.de>
Signed-off-by: Bhabu Bindu <bhabu.bindu@kpit.com>
---
 meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

akuster808 Nov. 17, 2022, 2:41 p.m. UTC | #1
On 11/17/22 6:51 AM, BINDU wrote:
> From: Ivan Stepic <Ivan.Stepic@bmw.de>
>
> Flatbuffers contains a library and a schema compiler. The package
> contains cmake files to discover the libraries and the compiler tool.
> Currently, all of these cmake files are installed into the target
> sysroot. However, the compiler utility isn't installed into the sysroot
> (as it is not runnable on the build machine).
>
> When an application that depends on flatbuffers gets built, it uses
> flatbuffers' exported cmake targets to configure the project. One of the
> exported targets is FlatcTarget.cmake which expects to see flatc binary
> in /usr/bin of the sysroot. Since binaries for target don't end up in
> target sysroot, cmake configuration fails.
>
> This patch addresses this problem of flatbuffers' build infrastructure
> in cross-compiling environments. By removing FlatcTarget.cmake for
> target builds from the sysroot we essentially skip this step of
> flatbuffers' configuration.

Are any of the other branches affected by this issue?
- armin
>
> Signed-off-by: Ivan Stepic <Ivan.Stepic@bmw.de>
> Signed-off-by: Bhabu Bindu <bhabu.bindu@kpit.com>
> ---
>   meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb b/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb
> index 859d6a0b0..c4f3594f3 100644
> --- a/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb
> +++ b/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb
> @@ -24,12 +24,17 @@ BUILD_CXXFLAGS += "-std=c++11 -fPIC"
>   # BUILD_TYPE=Release is required, otherwise flatc is not installed
>   EXTRA_OECMAKE += "\
>       -DCMAKE_BUILD_TYPE=Release \
> -    -DFLATBUFFERS_BUILD_TESTS=OFF \
> +    -DFLATBUFFERS_BUILD_TESTS=OFF \
>       -DFLATBUFFERS_BUILD_SHAREDLIB=ON \
>   "
>   
>   inherit cmake
>   
> +rm_flatc_cmaketarget_for_target() {
> +    rm -f "${SYSROOT_DESTDIR}/${libdir}/cmake/flatbuffers/FlatcTargets.cmake"
> +}
> +SYSROOT_PREPROCESS_FUNCS:class-target += "rm_flatc_cmaketarget_for_target"
> +
>   S = "${WORKDIR}/git"
>   
>   FILES_${PN}-compiler = "${bindir}"
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#99604): https://lists.openembedded.org/g/openembedded-devel/message/99604
> Mute This Topic: https://lists.openembedded.org/mt/95087923/3616698
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [akuster808@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb b/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb
index 859d6a0b0..c4f3594f3 100644
--- a/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb
+++ b/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.12.0.bb
@@ -24,12 +24,17 @@  BUILD_CXXFLAGS += "-std=c++11 -fPIC"
 # BUILD_TYPE=Release is required, otherwise flatc is not installed
 EXTRA_OECMAKE += "\
     -DCMAKE_BUILD_TYPE=Release \
-    -DFLATBUFFERS_BUILD_TESTS=OFF \    
+    -DFLATBUFFERS_BUILD_TESTS=OFF \
     -DFLATBUFFERS_BUILD_SHAREDLIB=ON \
 "
 
 inherit cmake
 
+rm_flatc_cmaketarget_for_target() {
+    rm -f "${SYSROOT_DESTDIR}/${libdir}/cmake/flatbuffers/FlatcTargets.cmake"
+}
+SYSROOT_PREPROCESS_FUNCS:class-target += "rm_flatc_cmaketarget_for_target"
+
 S = "${WORKDIR}/git"
 
 FILES_${PN}-compiler = "${bindir}"