All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustav Lindberg <gustali@axis.com>
To: <openembedded-core@lists.openembedded.org>
Cc: Gustav Lindberg <gustali@axis.com>
Subject: [PATCHv7] boost: Add support for building boost-asio as a shared library
Date: Thu, 3 Sep 2026 11:45:17 +0200	[thread overview]
Message-ID: <20260903094517.891670-1-gustali@axis.com> (raw)

This is needed to build boost asio as a shared library rather than a
header-only library, which is needed to save memory.

This can be enabled by adding `PACKAGECONFIG:append = " asio"` to
`boost_%.bbappend`.

Signed-off-by: Gustav Lindberg <gustali@axis.com>
---
 meta/recipes-support/boost/boost.inc          | 25 +++++++++++++++++++
 .../boost/boost/boost_asio.cpp                |  1 +
 2 files changed, 26 insertions(+)
 create mode 100644 meta/recipes-support/boost/boost/boost_asio.cpp

diff --git a/meta/recipes-support/boost/boost.inc b/meta/recipes-support/boost/boost.inc
index 64a57ddfb2..4ac3f7af5b 100644
--- a/meta/recipes-support/boost/boost.inc
+++ b/meta/recipes-support/boost/boost.inc
@@ -44,6 +44,7 @@ BOOST_LIBS = "\
 	type_erasure \
 	url \
 	wave \
+	${@bb.utils.contains('PACKAGECONFIG', 'asio', 'asio', '', d)} \
 	${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \
 	${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \
 			     bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \
@@ -51,11 +52,14 @@ BOOST_LIBS = "\
 
 # optional libraries
 PACKAGECONFIG ??= "locale python"
+PACKAGECONFIG[asio] = ",,"
 PACKAGECONFIG[locale] = ",,icu"
 PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich"
 PACKAGECONFIG[mpi] = ",,mpich"
 PACKAGECONFIG[python] = ",,python3"
 
+SRC_URI:append = " ${@bb.utils.contains('PACKAGECONFIG', 'asio', 'file://boost_asio.cpp', '', d)}"
+
 inherit python3-dir
 PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}"
 
@@ -198,6 +202,20 @@ do_compile() {
 		--debug-configuration
 }
 
+do_compile:append() {
+	if ${@bb.utils.contains('PACKAGECONFIG', 'asio', 'true', 'false', d)}; then
+		${CXX} ${CPPFLAGS} ${CXXFLAGS} \
+			-DBOOST_ASIO_DYN_LINK=1 \
+			-I${S} \
+			-fPIC \
+			-shared \
+			-Wl,-soname,libboost_asio.so.${PV} \
+			${UNPACKDIR}/boost_asio.cpp \
+			${LDFLAGS} \
+			-o ${B}/libboost_asio.so.${PV}
+	fi
+}
+
 do_install() {
 	cd ${S}
 	b2 ${BJAM_OPTS} \
@@ -220,4 +238,11 @@ do_install() {
 
 }
 
+do_install:append() {
+	if ${@bb.utils.contains('PACKAGECONFIG', 'asio', 'true', 'false', d)}; then
+		install -Dm 0755 ${B}/libboost_asio.so.${PV} ${D}${libdir}/libboost_asio.so.${PV}
+		ln -sf libboost_asio.so.${PV} ${D}${libdir}/libboost_asio.so
+	fi
+}
+
 BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-support/boost/boost/boost_asio.cpp b/meta/recipes-support/boost/boost/boost_asio.cpp
new file mode 100644
index 0000000000..eb3b7262c3
--- /dev/null
+++ b/meta/recipes-support/boost/boost/boost_asio.cpp
@@ -0,0 +1 @@
+#include <boost/asio/impl/src.hpp>
\ No newline at end of file
-- 
2.43.0

Move the shared library build to the existing boost recipe, and allow enabling it with a PACKAGECONFIG


             reply	other threads:[~2026-09-03  9:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  9:45 Gustav Lindberg [this message]
2026-09-03  9:58 ` [OE-core] [PATCHv7] boost: Add support for building boost-asio as a shared library Alexander Kanavin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260903094517.891670-1-gustali@axis.com \
    --to=gustali@axis.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.