@@ -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
@@ -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
+}
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> --- .../meson/meson/meson-wrapper | 2 +- meta/recipes-devtools/meson/meson_0.62.2.bb | 34 ++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-)