summaryrefslogtreecommitdiffstats
path: root/meta/classes/meson.bbclass
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2021-12-04 08:13:00 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-12-06 11:09:47 +0000
commit17fb047282a413aae5af991ecf5bbb225e19581e (patch)
treeb125c3dcbe3eeedc18f369fc08b0bd48d8545542 /meta/classes/meson.bbclass
parentb9bc216c8d25ad3696c858bf12ebe893b8fe0edd (diff)
downloadopenembedded-core-contrib-17fb047282a413aae5af991ecf5bbb225e19581e.tar.gz
meson: configure and use generic exe_wrapper
This replaces the specific gtkdoc wrapper setting (which was rejected by upstream in https://github.com/mesonbuild/meson/pull/9627) with a generic, officially supported and documented exe_wrapper, which is enabled subject to qemu usermode support (just as is done for g-i and gtk-doc with autotools). gtk-doc support is adjusted so that this wrapper is passed to meson's gtk-doc module, which passes it to gtk-doc. The adjusted patch is re-submitted upstream. The side effect of this is that meson is now able to run target binaries in a generic way when it wants to, so this may affect cross-builds - hopefully in a positive way. Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/meson.bbclass')
-rw-r--r--meta/classes/meson.bbclass30
1 files changed, 28 insertions, 2 deletions
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index a7981e481f..ffec5f3269 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -1,7 +1,12 @@
-inherit python3native meson-routines
+inherit python3native meson-routines qemu
DEPENDS:append = " meson-native ninja-native"
+EXEWRAPPER_ENABLED:class-native = "False"
+EXEWRAPPER_ENABLED:class-nativesdk = "False"
+EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}"
+DEPENDS:append = "${@' qemu-native' if d.getVar('EXEWRAPPER_ENABLED') == 'True' else ''}"
+
# As Meson enforces out-of-tree builds we can just use cleandirs
B = "${WORKDIR}/build"
do_configure[cleandirs] = "${B}"
@@ -36,6 +41,9 @@ MESON_CROSS_FILE = ""
MESON_CROSS_FILE:class-target = "--cross-file ${WORKDIR}/meson.cross"
MESON_CROSS_FILE:class-nativesdk = "--cross-file ${WORKDIR}/meson.cross"
+# Needed to set up qemu wrapper below
+export STAGING_DIR_HOST
+
def rust_tool(d, target_var):
rustc = d.getVar('RUSTC')
if not rustc:
@@ -62,6 +70,7 @@ cups-config = 'cups-config'
g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper'
g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper'
${@rust_tool(d, "HOST_SYS")}
+${@"exe_wrapper = '${WORKDIR}/meson-qemuwrapper'" if d.getVar('EXEWRAPPER_ENABLED') == 'True' else ""}
[built-in options]
c_args = ${@meson_array('CFLAGS', d)}
@@ -71,7 +80,6 @@ cpp_link_args = ${@meson_array('LDFLAGS', d)}
[properties]
needs_exe_wrapper = true
-gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
[host_machine]
system = '${@meson_operating_system('HOST_OS', d)}'
@@ -106,6 +114,24 @@ cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)}
EOF
}
+do_write_config:append:class-target() {
+ # Write out a qemu wrapper that will be used as exe_wrapper so that meson
+ # can run target helper binaries through that.
+ qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
+ cat > ${WORKDIR}/meson-qemuwrapper << EOF
+#!/bin/sh
+# Use a modules directory which doesn't exist so we don't load random things
+# which may then get deleted (or their dependencies) and potentially segfault
+export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy
+
+# meson sets this wrongly (only to libs in build-dir), qemu-wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly
+unset LD_LIBRARY_PATH
+
+$qemu_binary "\$@"
+EOF
+ chmod +x ${WORKDIR}/meson-qemuwrapper
+}
+
# Tell externalsrc that changes to this file require a reconfigure
CONFIGURE_FILES = "meson.build"