• [gentoo-dev] [PATCH] meson.eclass: add EMESON_BUILDTYPE variable

    From Mike Gilbert@21:1/5 to All on Thu Oct 21 18:00:01 2021
    This allows the buildtype option to be overridden or omitted.

    This may be necessary if an ebuild makes use of the 'debug' built-in
    option control project-specific debug functionality. meson emits a
    warning if both buildtype and debug are specified, since the former
    overrides the latter.

    See discussion in https://github.com/gentoo/gentoo/pull/22574.

    Signed-off-by: Mike Gilbert <floppym@gentoo.org>
    ---
    eclass/meson.eclass | 10 +++++++++-
    1 file changed, 9 insertions(+), 1 deletion(-)

    diff --git a/eclass/meson.eclass b/eclass/meson.eclass
    index 4ba364924e4..5fab2f8df6b 100644
    --- a/eclass/meson.eclass
    +++ b/eclass/meson.eclass
    @@ -64,6 +64,11 @@ fi
    # Build directory, location where all generated files should be placed.
    # If this isn't set, it defaults to ${WORKDIR}/${P}-build.

    +# @ECLASS-VARIABLE: EMESON_BUILDTYPE
    +# @DESCRIPTION:
    +# The buildtype value to pass to meson setup.
    +: ${EMESON_BUILDTYPE=plain}
    +
    # @ECLASS-VARIABLE: EMESON_SOURCE
    # @DEFAULT_UNSET
    # @DESCRIPTION:
    @@ -310,7 +315,6 @@ meson_src_configure() {

    local mesonargs=(
    meson setup
    - --buildtype plain
    --libdir "$(get_libdir)"
    --localstatedir "${EPREFIX}/var/lib"
    --prefix "${EPREFIX}/usr"
    @@ -321,6 +325,10 @@ meson_src_configure() {
    --native-file "$(_meson_create_native_file)"
    )

    + if [[ -n ${EMESON_BUILDTYPE} ]]; then
    + mesonargs+=( --buildtype "${EMESON_BUILDTYPE}" )
    + fi
    +