All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ross Burton" <ross@burtonini.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2 3/3] meson: use native-file instead of environment variables
Date: Thu, 25 Mar 2021 17:39:01 +0000	[thread overview]
Message-ID: <20210325173901.3057180-3-ross.burton@arm.com> (raw)
In-Reply-To: <20210325173901.3057180-1-ross.burton@arm.com>

Meson now supports native-files, which are the same as cross files but
describe the native build.

By writing and using a native file which describes the tools to use, we
can drop the environment variable overriding.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes/meson.bbclass | 54 +++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 30 deletions(-)

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index a7644e70cb..bf9b02e06e 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -26,7 +26,8 @@ MESONOPTS = " --prefix ${prefix} \
               --sysconfdir ${sysconfdir} \
               --localstatedir ${localstatedir} \
               --sharedstatedir ${sharedstatedir} \
-              --wrap-mode nodownload"
+              --wrap-mode nodownload \
+              --native-file ${WORKDIR}/meson.native"
 
 EXTRA_OEMESON_append = " ${PACKAGECONFIG_CONFARGS}"
 
@@ -102,12 +103,14 @@ cups-config = 'cups-config'
 g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper'
 g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper'
 
-[properties]
-needs_exe_wrapper = true
+[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
 gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
 
 [host_machine]
@@ -121,9 +124,27 @@ 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)}
+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 = ${@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
 }
 
+# Tell externalsrc that changes to this file require a reconfigure
 CONFIGURE_FILES = "meson.build"
 
 meson_do_configure() {
@@ -140,33 +161,6 @@ meson_do_configure() {
     fi
 }
 
-override_native_tools() {
-    # Set these so that meson uses the native tools for its build sanity tests,
-    # which require executables to be runnable. The cross file will still
-    # override these for the target build.
-    export CC="${BUILD_CC}"
-    export CXX="${BUILD_CXX}"
-    export LD="${BUILD_LD}"
-    export AR="${BUILD_AR}"
-    export STRIP="${BUILD_STRIP}"
-    # These contain *target* flags but will be used as *native* flags.  The
-    # correct native flags will be passed via -Dc_args and so on, unset them so
-    # they don't interfere with tools invoked by Meson (such as g-ir-scanner)
-    unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
-}
-
-meson_do_configure_prepend_class-target() {
-    override_native_tools
-}
-
-meson_do_configure_prepend_class-nativesdk() {
-    override_native_tools
-}
-
-meson_do_configure_prepend_class-native() {
-    export PKG_CONFIG="pkg-config-native"
-}
-
 python meson_do_qa_configure() {
     import re
     warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE)
-- 
2.25.1


  parent reply	other threads:[~2021-03-25 17:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 17:38 [PATCH v2 1/3] meson: fix native/host confusion in gobject-introspection Ross Burton
2021-03-25 17:39 ` [PATCH v2 2/3] bitbake.conf: ensure BUILD_* tools match target tools Ross Burton
2021-03-25 17:39 ` Ross Burton [this message]
2021-03-25 18:15 ` [OE-core] [PATCH v2 1/3] meson: fix native/host confusion in gobject-introspection Alexander Kanavin
2021-03-25 19:07   ` Ross Burton
2021-03-26 18:48     ` Khem Raj
2021-03-29  9:25       ` Ross Burton
2021-03-29 15:26         ` Khem Raj

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=20210325173901.3057180-3-ross.burton@arm.com \
    --to=ross@burtonini.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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.