All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Kelly <mkelly@xevo.com>
To: "Burton, Ross" <ross.burton@intel.com>
Cc: OE-core <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH v2 7/7] meson: enable nativesdk
Date: Mon, 7 Jan 2019 17:54:12 +0000	[thread overview]
Message-ID: <db1d1175-3104-eb1f-a3ca-66c7c362aa4a@xevo.com> (raw)
In-Reply-To: <CAJTo0LY-16oCyFf-etweZq1P5=DpOtG8Qou0pQHMa0mZkXvPaA@mail.gmail.com>

On 1/7/19 4:41 AM, Burton, Ross wrote:
> I added a test case to actually build something with Meson on the
> autobuilder, and this breaks for multilib SDKs.  These ship multiple
> environment files, so the cross generation can't happen at relocate
> time.
> 
> Ross
> 

Could you elaborate on exactly what is breaking, or do you have a link 
to the autobuilder breakage?

To give a bit of background, cmake handles this by putting env vars 
directly into the wrapper script. However, meson does not support env 
vars in its cross toolchain file (and upstream is resistant to adding 
it), so we are left with generating paths at relocate time.

> On Fri, 1 Jun 2018 at 22:04, Martin Kelly <mkelly@xevo.com> wrote:
>>
>> 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.
>>
>> Signed-off-by: Martin Kelly <mkelly@xevo.com>
>> ---
>>   meta/recipes-devtools/meson/meson.inc              | 22 +++++++
>>   meta/recipes-devtools/meson/meson/meson-setup.py   | 62 ++++++++++++++++++
>>   meta/recipes-devtools/meson/meson/meson-wrapper    | 14 ++++
>>   meta/recipes-devtools/meson/meson_0.46.1.bb        | 22 +------
>>   .../meson/nativesdk-meson_0.46.1.bb                | 74 ++++++++++++++++++++++
>>   5 files changed, 173 insertions(+), 21 deletions(-)
>>   create mode 100644 meta/recipes-devtools/meson/meson.inc
>>   create mode 100755 meta/recipes-devtools/meson/meson/meson-setup.py
>>   create mode 100755 meta/recipes-devtools/meson/meson/meson-wrapper
>>   create mode 100644 meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
>>
>> diff --git a/meta/recipes-devtools/meson/meson.inc b/meta/recipes-devtools/meson/meson.inc
>> new file mode 100644
>> index 0000000000..4c113dcaf7
>> --- /dev/null
>> +++ b/meta/recipes-devtools/meson/meson.inc
>> @@ -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"
>> diff --git a/meta/recipes-devtools/meson/meson/meson-setup.py b/meta/recipes-devtools/meson/meson/meson-setup.py
>> new file mode 100755
>> index 0000000000..a9749eae9d
>> --- /dev/null
>> +++ b/meta/recipes-devtools/meson/meson/meson-setup.py
>> @@ -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)
>> diff --git a/meta/recipes-devtools/meson/meson/meson-wrapper b/meta/recipes-devtools/meson/meson/meson-wrapper
>> new file mode 100755
>> index 0000000000..b2e00da513
>> --- /dev/null
>> +++ b/meta/recipes-devtools/meson/meson/meson-wrapper
>> @@ -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" \
>> +     "$@"
>> diff --git a/meta/recipes-devtools/meson/meson_0.46.1.bb b/meta/recipes-devtools/meson/meson_0.46.1.bb
>> index 77f6416cc2..897fa148d9 100644
>> --- a/meta/recipes-devtools/meson/meson_0.46.1.bb
>> +++ b/meta/recipes-devtools/meson/meson_0.46.1.bb
>> @@ -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"
>> diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb b/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
>> new file mode 100644
>> index 0000000000..53503aa998
>> --- /dev/null
>> +++ b/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
>> @@ -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}"
>> --
>> 2.11.0
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core

  reply	other threads:[~2019-01-08  0:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 21:02 [PATCH v2 0/7] meson: implement nativesdk support Martin Kelly
2018-06-01 21:02 ` [PATCH v2 1/7] meson.bbclass: refactor native override Martin Kelly
2018-06-01 21:02 ` [PATCH v2 2/7] nativesdk-python*: suppress user site dirs Martin Kelly
2018-06-01 21:02 ` [PATCH v2 3/7] toolchain-shar-extract: allow non-sh post-relocate Martin Kelly
2018-06-01 21:02 ` [PATCH v2 4/7] toolchain-shar-extract: print post-relocate error Martin Kelly
2018-06-01 21:57   ` Joshua Watt
2018-06-01 22:00     ` Martin Kelly
2018-06-01 21:02 ` [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate Martin Kelly
2018-06-01 22:08   ` Joshua Watt
2018-06-01 22:24     ` Martin Kelly
2018-06-04 17:20       ` Joshua Watt
2018-06-04 18:10         ` Martin Kelly
2018-06-04 18:20           ` Joshua Watt
2018-06-04 18:24             ` Martin Kelly
2018-06-04 18:42               ` Joshua Watt
2018-06-04 19:12                 ` Martin Kelly
2018-06-01 21:02 ` [PATCH v2 6/7] meson: handle exe wrappers Martin Kelly
2018-06-01 21:02 ` [PATCH v2 7/7] meson: enable nativesdk Martin Kelly
2019-01-07 12:41   ` Burton, Ross
2019-01-07 17:54     ` Martin Kelly [this message]
2019-01-07 17:55       ` Burton, Ross
2019-01-07 19:03         ` Martin Kelly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db1d1175-3104-eb1f-a3ca-66c7c362aa4a@xevo.com \
    --to=mkelly@xevo.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=ross.burton@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.