Skip to contentSkip to conversation

capnproto: only export binaries for native build

PATCH New Gyorgy Sarvari 1 participant 1 message Feb 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 capnproto: only export binaries for native build

The base problem this is trying to solve: capnproto has two main
components: libraries that can be linked against, and binary files that can generate c++ code from capnproto definitions. When cross-compiling one needs to use the cross-compiled libraries, but with the native definition-compilers.
When linking against capnproto from another recipe, cross-compilation fails, because the cmake files generated by capnproto verify the existence of binary files in $bindir. When using a cross-compiled version of capnproto, these binary files do not exist in RECIPE_SYSROOT, so the compilation fails.

The previous patch: the previous solution patched the CMakeLists.txt file in a way that it didn't export nor install the generated binary files. Accidentally this also happened with native build (and happened knowingly with target builds).

The new patch: instead of not installing and not exporting the binaries, just install them without exporting, when creating a target build. During compilation check is CMAKE_CROSSCOMPILING is set (coming from cmake.bbclass) - if it is set, only install the binaries, without exporting. When it is not set, resort to the original behavior.

---
 ...n-t-check-usr-bin-content-from-cmake.patch | 43 ---------------
 ...xport-binaries-only-for-native-build.patch | 53 +++++++++++++++++++
 .../capnproto/capnproto_1.0.2.bb              |  2 +-
 3 files changed, 54 insertions(+), 44 deletions(-)
 delete mode 100644 meta-oe/recipes-devtools/capnproto/capnproto/0001-Don-t-check-usr-bin-content-from-cmake.patch
 create mode 100644 meta-oe/recipes-devtools/capnproto/capnproto/0001-Export-binaries-only-for-native-build.patch
meta-oe/recipes-devtools/capnproto/capnproto/0001-Don-t-check-usr-bin-content-from-cmake.patch deleted +0 -43
deleted file mode 100644
index 6447fadcf9..0000000000
@@ -1,43 +0,0 @@
-From 43573472a62ff68ba6b1180d6551ef536471a99f Mon Sep 17 00:00:00 2001
-From: Gyorgy Sarvari <[email protected]>
-Date: Mon, 3 Feb 2025 11:52:01 +0100
-Subject: [PATCH] Don't install files in bindir
-
-This patch prevents the generated binary executables from being
-installed into the /usr/bin folder.
-
-By default, cmake installs these binaries into the /usr/bin folder,
-(e.g. binaries used to generate C++ source from the capnproto definition
-files) however with Yocto, when using the cross-compiled version of this
-application, the /usr/bin folder is not populated in the sysroot.
-The generated cmake file however tries to verify that these binaries
-exist, and since it cannot find them, it fails the build.
-
-But even in case these files would exist, they are not usable on the build
-machine, as these are cross-compiled for the target machine. When another
-recipe it built against the capnproto cmake package, the application can
-link against the cross-compiled libraries as expected, but for code
-generation the capnproto-native package's binaries need to be used.
-
-This patch is only applicable on the cross-compiled version of capnproto.
-
-Upstream-Status: Inappropriate [oe specific: see above message]
-
-Signed-off-by: Gyorgy Sarvari <[email protected]>
----
- c++/src/capnp/CMakeLists.txt | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/c++/src/capnp/CMakeLists.txt b/c++/src/capnp/CMakeLists.txt
-index 9980fde6..101a7091 100644
---- a/src/capnp/CMakeLists.txt
-+++ b/src/capnp/CMakeLists.txt
-@@ -210,8 +210,6 @@ if(NOT CAPNP_LITE)
-   target_link_libraries(capnpc_capnp capnp kj)
-   set_target_properties(capnpc_capnp PROPERTIES OUTPUT_NAME capnpc-capnp)
- 
--  install(TARGETS capnp_tool capnpc_cpp capnpc_capnp ${INSTALL_TARGETS_DEFAULT_ARGS})
--
-   if(WIN32)
-     # On Windows platforms symlinks are not guaranteed to support. Also different version of CMake handle create_symlink in a different way.
-     # The most portable way in this case just copy the file.
meta-oe/recipes-devtools/capnproto/capnproto/0001-Export-binaries-only-for-native-build.patch new file +53 -0

53 lines not on this page · raw message

meta-oe/recipes-devtools/capnproto/capnproto_1.0.2.bb +1 -1
index 6136ff20fb..77bde79217 100644
@@ -6,7 +6,7 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://../LICENSE;md5=a05663ae6cca874123bf667a60dca8c9"
 
 SRC_URI = "git://github.com/sandstorm-io/capnproto.git;branch=release-${PV};protocol=https \
-           file://0001-Don-t-check-usr-bin-content-from-cmake.patch"
+           file://0001-Export-binaries-only-for-native-build.patch"
 SRCREV = "1a0e12c0a3ba1f0dbbad45ddfef555166e0a14fc"
 
 S = "${WORKDIR}/git/c++"