This is necessary in order to get at the implementation of `meson setup`
from other eclasses, which do not simply call meson_src_configure. The
intended use case is distutils-r1, where a python build backend wraps
meson and needs its arguments while calling meson on its own.

This allows distutils-r1 to invoke `setup_meson_src_configure` followed
by gpep517, and get access to:
- the preparation which needs to be done, including setting up the
  environment
- the array of setup arguments

Signed-off-by: Eli Schwartz <eschwart...@gmail.com>
---

v2: new patch

 eclass/meson.eclass | 49 +++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index e1963e552710..620381ed7079 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -277,15 +277,12 @@ meson_feature() {
        usex "$1" "-D${2-$1}=enabled" "-D${2-$1}=disabled"
 }
 
-# @FUNCTION: meson_src_configure
-# @USAGE: [extra meson arguments]
+# @FUNCTION: setup_meson_src_configure
 # @DESCRIPTION:
-# This is the meson_src_configure function.
-meson_src_configure() {
-       debug-print-function ${FUNCNAME} "$@"
-
-       [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for 
\${NINJA}"
-
+# Calculate the command line which meson should use, and other relevant
+# variables. Invoke via "${mesonargs[@]}" in the calling environment.
+# This function is called from meson_src_configure.
+setup_meson_src_configure() {
        local ltoflags=()
        if tc-is-lto; then
                # We want to connect -flto in *FLAGS to the dedicated meson 
option,
@@ -344,8 +341,7 @@ meson_src_configure() {
                : "${BUILD_PKG_CONFIG_PATH:=${PKG_CONFIG_PATH}}"
        fi
 
-       local mesonargs=(
-               meson setup
+       mesonargs=(
                --libdir "$(get_libdir)"
                --localstatedir "${EPREFIX}/var/lib"
                --prefix "${EPREFIX}/usr"
@@ -390,12 +386,6 @@ meson_src_configure() {
 
                # Arguments from user
                "${MYMESONARGS[@]}"
-
-               # Source directory
-               "${EMESON_SOURCE:-${S}}"
-
-               # Build directory
-               "${BUILD_DIR}"
        )
 
        # Used by symbolextractor.py
@@ -407,13 +397,32 @@ meson_src_configure() {
        python_export_utf8_locale
 
        # https://bugs.gentoo.org/721786
-       local -x BOOST_INCLUDEDIR="${BOOST_INCLUDEDIR-${EPREFIX}/usr/include}"
-       local -x 
BOOST_LIBRARYDIR="${BOOST_LIBRARYDIR-${EPREFIX}/usr/$(get_libdir)}"
+       export BOOST_INCLUDEDIR="${BOOST_INCLUDEDIR-${EPREFIX}/usr/include}"
+       export 
BOOST_LIBRARYDIR="${BOOST_LIBRARYDIR-${EPREFIX}/usr/$(get_libdir)}"
+}
+
+# @FUNCTION: meson_src_configure
+# @USAGE: [extra meson arguments]
+# @DESCRIPTION:
+# This is the meson_src_configure function.
+meson_src_configure() {
+       debug-print-function ${FUNCNAME} "$@"
+
+       [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for 
\${NINJA}"
 
        (
+               setup_meson_src_configure "$@"
+               mesonargs+=(
+                       # Source directory
+                       "${EMESON_SOURCE:-${S}}"
+
+                       # Build directory
+                       "${BUILD_DIR}"
+               )
+
                export -n {C,CPP,CXX,F,OBJC,OBJCXX,LD}FLAGS 
PKG_CONFIG_{LIBDIR,PATH}
-               echo "${mesonargs[@]}" >&2
-               "${mesonargs[@]}"
+               echo meson setup "${mesonargs[@]}" >&2
+               meson setup "${mesonargs[@]}"
        ) || die
 }
 
-- 
2.43.0


Reply via email to