meson: install native file in sdk

Without a native environment file, find_program() can't
locate the native program inside SDK.

That stops wayland compositor using wayland scanner.

(From OE-Core rev: c6aed1084006727e3baf70ab9d1f70d9d2d6c01f)

Signed-off-by: Hsia-Jun(Randy) Li <randy.li@synaptics.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Hsia-Jun(Randy) Li
2021-10-25 11:37:44 +08:00
committed by Richard Purdie
parent 15487d272f
commit 4311fe0324
3 changed files with 55 additions and 0 deletions

View File

@@ -27,9 +27,17 @@ except KeyError:
template_file = os.path.join(sysroot, 'usr/share/meson/meson.cross.template')
cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ["TARGET_PREFIX"])
native_template_file = os.path.join(sysroot, 'usr/share/meson/meson.native.template')
native_file = os.path.join(sysroot, 'usr/share/meson/meson.native')
with open(template_file) as in_file:
template = in_file.read()
output = Template(template).substitute(Environ())
with open(cross_file, "w") as out_file:
out_file.write(output)
with open(native_template_file) as in_file:
template = in_file.read()
output = Template(template).substitute({'OECORE_NATIVE_SYSROOT': os.environ['OECORE_NATIVE_SYSROOT']})
with open(native_file, "w") as out_file:
out_file.write(output)

View File

@@ -11,4 +11,5 @@ unset CC CXX CPP LD AR NM STRIP
exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
--cross-file "${OECORE_NATIVE_SYSROOT}/usr/share/meson/${TARGET_PREFIX}meson.cross" \
--native-file "${OECORE_NATIVE_SYSROOT}/usr/share/meson/meson.native" \
"$@"

View File

@@ -13,8 +13,54 @@ SRC_URI += "file://meson-setup.py \
# 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.
def var_list2str(var, d):
items = d.getVar(var).split()
return items[0] if len(items) == 1 else ', '.join(repr(s) for s in items)
def generate_native_link_template(d):
val = ['-L@{OECORE_NATIVE_SYSROOT}${libdir_native}',
'-L@{OECORE_NATIVE_SYSROOT}${base_libdir_native}',
'-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${libdir_native}',
'-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${base_libdir_native}',
'-Wl,--allow-shlib-undefined'
]
build_arch = d.getVar('BUILD_ARCH')
if 'x86_64' in build_arch:
loader = 'ld-linux-x86-64.so.2'
elif 'i686' in build_arch:
loader = 'ld-linux.so.2'
elif 'aarch64' in build_arch:
loader = 'ld-linux-aarch64.so.1'
elif 'ppc64le' in build_arch:
loader = 'ld64.so.2'
if loader:
val += ['-Wl,--dynamic-linker=@{OECORE_NATIVE_SYSROOT}${base_libdir_native}/' + loader]
return repr(val)
do_install:append() {
install -d ${D}${datadir}/meson
cat >${D}${datadir}/meson/meson.native.template <<EOF
[binaries]
c = ${@meson_array('BUILD_CC', d)}
cpp = ${@meson_array('BUILD_CXX', d)}
ar = ${@meson_array('BUILD_AR', d)}
nm = ${@meson_array('BUILD_NM', d)}
strip = ${@meson_array('BUILD_STRIP', d)}
readelf = ${@meson_array('BUILD_READELF', d)}
pkgconfig = 'pkg-config-native'
[built-in options]
c_args = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
c_link_args = ${@generate_native_link_template(d)}
cpp_args = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
cpp_link_args = ${@generate_native_link_template(d)}
[properties]
sys_root = '@OECORE_NATIVE_SYSROOT'
EOF
cat >${D}${datadir}/meson/meson.cross.template <<EOF
[binaries]
c = @CC