mirror of
https://git.yoctoproject.org/poky
synced 2026-04-30 03:32:12 +02:00
meson: enable nativesdk
Currently, we can't build meson into SDKs because we don't autogenerate the required meson.cross file. Enable this by using the post-relocate hooks and generating a meson.cross file based on the SDK environment passed into the post-relocate hook. (From OE-Core rev: aabb846b165fec218024a7a57f3c9fdaa2514179) Signed-off-by: Martin Kelly <mkelly@xevo.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
2a73be1b0e
commit
e14171cc59
22
meta/recipes-devtools/meson/meson.inc
Normal file
22
meta/recipes-devtools/meson/meson.inc
Normal file
@@ -0,0 +1,22 @@
|
||||
HOMEPAGE = "http://mesonbuild.com"
|
||||
SUMMARY = "A high performance build system"
|
||||
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
|
||||
|
||||
SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz \
|
||||
file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
|
||||
file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
|
||||
file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
|
||||
file://0003-native_bindir.patch \
|
||||
file://0004-Prettifying-some-output-with-pathlib.patch \
|
||||
file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
|
||||
"
|
||||
|
||||
SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
|
||||
SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
|
||||
UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
|
||||
|
||||
inherit setuptools3
|
||||
|
||||
RDEPENDS_${PN} = "ninja python3-core python3-modules"
|
||||
62
meta/recipes-devtools/meson/meson/meson-setup.py
Executable file
62
meta/recipes-devtools/meson/meson/meson-setup.py
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def bail(msg):
|
||||
print(msg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
_MARKER = '@@'
|
||||
def transform_line(line):
|
||||
# Substitute any special markers of this form:
|
||||
# @@ENV@@
|
||||
# with the value of ENV, split into meson array syntax.
|
||||
start = line.find(_MARKER)
|
||||
if start == -1:
|
||||
return line
|
||||
|
||||
end = line.rfind(_MARKER)
|
||||
if end == start:
|
||||
return line
|
||||
|
||||
# Lookup value of the env var.
|
||||
var = line[start+len(_MARKER):end]
|
||||
try:
|
||||
val = os.environ[var]
|
||||
except KeyError:
|
||||
bail('cannot generate meson.cross; env var %s not set' % var)
|
||||
|
||||
# Transform into meson array.
|
||||
val = ["'%s'" % x for x in val.split()]
|
||||
val = ', '.join(val)
|
||||
val = '[%s]' % val
|
||||
|
||||
before = line[:start]
|
||||
after = line[end+len(_MARKER):]
|
||||
|
||||
return '%s%s%s' % (before, val, after)
|
||||
|
||||
# Make sure this is really an SDK extraction environment.
|
||||
try:
|
||||
sysroot = os.environ['OECORE_NATIVE_SYSROOT']
|
||||
except KeyError:
|
||||
bail('OECORE_NATIVE_SYSROOT env var must be set')
|
||||
|
||||
cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross')
|
||||
tmp_cross_file = '%s.tmp' % cross_file
|
||||
|
||||
# Read through and transform the current meson.cross.
|
||||
lines = []
|
||||
with open(cross_file, 'r') as f:
|
||||
for line in f:
|
||||
lines.append(transform_line(line))
|
||||
|
||||
# Write the transformed result to a tmp file and atomically rename it. In case
|
||||
# we crash during the file write, we don't want an invalid meson.cross file.
|
||||
with open(tmp_cross_file, 'w') as f:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
f.flush()
|
||||
os.fdatasync(f.fileno())
|
||||
os.rename(tmp_cross_file, cross_file)
|
||||
14
meta/recipes-devtools/meson/meson/meson-wrapper
Executable file
14
meta/recipes-devtools/meson/meson/meson-wrapper
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
|
||||
echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
|
||||
fi
|
||||
|
||||
# If these are set to a cross-compile path, meson will get confused and try to
|
||||
# use them as native tools. Unset them to prevent this, as all the cross-compile
|
||||
# config is already in meson.cross.
|
||||
unset CC CXX CPP LD AR NM STRIP
|
||||
|
||||
exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
|
||||
--cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \
|
||||
"$@"
|
||||
@@ -1,23 +1,3 @@
|
||||
HOMEPAGE = "http://mesonbuild.com"
|
||||
SUMMARY = "A high performance build system"
|
||||
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
|
||||
|
||||
SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/${BP}.tar.gz \
|
||||
file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
|
||||
file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
|
||||
file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
|
||||
file://0003-native_bindir.patch \
|
||||
file://0004-Prettifying-some-output-with-pathlib.patch \
|
||||
file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
|
||||
SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
|
||||
UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
|
||||
|
||||
inherit setuptools3
|
||||
|
||||
RDEPENDS_${PN} = "ninja python3-core python3-modules"
|
||||
include meson.inc
|
||||
|
||||
BBCLASSEXTEND = "native"
|
||||
|
||||
74
meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
Normal file
74
meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
Normal file
@@ -0,0 +1,74 @@
|
||||
include meson.inc
|
||||
|
||||
inherit nativesdk
|
||||
|
||||
SRC_URI += "file://meson-setup.py \
|
||||
file://meson-wrapper"
|
||||
|
||||
def meson_array(var, d):
|
||||
return "', '".join(d.getVar(var).split()).join(("'", "'"))
|
||||
|
||||
# both are required but not used by meson
|
||||
MESON_SDK_ENDIAN = "bogus-endian"
|
||||
MESON_TARGET_ENDIAN = "bogus-endian"
|
||||
|
||||
MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}"
|
||||
MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}"
|
||||
MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}"
|
||||
MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}"
|
||||
|
||||
# This logic is similar but not identical to that in meson.bbclass, since it's
|
||||
# generating for an SDK rather than a cross-compile. Important differences are:
|
||||
# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
|
||||
# real paths by meson-setup.sh when the SDK is extracted.
|
||||
# - Some overrides aren't needed, since the SDK injects paths that take care of
|
||||
# them.
|
||||
addtask write_config before do_install
|
||||
do_write_config[vardeps] += "MESON_C_ARGS MESON_CPP_ARGS MESON_LINK_ARGS CC CXX LD AR NM STRIP READELF"
|
||||
do_write_config() {
|
||||
# This needs to be Py to split the args into single-element lists
|
||||
cat >${WORKDIR}/meson.cross <<EOF
|
||||
[binaries]
|
||||
c = @@CC@@
|
||||
cpp = @@CXX@@
|
||||
ar = @@AR@@
|
||||
nm = @@NM@@
|
||||
ld = @@LD@@
|
||||
strip = @@STRIP@@
|
||||
pkgconfig = 'pkg-config'
|
||||
|
||||
[properties]
|
||||
needs_exe_wrapper = true
|
||||
c_args = @@CFLAGS@@
|
||||
c_link_args = @@LDFLAGS@@
|
||||
cpp_args = @@CPPFLAGS@@
|
||||
cpp_link_args = @@LDFLAGS@@
|
||||
|
||||
[host_machine]
|
||||
system = '${SDK_OS}'
|
||||
cpu_family = '${SDK_ARCH}'
|
||||
cpu = '${SDK_ARCH}'
|
||||
endian = '${MESON_SDK_ENDIAN}'
|
||||
EOF
|
||||
}
|
||||
|
||||
do_install_append() {
|
||||
install -d ${D}${datadir}/meson
|
||||
install -m 0644 ${WORKDIR}/meson.cross ${D}${datadir}/meson/
|
||||
|
||||
install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
|
||||
install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
|
||||
|
||||
# We need to wrap the real meson with a thin env setup wrapper.
|
||||
mv ${D}${bindir}/meson ${D}${bindir}/meson.real
|
||||
install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
|
||||
}
|
||||
|
||||
RDEPENDS_${PN} += "\
|
||||
nativesdk-ninja \
|
||||
nativesdk-python3-core \
|
||||
nativesdk-python3-misc \
|
||||
nativesdk-python3-modules \
|
||||
"
|
||||
|
||||
FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}"
|
||||
Reference in New Issue
Block a user