meson.bbclass: Split into meson-env and meson classes
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 meson.bbclass: Split into meson-env and meson classes
The new meson-env class will be used by a new PEP517 python build class using meson-python a.k.a. mesonpy.
---
v2: The split-off part is called meson-env.bbclass
because "common" is not liked.
meta/classes-recipe/meson-env.bbclass | 141 ++++++++++++++++++++++++++ meta/classes-recipe/meson.bbclass | 136 +------------------------ 2 files changed, 142 insertions(+), 135 deletions(-) create mode 100644 meta/classes-recipe/meson-env.bbclass
meta/classes-recipe/meson-env.bbclass new file +141 -0
@@ -0,0 +1,141 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +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}" + +# Where the meson.build build configuration is +MESON_SOURCEPATH = "${S}" + +def noprefix(var, d): + return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) + +MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" +MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" +MESONOPTS = " --prefix ${prefix} \ + --buildtype ${MESON_BUILDTYPE} \ + --bindir ${@noprefix('bindir', d)} \ + --sbindir ${@noprefix('sbindir', d)} \ + --datadir ${@noprefix('datadir', d)} \ + --libdir ${@noprefix('libdir', d)} \ + --libexecdir ${@noprefix('libexecdir', d)} \ + --includedir ${@noprefix('includedir', d)} \ + --mandir ${@noprefix('mandir', d)} \ + --infodir ${@noprefix('infodir', d)} \ + --sysconfdir ${sysconfdir} \ + --localstatedir ${localstatedir} \ + --sharedstatedir ${sharedstatedir} \ + --wrap-mode nodownload \ + --native-file ${WORKDIR}/meson.native" + +EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" + +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: + return "" + cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() + return "rust = %s" % repr(cmd) + +addtask write_config before do_configure +do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" +do_write_config() { + # This needs to be Py to split the args into single-element lists + cat >${WORKDIR}/meson.cross <<EOF +[binaries] +c = ${@meson_array('CC', d)} +cpp = ${@meson_array('CXX', d)} +cython = 'cython3' +ar = ${@meson_array('AR', d)} +nm = ${@meson_array('NM', d)} +strip = ${@meson_array('STRIP', d)} +readelf = ${@meson_array('READELF', d)} +objcopy = ${@meson_array('OBJCOPY', d)} +pkgconfig = 'pkg-config' +llvm-config = 'llvm-config' +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)} +c_link_args = ${@meson_array('LDFLAGS', d)} +cpp_args = ${@meson_array('CXXFLAGS', d)} +cpp_link_args = ${@meson_array('LDFLAGS', d)} + +[properties] +needs_exe_wrapper = true + +[host_machine] +system = '${@meson_operating_system('HOST_OS', d)}' +cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' +cpu = '${HOST_ARCH}' +endian = '${@meson_endian('HOST', d)}' + +[target_machine] +system = '${@meson_operating_system('TARGET_OS', d)}' +cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' +cpu = '${TARGET_ARCH}' +endian = '${@meson_endian('TARGET', d)}' +EOF + + cat >${WORKDIR}/meson.native <<EOF +[binaries] +c = ${@meson_array('BUILD_CC', d)} +cpp = ${@meson_array('BUILD_CXX', d)} +cython = 'cython3' +ar = ${@meson_array('BUILD_AR', d)} +nm = ${@meson_array('BUILD_NM', d)} +strip = ${@meson_array('BUILD_STRIP', d)} +readelf = ${@meson_array('BUILD_READELF', d)} +objcopy = ${@meson_array('BUILD_OBJCOPY', d)} +pkgconfig = 'pkg-config-native' +${@rust_tool(d, "BUILD_SYS")} + +[built-in options] +c_args = ${@meson_array('BUILD_CFLAGS', d)} +c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} +cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} +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 +}
meta/classes-recipe/meson.bbclass +1 -135
142 lines not on this page · raw message
Signature · 1 line
2.39.2
It would help if you explain why existing meson class can't be used directly, and what the meson class adds compared to meson-env that gets in the way of that.
Alex
Quoted 320 lines · Zoltan Boszormenyi
The new meson-env class will be used by a new PEP517 python build class using meson-python a.k.a. mesonpy.
Signed-off-by Zoltán Böszörményi <[email protected]>---
v2: The split-off part is called meson-env.bbclass
because "common" is not liked.meta/classes-recipe/meson-env.bbclass | 141 ++++++++++++++++++++++++++ meta/classes-recipe/meson.bbclass | 136 +------------------------ 2 files changed, 142 insertions(+), 135 deletions(-) create mode 100644 meta/classes-recipe/meson-env.bbclassmeta/classes-recipe/meson-env.bbclass new file +141
-0@@ -0,0 +1,141 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +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}" + +# Where the meson.build build configuration is +MESON_SOURCEPATH = "${S}" + +def noprefix(var, d): + return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) + +MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" +MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" +MESONOPTS = " --prefix ${prefix} \ + --buildtype ${MESON_BUILDTYPE} \ + --bindir ${@noprefix('bindir', d)} \ + --sbindir ${@noprefix('sbindir', d)} \ + --datadir ${@noprefix('datadir', d)} \ + --libdir ${@noprefix('libdir', d)} \ + --libexecdir ${@noprefix('libexecdir', d)} \ + --includedir ${@noprefix('includedir', d)} \ + --mandir ${@noprefix('mandir', d)} \ + --infodir ${@noprefix('infodir', d)} \ + --sysconfdir ${sysconfdir} \ + --localstatedir ${localstatedir} \ + --sharedstatedir ${sharedstatedir} \ + --wrap-mode nodownload \ + --native-file ${WORKDIR}/meson.native" + +EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" + +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: + return "" + cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() + return "rust = %s" % repr(cmd) + +addtask write_config before do_configure +do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" +do_write_config() { + # This needs to be Py to split the args into single-element lists + cat >${WORKDIR}/meson.cross <<EOF +[binaries] +c = ${@meson_array('CC', d)} +cpp = ${@meson_array('CXX', d)} +cython = 'cython3' +ar = ${@meson_array('AR', d)} +nm = ${@meson_array('NM', d)} +strip = ${@meson_array('STRIP', d)} +readelf = ${@meson_array('READELF', d)} +objcopy = ${@meson_array('OBJCOPY', d)} +pkgconfig = 'pkg-config' +llvm-config = 'llvm-config' +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)} +c_link_args = ${@meson_array('LDFLAGS', d)} +cpp_args = ${@meson_array('CXXFLAGS', d)} +cpp_link_args = ${@meson_array('LDFLAGS', d)} + +[properties] +needs_exe_wrapper = true + +[host_machine] +system = '${@meson_operating_system('HOST_OS', d)}' +cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' +cpu = '${HOST_ARCH}' +endian = '${@meson_endian('HOST', d)}' + +[target_machine] +system = '${@meson_operating_system('TARGET_OS', d)}' +cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' +cpu = '${TARGET_ARCH}' +endian = '${@meson_endian('TARGET', d)}' +EOF + + cat >${WORKDIR}/meson.native <<EOF +[binaries] +c = ${@meson_array('BUILD_CC', d)} +cpp = ${@meson_array('BUILD_CXX', d)} +cython = 'cython3' +ar = ${@meson_array('BUILD_AR', d)} +nm = ${@meson_array('BUILD_NM', d)} +strip = ${@meson_array('BUILD_STRIP', d)} +readelf = ${@meson_array('BUILD_READELF', d)} +objcopy = ${@meson_array('BUILD_OBJCOPY', d)} +pkgconfig = 'pkg-config-native' +${@rust_tool(d, "BUILD_SYS")} + +[built-in options] +c_args = ${@meson_array('BUILD_CFLAGS', d)} +c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} +cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} +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 +}meta/classes-recipe/meson.bbclass +1
-136@@ -4,141 +4,7 @@ # SPDX-License-Identifier: MIT # -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}" - -# Where the meson.build build configuration is -MESON_SOURCEPATH = "${S}" - -def noprefix(var, d): - return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) - -MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" -MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" -MESONOPTS = " --prefix ${prefix} \ - --buildtype ${MESON_BUILDTYPE} \ - --bindir ${@noprefix('bindir', d)} \ - --sbindir ${@noprefix('sbindir', d)} \ - --datadir ${@noprefix('datadir', d)} \ - --libdir ${@noprefix('libdir', d)} \ - --libexecdir ${@noprefix('libexecdir', d)} \ - --includedir ${@noprefix('includedir', d)} \ - --mandir ${@noprefix('mandir', d)} \ - --infodir ${@noprefix('infodir', d)} \ - --sysconfdir ${sysconfdir} \ - --localstatedir ${localstatedir} \ - --sharedstatedir ${sharedstatedir} \ - --wrap-mode nodownload \ - --native-file ${WORKDIR}/meson.native" - -EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" - -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: - return "" - cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() - return "rust = %s" % repr(cmd) - -addtask write_config before do_configure -do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" -do_write_config() { - # This needs to be Py to split the args into single-element lists - cat >${WORKDIR}/meson.cross <<EOF -[binaries] -c = ${@meson_array('CC', d)} -cpp = ${@meson_array('CXX', d)} -cython = 'cython3' -ar = ${@meson_array('AR', d)} -nm = ${@meson_array('NM', d)} -strip = ${@meson_array('STRIP', d)} -readelf = ${@meson_array('READELF', d)} -objcopy = ${@meson_array('OBJCOPY', d)} -pkgconfig = 'pkg-config' -llvm-config = 'llvm-config' -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)} -c_link_args = ${@meson_array('LDFLAGS', d)} -cpp_args = ${@meson_array('CXXFLAGS', d)} -cpp_link_args = ${@meson_array('LDFLAGS', d)} - -[properties] -needs_exe_wrapper = true - -[host_machine] -system = '${@meson_operating_system('HOST_OS', d)}' -cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' -cpu = '${HOST_ARCH}' -endian = '${@meson_endian('HOST', d)}' - -[target_machine] -system = '${@meson_operating_system('TARGET_OS', d)}' -cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' -cpu = '${TARGET_ARCH}' -endian = '${@meson_endian('TARGET', d)}' -EOF - - cat >${WORKDIR}/meson.native <<EOF -[binaries] -c = ${@meson_array('BUILD_CC', d)} -cpp = ${@meson_array('BUILD_CXX', d)} -cython = 'cython3' -ar = ${@meson_array('BUILD_AR', d)} -nm = ${@meson_array('BUILD_NM', d)} -strip = ${@meson_array('BUILD_STRIP', d)} -readelf = ${@meson_array('BUILD_READELF', d)} -objcopy = ${@meson_array('BUILD_OBJCOPY', d)} -pkgconfig = 'pkg-config-native' -${@rust_tool(d, "BUILD_SYS")} - -[built-in options] -c_args = ${@meson_array('BUILD_CFLAGS', d)} -c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} -cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} -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 -} +inherit meson-env # Tell externalsrc that changes to this file require a reconfigure CONFIGURE_FILES = "meson.build" --2.39.2
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#179011): https://lists.openembedded.org/g/openembedded-core/message/179011
Mute This Topic: https://lists.openembedded.org/mt/97816812/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
2023. 03. 24. 8:47 keltezéssel, Alexander Kanavin írta:
Quoted 3 lines
It would help if you explain why existing meson class can't be used directly, and what the meson class adds compared to meson-env that gets in the way of that.
The email thread for the mesonpy bbclass in
openembedded-devel lists all the problems.
Summary:
* Both meson and python_pep517 classes declare EXPORT_FUNCTION. For some reason, meson always wins regardless of the inheritance order. The mesonpy class needs the meson cross compiler environment using the pep517 configure/compile/install functions.
* The meson class adds do_qa_configure which fails because the mesonpy build moves the meson setup phase from do_configure to do_compile. Removing items from do_configure[postfuncs] is impossible because this results in a parse error:
do_configure[postfuncs]:remove = "meson_do_qa_configure"
The only option left is to split the environment setup part out of meson.bbclass.
Quoted 322 lines
Alex
Quoted 319 lines · Zoltan Boszormenyi
The new meson-env class will be used by a new PEP517 python build class using meson-python a.k.a. mesonpy.
Signed-off-by Zoltán Böszörményi <[email protected]>---
v2: The split-off part is called meson-env.bbclass
because "common" is not liked.meta/classes-recipe/meson-env.bbclass | 141 ++++++++++++++++++++++++++ meta/classes-recipe/meson.bbclass | 136 +------------------------ 2 files changed, 142 insertions(+), 135 deletions(-)create mode 100644 meta/classes-recipe/meson-env.bbclass
meta/classes-recipe/meson-env.bbclass new file +141
-0@@ -0,0 +1,141 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +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}" + +# Where the meson.build build configuration is +MESON_SOURCEPATH = "${S}" + +def noprefix(var, d): + return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) + +MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" +MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" +MESONOPTS = " --prefix ${prefix} \ + --buildtype ${MESON_BUILDTYPE} \ + --bindir ${@noprefix('bindir', d)} \ + --sbindir ${@noprefix('sbindir', d)} \ + --datadir ${@noprefix('datadir', d)} \ + --libdir ${@noprefix('libdir', d)} \ + --libexecdir ${@noprefix('libexecdir', d)} \ + --includedir ${@noprefix('includedir', d)} \ + --mandir ${@noprefix('mandir', d)} \ + --infodir ${@noprefix('infodir', d)} \ + --sysconfdir ${sysconfdir} \ + --localstatedir ${localstatedir} \ + --sharedstatedir ${sharedstatedir} \ + --wrap-mode nodownload \ + --native-file ${WORKDIR}/meson.native" + +EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" + +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: + return "" + cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() + return "rust = %s" % repr(cmd) + +addtask write_config before do_configure +do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" +do_write_config() { + # This needs to be Py to split the args into single-element lists + cat >${WORKDIR}/meson.cross <<EOF +[binaries] +c = ${@meson_array('CC', d)} +cpp = ${@meson_array('CXX', d)} +cython = 'cython3' +ar = ${@meson_array('AR', d)} +nm = ${@meson_array('NM', d)} +strip = ${@meson_array('STRIP', d)} +readelf = ${@meson_array('READELF', d)} +objcopy = ${@meson_array('OBJCOPY', d)} +pkgconfig = 'pkg-config' +llvm-config = 'llvm-config' +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)} +c_link_args = ${@meson_array('LDFLAGS', d)} +cpp_args = ${@meson_array('CXXFLAGS', d)} +cpp_link_args = ${@meson_array('LDFLAGS', d)} + +[properties] +needs_exe_wrapper = true + +[host_machine] +system = '${@meson_operating_system('HOST_OS', d)}' +cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' +cpu = '${HOST_ARCH}' +endian = '${@meson_endian('HOST', d)}' + +[target_machine] +system = '${@meson_operating_system('TARGET_OS', d)}' +cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' +cpu = '${TARGET_ARCH}' +endian = '${@meson_endian('TARGET', d)}' +EOF + + cat >${WORKDIR}/meson.native <<EOF +[binaries] +c = ${@meson_array('BUILD_CC', d)} +cpp = ${@meson_array('BUILD_CXX', d)} +cython = 'cython3' +ar = ${@meson_array('BUILD_AR', d)} +nm = ${@meson_array('BUILD_NM', d)} +strip = ${@meson_array('BUILD_STRIP', d)} +readelf = ${@meson_array('BUILD_READELF', d)} +objcopy = ${@meson_array('BUILD_OBJCOPY', d)} +pkgconfig = 'pkg-config-native' +${@rust_tool(d, "BUILD_SYS")} + +[built-in options] +c_args = ${@meson_array('BUILD_CFLAGS', d)} +c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} +cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} +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 +}meta/classes-recipe/meson.bbclass +1
-136@@ -4,141 +4,7 @@ # SPDX-License-Identifier: MIT # -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}" - -# Where the meson.build build configuration is -MESON_SOURCEPATH = "${S}" - -def noprefix(var, d): - return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) - -MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" -MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" -MESONOPTS = " --prefix ${prefix} \ - --buildtype ${MESON_BUILDTYPE} \ - --bindir ${@noprefix('bindir', d)} \ - --sbindir ${@noprefix('sbindir', d)} \ - --datadir ${@noprefix('datadir', d)} \ - --libdir ${@noprefix('libdir', d)} \ - --libexecdir ${@noprefix('libexecdir', d)} \ - --includedir ${@noprefix('includedir', d)} \ - --mandir ${@noprefix('mandir', d)} \ - --infodir ${@noprefix('infodir', d)} \ - --sysconfdir ${sysconfdir} \ - --localstatedir ${localstatedir} \ - --sharedstatedir ${sharedstatedir} \ - --wrap-mode nodownload \ - --native-file ${WORKDIR}/meson.native" - -EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" - -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: - return "" - cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() - return "rust = %s" % repr(cmd) - -addtask write_config before do_configure -do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" -do_write_config() { - # This needs to be Py to split the args into single-element lists - cat >${WORKDIR}/meson.cross <<EOF -[binaries] -c = ${@meson_array('CC', d)} -cpp = ${@meson_array('CXX', d)} -cython = 'cython3' -ar = ${@meson_array('AR', d)} -nm = ${@meson_array('NM', d)} -strip = ${@meson_array('STRIP', d)} -readelf = ${@meson_array('READELF', d)} -objcopy = ${@meson_array('OBJCOPY', d)} -pkgconfig = 'pkg-config' -llvm-config = 'llvm-config' -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)} -c_link_args = ${@meson_array('LDFLAGS', d)} -cpp_args = ${@meson_array('CXXFLAGS', d)} -cpp_link_args = ${@meson_array('LDFLAGS', d)} - -[properties] -needs_exe_wrapper = true - -[host_machine] -system = '${@meson_operating_system('HOST_OS', d)}' -cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' -cpu = '${HOST_ARCH}' -endian = '${@meson_endian('HOST', d)}' - -[target_machine] -system = '${@meson_operating_system('TARGET_OS', d)}' -cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' -cpu = '${TARGET_ARCH}' -endian = '${@meson_endian('TARGET', d)}' -EOF - - cat >${WORKDIR}/meson.native <<EOF -[binaries] -c = ${@meson_array('BUILD_CC', d)} -cpp = ${@meson_array('BUILD_CXX', d)} -cython = 'cython3' -ar = ${@meson_array('BUILD_AR', d)} -nm = ${@meson_array('BUILD_NM', d)} -strip = ${@meson_array('BUILD_STRIP', d)} -readelf = ${@meson_array('BUILD_READELF', d)} -objcopy = ${@meson_array('BUILD_OBJCOPY', d)} -pkgconfig = 'pkg-config-native' -${@rust_tool(d, "BUILD_SYS")} - -[built-in options] -c_args = ${@meson_array('BUILD_CFLAGS', d)} -c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} -cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} -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 -} +inherit meson-env # Tell externalsrc that changes to this file require a reconfigure CONFIGURE_FILES = "meson.build" --2.39.2
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#179011): https://lists.openembedded.org/g/openembedded-core/message/179011
Mute This Topic: https://lists.openembedded.org/mt/97816812/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Cam you please place this information into the commit message? At some point someone will need to find out why this was done this way, and email thread would by then be hopelessly undiscoverable.
Alex
Quoted 348 lines · Böszörményi Zoltán
2023. 03. 24. 8:47 keltezéssel, Alexander Kanavin írta:
Quoted 3 lines
It would help if you explain why existing meson class can't be used directly, and what the meson class adds compared to meson-env that gets in the way of that.
The email thread for the mesonpy bbclass in
openembedded-devel lists all the problems.Summary:
* Both meson andpython_pep517classes declareEXPORT_FUNCTION. For some reason, meson always wins regardless of the inheritance order. The mesonpy class needs the meson cross compiler environment using the pep517 configure/compile/install functions.
* The meson class addsdo_qa_configurewhich fails because the mesonpy build moves the meson setup phase fromdo_configuretodo_compile. Removing items from do_configure[postfuncs] is impossible because this results in a parse error:
do_configure[postfuncs]:remove = "meson_do_qa_configure"The only option left is to split the environment setup part out of meson.bbclass.
Quoted 322 lines
Alex
Quoted 319 lines · Zoltan Boszormenyi
The new meson-env class will be used by a new PEP517 python build class using meson-python a.k.a. mesonpy.
Signed-off-by Zoltán Böszörményi <[email protected]>---
v2: The split-off part is called meson-env.bbclass
because "common" is not liked.meta/classes-recipe/meson-env.bbclass | 141 ++++++++++++++++++++++++++ meta/classes-recipe/meson.bbclass | 136 +------------------------ 2 files changed, 142 insertions(+), 135 deletions(-)create mode 100644 meta/classes-recipe/meson-env.bbclass
meta/classes-recipe/meson-env.bbclass new file +141
-0@@ -0,0 +1,141 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +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}" + +# Where the meson.build build configuration is +MESON_SOURCEPATH = "${S}" + +def noprefix(var, d): + return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) + +MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" +MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" +MESONOPTS = " --prefix ${prefix} \ + --buildtype ${MESON_BUILDTYPE} \ + --bindir ${@noprefix('bindir', d)} \ + --sbindir ${@noprefix('sbindir', d)} \ + --datadir ${@noprefix('datadir', d)} \ + --libdir ${@noprefix('libdir', d)} \ + --libexecdir ${@noprefix('libexecdir', d)} \ + --includedir ${@noprefix('includedir', d)} \ + --mandir ${@noprefix('mandir', d)} \ + --infodir ${@noprefix('infodir', d)} \ + --sysconfdir ${sysconfdir} \ + --localstatedir ${localstatedir} \ + --sharedstatedir ${sharedstatedir} \ + --wrap-mode nodownload \ + --native-file ${WORKDIR}/meson.native" + +EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" + +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: + return "" + cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() + return "rust = %s" % repr(cmd) + +addtask write_config before do_configure +do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" +do_write_config() { + # This needs to be Py to split the args into single-element lists + cat >${WORKDIR}/meson.cross <<EOF +[binaries] +c = ${@meson_array('CC', d)} +cpp = ${@meson_array('CXX', d)} +cython = 'cython3' +ar = ${@meson_array('AR', d)} +nm = ${@meson_array('NM', d)} +strip = ${@meson_array('STRIP', d)} +readelf = ${@meson_array('READELF', d)} +objcopy = ${@meson_array('OBJCOPY', d)} +pkgconfig = 'pkg-config' +llvm-config = 'llvm-config' +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)} +c_link_args = ${@meson_array('LDFLAGS', d)} +cpp_args = ${@meson_array('CXXFLAGS', d)} +cpp_link_args = ${@meson_array('LDFLAGS', d)} + +[properties] +needs_exe_wrapper = true + +[host_machine] +system = '${@meson_operating_system('HOST_OS', d)}' +cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' +cpu = '${HOST_ARCH}' +endian = '${@meson_endian('HOST', d)}' + +[target_machine] +system = '${@meson_operating_system('TARGET_OS', d)}' +cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' +cpu = '${TARGET_ARCH}' +endian = '${@meson_endian('TARGET', d)}' +EOF + + cat >${WORKDIR}/meson.native <<EOF +[binaries] +c = ${@meson_array('BUILD_CC', d)} +cpp = ${@meson_array('BUILD_CXX', d)} +cython = 'cython3' +ar = ${@meson_array('BUILD_AR', d)} +nm = ${@meson_array('BUILD_NM', d)} +strip = ${@meson_array('BUILD_STRIP', d)} +readelf = ${@meson_array('BUILD_READELF', d)} +objcopy = ${@meson_array('BUILD_OBJCOPY', d)} +pkgconfig = 'pkg-config-native' +${@rust_tool(d, "BUILD_SYS")} + +[built-in options] +c_args = ${@meson_array('BUILD_CFLAGS', d)} +c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} +cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} +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 +}meta/classes-recipe/meson.bbclass +1
-136@@ -4,141 +4,7 @@ # SPDX-License-Identifier: MIT # -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}" - -# Where the meson.build build configuration is -MESON_SOURCEPATH = "${S}" - -def noprefix(var, d): - return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) - -MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" -MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" -MESONOPTS = " --prefix ${prefix} \ - --buildtype ${MESON_BUILDTYPE} \ - --bindir ${@noprefix('bindir', d)} \ - --sbindir ${@noprefix('sbindir', d)} \ - --datadir ${@noprefix('datadir', d)} \ - --libdir ${@noprefix('libdir', d)} \ - --libexecdir ${@noprefix('libexecdir', d)} \ - --includedir ${@noprefix('includedir', d)} \ - --mandir ${@noprefix('mandir', d)} \ - --infodir ${@noprefix('infodir', d)} \ - --sysconfdir ${sysconfdir} \ - --localstatedir ${localstatedir} \ - --sharedstatedir ${sharedstatedir} \ - --wrap-mode nodownload \ - --native-file ${WORKDIR}/meson.native" - -EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" - -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: - return "" - cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() - return "rust = %s" % repr(cmd) - -addtask write_config before do_configure -do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" -do_write_config() { - # This needs to be Py to split the args into single-element lists - cat >${WORKDIR}/meson.cross <<EOF -[binaries] -c = ${@meson_array('CC', d)} -cpp = ${@meson_array('CXX', d)} -cython = 'cython3' -ar = ${@meson_array('AR', d)} -nm = ${@meson_array('NM', d)} -strip = ${@meson_array('STRIP', d)} -readelf = ${@meson_array('READELF', d)} -objcopy = ${@meson_array('OBJCOPY', d)} -pkgconfig = 'pkg-config' -llvm-config = 'llvm-config' -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)} -c_link_args = ${@meson_array('LDFLAGS', d)} -cpp_args = ${@meson_array('CXXFLAGS', d)} -cpp_link_args = ${@meson_array('LDFLAGS', d)} - -[properties] -needs_exe_wrapper = true - -[host_machine] -system = '${@meson_operating_system('HOST_OS', d)}' -cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' -cpu = '${HOST_ARCH}' -endian = '${@meson_endian('HOST', d)}' - -[target_machine] -system = '${@meson_operating_system('TARGET_OS', d)}' -cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' -cpu = '${TARGET_ARCH}' -endian = '${@meson_endian('TARGET', d)}' -EOF - - cat >${WORKDIR}/meson.native <<EOF -[binaries] -c = ${@meson_array('BUILD_CC', d)} -cpp = ${@meson_array('BUILD_CXX', d)} -cython = 'cython3' -ar = ${@meson_array('BUILD_AR', d)} -nm = ${@meson_array('BUILD_NM', d)} -strip = ${@meson_array('BUILD_STRIP', d)} -readelf = ${@meson_array('BUILD_READELF', d)} -objcopy = ${@meson_array('BUILD_OBJCOPY', d)} -pkgconfig = 'pkg-config-native' -${@rust_tool(d, "BUILD_SYS")} - -[built-in options] -c_args = ${@meson_array('BUILD_CFLAGS', d)} -c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} -cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} -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 -} +inherit meson-env # Tell externalsrc that changes to this file require a reconfigure CONFIGURE_FILES = "meson.build" --2.39.2
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#179011): https://lists.openembedded.org/g/openembedded-core/message/179011
Mute This Topic: https://lists.openembedded.org/mt/97816812/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Sure, I will send v3 shortly.
2023. 03. 24. 10:31 keltezéssel, Alexander Kanavin írta:
Quoted 352 lines
Cam you please place this information into the commit message? At some point someone will need to find out why this was done this way, and email thread would by then be hopelessly undiscoverable.
Alex
Quoted 345 lines · Böszörményi Zoltán
2023. 03. 24. 8:47 keltezéssel, Alexander Kanavin írta:
Quoted 3 lines
It would help if you explain why existing meson class can't be used directly, and what the meson class adds compared to meson-env that gets in the way of that.
The email thread for the mesonpy bbclass in
openembedded-devel lists all the problems.Summary:
* Both meson andpython_pep517classes declareEXPORT_FUNCTION. For some reason, meson always wins regardless of the inheritance order. The mesonpy class needs the meson cross compiler environment using the pep517 configure/compile/install functions.
* The meson class addsdo_qa_configurewhich fails because the mesonpy build moves the meson setup phase fromdo_configuretodo_compile. Removing items from do_configure[postfuncs] is impossible because this results in a parse error:
do_configure[postfuncs]:remove = "meson_do_qa_configure"The only option left is to split the environment setup part out of meson.bbclass.
Quoted 322 lines
Alex
Quoted 319 lines · Zoltan Boszormenyi
The new meson-env class will be used by a new PEP517 python build class using meson-python a.k.a. mesonpy.
Signed-off-by Zoltán Böszörményi <[email protected]>---
v2: The split-off part is called meson-env.bbclass
because "common" is not liked.meta/classes-recipe/meson-env.bbclass | 141 ++++++++++++++++++++++++++ meta/classes-recipe/meson.bbclass | 136 +------------------------ 2 files changed, 142 insertions(+), 135 deletions(-)create mode 100644 meta/classes-recipe/meson-env.bbclass
meta/classes-recipe/meson-env.bbclass new file +141
-0@@ -0,0 +1,141 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +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}" + +# Where the meson.build build configuration is +MESON_SOURCEPATH = "${S}" + +def noprefix(var, d): + return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) + +MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" +MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" +MESONOPTS = " --prefix ${prefix} \ + --buildtype ${MESON_BUILDTYPE} \ + --bindir ${@noprefix('bindir', d)} \ + --sbindir ${@noprefix('sbindir', d)} \ + --datadir ${@noprefix('datadir', d)} \ + --libdir ${@noprefix('libdir', d)} \ + --libexecdir ${@noprefix('libexecdir', d)} \ + --includedir ${@noprefix('includedir', d)} \ + --mandir ${@noprefix('mandir', d)} \ + --infodir ${@noprefix('infodir', d)} \ + --sysconfdir ${sysconfdir} \ + --localstatedir ${localstatedir} \ + --sharedstatedir ${sharedstatedir} \ + --wrap-mode nodownload \ + --native-file ${WORKDIR}/meson.native" + +EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" + +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: + return "" + cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() + return "rust = %s" % repr(cmd) + +addtask write_config before do_configure +do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" +do_write_config() { + # This needs to be Py to split the args into single-element lists + cat >${WORKDIR}/meson.cross <<EOF +[binaries] +c = ${@meson_array('CC', d)} +cpp = ${@meson_array('CXX', d)} +cython = 'cython3' +ar = ${@meson_array('AR', d)} +nm = ${@meson_array('NM', d)} +strip = ${@meson_array('STRIP', d)} +readelf = ${@meson_array('READELF', d)} +objcopy = ${@meson_array('OBJCOPY', d)} +pkgconfig = 'pkg-config' +llvm-config = 'llvm-config' +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)} +c_link_args = ${@meson_array('LDFLAGS', d)} +cpp_args = ${@meson_array('CXXFLAGS', d)} +cpp_link_args = ${@meson_array('LDFLAGS', d)} + +[properties] +needs_exe_wrapper = true + +[host_machine] +system = '${@meson_operating_system('HOST_OS', d)}' +cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' +cpu = '${HOST_ARCH}' +endian = '${@meson_endian('HOST', d)}' + +[target_machine] +system = '${@meson_operating_system('TARGET_OS', d)}' +cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' +cpu = '${TARGET_ARCH}' +endian = '${@meson_endian('TARGET', d)}' +EOF + + cat >${WORKDIR}/meson.native <<EOF +[binaries] +c = ${@meson_array('BUILD_CC', d)} +cpp = ${@meson_array('BUILD_CXX', d)} +cython = 'cython3' +ar = ${@meson_array('BUILD_AR', d)} +nm = ${@meson_array('BUILD_NM', d)} +strip = ${@meson_array('BUILD_STRIP', d)} +readelf = ${@meson_array('BUILD_READELF', d)} +objcopy = ${@meson_array('BUILD_OBJCOPY', d)} +pkgconfig = 'pkg-config-native' +${@rust_tool(d, "BUILD_SYS")} + +[built-in options] +c_args = ${@meson_array('BUILD_CFLAGS', d)} +c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} +cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} +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 +}meta/classes-recipe/meson.bbclass +1
-136@@ -4,141 +4,7 @@ # SPDX-License-Identifier: MIT # -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}" - -# Where the meson.build build configuration is -MESON_SOURCEPATH = "${S}" - -def noprefix(var, d): - return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) - -MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" -MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" -MESONOPTS = " --prefix ${prefix} \ - --buildtype ${MESON_BUILDTYPE} \ - --bindir ${@noprefix('bindir', d)} \ - --sbindir ${@noprefix('sbindir', d)} \ - --datadir ${@noprefix('datadir', d)} \ - --libdir ${@noprefix('libdir', d)} \ - --libexecdir ${@noprefix('libexecdir', d)} \ - --includedir ${@noprefix('includedir', d)} \ - --mandir ${@noprefix('mandir', d)} \ - --infodir ${@noprefix('infodir', d)} \ - --sysconfdir ${sysconfdir} \ - --localstatedir ${localstatedir} \ - --sharedstatedir ${sharedstatedir} \ - --wrap-mode nodownload \ - --native-file ${WORKDIR}/meson.native" - -EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" - -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: - return "" - cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() - return "rust = %s" % repr(cmd) - -addtask write_config before do_configure -do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" -do_write_config() { - # This needs to be Py to split the args into single-element lists - cat >${WORKDIR}/meson.cross <<EOF -[binaries] -c = ${@meson_array('CC', d)} -cpp = ${@meson_array('CXX', d)} -cython = 'cython3' -ar = ${@meson_array('AR', d)} -nm = ${@meson_array('NM', d)} -strip = ${@meson_array('STRIP', d)} -readelf = ${@meson_array('READELF', d)} -objcopy = ${@meson_array('OBJCOPY', d)} -pkgconfig = 'pkg-config' -llvm-config = 'llvm-config' -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)} -c_link_args = ${@meson_array('LDFLAGS', d)} -cpp_args = ${@meson_array('CXXFLAGS', d)} -cpp_link_args = ${@meson_array('LDFLAGS', d)} - -[properties] -needs_exe_wrapper = true - -[host_machine] -system = '${@meson_operating_system('HOST_OS', d)}' -cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' -cpu = '${HOST_ARCH}' -endian = '${@meson_endian('HOST', d)}' - -[target_machine] -system = '${@meson_operating_system('TARGET_OS', d)}' -cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' -cpu = '${TARGET_ARCH}' -endian = '${@meson_endian('TARGET', d)}' -EOF - - cat >${WORKDIR}/meson.native <<EOF -[binaries] -c = ${@meson_array('BUILD_CC', d)} -cpp = ${@meson_array('BUILD_CXX', d)} -cython = 'cython3' -ar = ${@meson_array('BUILD_AR', d)} -nm = ${@meson_array('BUILD_NM', d)} -strip = ${@meson_array('BUILD_STRIP', d)} -readelf = ${@meson_array('BUILD_READELF', d)} -objcopy = ${@meson_array('BUILD_OBJCOPY', d)} -pkgconfig = 'pkg-config-native' -${@rust_tool(d, "BUILD_SYS")} - -[built-in options] -c_args = ${@meson_array('BUILD_CFLAGS', d)} -c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} -cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} -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 -} +inherit meson-env # Tell externalsrc that changes to this file require a reconfigure CONFIGURE_FILES = "meson.build" --2.39.2
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#179011): https://lists.openembedded.org/g/openembedded-core/message/179011
Mute This Topic: https://lists.openembedded.org/mt/97816812/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-