]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
meson: provide relocation script and native/cross wrappers also for meson-native
authorAlexander Kanavin <alex.kanavin@gmail.com>
Fri, 22 Jul 2022 18:39:15 +0000 (20:39 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 28 Jul 2022 10:50:01 +0000 (11:50 +0100)
When using meson-native directly from bitbake this has no effect and
everything works as before; the use case is being able to build
meson-driven projects from the 'direct SDK' environment. Build systems
like cmake/autotools are entirely driven by environment variables,
but meson needs configuration files, and so this replicates how SDKs
set things up.

In particular, with this change the libepoxy build test from the SDK
test suite is able to pass.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/meson/meson/meson-wrapper
meta/recipes-devtools/meson/meson_0.63.0.bb

index 8fafaad9754f70cb2d9ff27c2108ee9564b7d2cf..c62007f5077e310f98c75d9596072492f4acb3b5 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
-    echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
+    exec "meson.real" "$@"
 fi
 
 if [ -z "$SSL_CERT_DIR" ]; then
index 42e64e351fe1f71d01ffb60f737dc5b885d76826..890f47506f488c0db52920cf9365a0c14a8194e9 100644 (file)
@@ -75,7 +75,7 @@ def generate_native_link_template(d):
 
     return repr(val)
 
-do_install:append:class-nativesdk() {
+install_templates() {
     install -d ${D}${datadir}/meson
 
     cat >${D}${datadir}/meson/meson.native.template <<EOF
@@ -117,11 +117,19 @@ needs_exe_wrapper = true
 sys_root = @OECORE_TARGET_SYSROOT
 
 [host_machine]
-system = '${SDK_OS}'
-cpu_family = '${@meson_cpu_family("SDK_ARCH", d)}'
-cpu = '${SDK_ARCH}'
-endian = '${@meson_endian("SDK", d)}'
+system = '$host_system'
+cpu_family = '$host_cpu_family'
+cpu = '$host_cpu'
+endian = '$host_endian'
 EOF
+}
+
+do_install:append:class-nativesdk() {
+    host_system=${SDK_OS}
+    host_cpu_family=${@meson_cpu_family("SDK_ARCH", d)}
+    host_cpu=${SDK_ARCH}
+    host_endian=${@meson_endian("SDK", d)}
+    install_templates
 
     install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
     install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
@@ -132,3 +140,19 @@ EOF
 }
 
 FILES:${PN}:append:class-nativesdk = "${datadir}/meson ${SDKPATHNATIVE}"
+
+do_install:append:class-native() {
+    host_system=${HOST_OS}
+    host_cpu_family=${@meson_cpu_family("HOST_ARCH", d)}
+    host_cpu=${HOST_ARCH}
+    host_endian=${@meson_endian("HOST", d)}
+    install_templates
+
+    install -d ${D}${datadir}/post-relocate-setup.d
+    install -m 0755 ${WORKDIR}/meson-setup.py ${D}${datadir}/post-relocate-setup.d/
+
+    # We need to wrap the real meson with a thin wrapper that substitues native/cross files
+    # when running in a direct SDK environment.
+    mv ${D}${bindir}/meson ${D}${bindir}/meson.real
+    install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
+}