From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3C60D1584AD for ; Mon, 05 May 2025 15:52:16 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 2D83D34318D for ; Mon, 05 May 2025 15:52:16 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 0278211047D; Mon, 05 May 2025 15:51:32 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 4C1A611036D for ; Mon, 05 May 2025 15:51:31 +0000 (UTC) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mattst88) by smtp.gentoo.org (Postfix) with ESMTPSA id 1F64334315C for ; Mon, 05 May 2025 15:51:31 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-54d6f93316dso3156935e87.2 for ; Mon, 05 May 2025 08:51:31 -0700 (PDT) X-Gm-Message-State: AOJu0Yx+Nn9S+/ZYdZZsogiyEGK3Ee3LS1PVFWSdl3vK90OssCw+FcCM DDveA5DPaE6rsJD16rIz6JHCgyXE9KinvcTMibcgDtFdMxQL840ASOBuqEyFyLSYDzkTSHd9LRF 5RxrL4u0iGSOFqDLpBiyFntHZIYo= X-Google-Smtp-Source: AGHT+IGfc36A2jj6MfKIMeNFCnlzEDhFQFlFM4jzivBQrV3O3QRkdL5bIpjqI8ZNtoarLCh3CYrFKPv2E0NKc7ppzFI= X-Received: by 2002:a05:6512:230f:b0:54b:117c:118a with SMTP id 2adb3069b0e04-54fa4f9a3fdmr1955663e87.55.1746460288096; Mon, 05 May 2025 08:51:28 -0700 (PDT) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 References: <20250429182949.2838222-1-mattst88@gentoo.org> <20250429182949.2838222-2-mattst88@gentoo.org> <26b42e6f6f39b2ecd5ffeb0f63d2db4de52845bd.camel@gentoo.org> In-Reply-To: <26b42e6f6f39b2ecd5ffeb0f63d2db4de52845bd.camel@gentoo.org> From: Matt Turner Date: Mon, 5 May 2025 11:51:16 -0400 X-Gmail-Original-Message-ID: X-Gm-Features: ATxdqUFI74hkAnjKbz3Kp6Ct_OujUNpKRM22PxwJFsuyCKjnpOkgayf3fMKqadA Message-ID: Subject: Re: [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass To: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= Cc: gentoo-dev@lists.gentoo.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Archives-Salt: d17add41-3be2-4d42-9b14-e0ed6619a0e0 X-Archives-Hash: d2b044ad14e66ce44ce998b088bdbc62 On Sat, May 3, 2025 at 2:05=E2=80=AFAM Micha=C5=82 G=C3=B3rny wrote: > > On Tue, 2025-04-29 at 14:28 -0400, Matt Turner wrote: > > To be used by X.Org packages with a meson build system. Largely a copy > > of xorg-3.eclass with changes necessary to switch from autotools to > > meson. > > > > Compared with xorg-3, I've dropped a few things that I don't think are > > necessary (at least initially), namely: > > > > - font support (media-libs/font-* packages); packages change very > > rarely and don't have meson build systems upstream. > > - XORG_DOC dependencies. This actually looks wrong in xorg-3? > > - asciidoc is used to generate docbook documentation (which I > > don't think we ever do in the ebuilds) > > - xmlto is used to create some man pages from XML, but the man page= s > > are checked into git so we don't ever need to generate them > > --- > > eclass/xorg-meson.eclass | 224 +++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 224 insertions(+) > > create mode 100644 eclass/xorg-meson.eclass > > > > diff --git ./eclass/xorg-meson.eclass ./eclass/xorg-meson.eclass > > new file mode 100644 > > index 000000000000..5c0a7d582479 > > --- /dev/null > > +++ ./eclass/xorg-meson.eclass > > @@ -0,0 +1,224 @@ > > +# Copyright 2025 Gentoo Authors > > +# Distributed under the terms of the GNU General Public License v2 > > + > > +# @ECLASS: xorg-meson.eclass > > +# @MAINTAINER: > > +# x11@gentoo.org > > +# @AUTHOR: > > +# Author: Matt Turner > > +# @SUPPORTED_EAPIS: 8 > > +# @PROVIDES: meson meson-multilib > > +# @BLURB: Reduces code duplication in the modularized X11 ebuilds. > > +# @DESCRIPTION: > > +# This eclass makes trivial X ebuilds possible for apps, drivers, > > +# and more. Many things that would normally be done in various functio= ns > > +# can be accessed by setting variables instead, such as patching, > > +# passing options to meson and installing docs. > > +# > > +# All you need to do in a basic ebuild is inherit this eclass and set > > +# DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted > > +# with the other X packages, you don't need to set SRC_URI. Pretty muc= h > > +# everything else should be automatic. > > + > > +case ${EAPI} in > > + 8) ;; > > + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; > > +esac > > + > > +if [[ -z ${_XORG_MESON_ECLASS} ]]; then > > +_XORG_MESON_ECLASS=3D1 > > + > > +GIT_ECLASS=3D"" > > +if [[ ${PV} =3D=3D *9999* ]]; then > > + GIT_ECLASS=3D"git-r3" > > +fi > > + > > +# @ECLASS_VARIABLE: XORG_MULTILIB > > +# @PRE_INHERIT > > +# @DESCRIPTION: > > +# If set to 'yes', the multilib support for package will be enabled. S= et > > +# before inheriting this eclass. > > +: "${XORG_MULTILIB:=3D"no"}" > > + > > +inherit flag-o-matic ${GIT_ECLASS} > > +unset GIT_ECLASS > > + > > +[[ ${XORG_MULTILIB} =3D=3D yes ]] && inherit meson-multilib || inherit= meson > > + > > +# @ECLASS_VARIABLE: XORG_BASE_INDIVIDUAL_URI > > +# @PRE_INHERIT > > +# @DESCRIPTION: > > +# Set up SRC_URI for individual modular releases. If set to an empty > > +# string, no SRC_URI will be provided by the eclass. > > +: "${XORG_BASE_INDIVIDUAL_URI=3D"https://www.x.org/releases/individual= "}" > > + > > +# @ECLASS_VARIABLE: XORG_MODULE > > +# @PRE_INHERIT > > +# @DESCRIPTION: > > +# The subdirectory to download source from. Possible settings are app, > > +# doc, data, util, driver, font, lib, proto, xserver. Set above the > > +# inherit to override the default autoconfigured module. > > +: "${XORG_MODULE:=3D"auto"}" > > +if [[ ${XORG_MODULE} =3D=3D auto ]]; then > > + case "${CATEGORY}/${P}" in > > + app-doc/*) XORG_MODULE=3Ddoc/ ;; > > + media-fonts/*) XORG_MODULE=3Dfont/ ;; > > + x11-apps/*|x11-wm/*) XORG_MODULE=3Dapp/ ;; > > + x11-misc/*|x11-themes/*) XORG_MODULE=3Dutil/ ;; > > + x11-base/*) XORG_MODULE=3Dxserver/ ;; > > + x11-drivers/*) XORG_MODULE=3Ddriver/ ;; > > + x11-libs/*) XORG_MODULE=3Dlib/ ;; > > + *) XORG_MODULE=3D ;; > > + esac > > +fi > > + > > +# @ECLASS_VARIABLE: XORG_PACKAGE_NAME > > +# @PRE_INHERIT > > +# @DESCRIPTION: > > +# For git checkout the git repository might differ from package name. > > +# This variable can be used for proper directory specification > > +: "${XORG_PACKAGE_NAME:=3D${PN}}" > > + > > +HOMEPAGE=3D"https://www.x.org/wiki/ https://gitlab.freedesktop.org/xor= g/${XORG_MODULE}${XORG_PACKAGE_NAME}" > > + > > +# @ECLASS_VARIABLE: XORG_TARBALL_SUFFIX > > +# @PRE_INHERIT > > +# @DESCRIPTION: > > +# Most X11 projects provide tarballs as tar.xz. This eclass defaults t= o xz. > > +: "${XORG_TARBALL_SUFFIX:=3D"xz"}" > > + > > +if [[ ${PV} =3D=3D *9999* ]]; then > > + : "${EGIT_REPO_URI:=3D"https://gitlab.freedesktop.org/xorg/${XORG= _MODULE}${XORG_PACKAGE_NAME}.git"}" > > +elif [[ -n ${XORG_BASE_INDIVIDUAL_URI} ]]; then > > + SRC_URI=3D"${XORG_BASE_INDIVIDUAL_URI}/${XORG_MODULE}${P}.tar.${X= ORG_TARBALL_SUFFIX}" > > +fi > > + > > +: "${SLOT:=3D0}" > > + > > +# Set the license for the package. This can be overridden by setting > > +# LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages > > +# are under the MIT license. > > +: "${LICENSE:=3DMIT}" > > + > > +if [[ ${PN} =3D=3D xf86-video-* || ${PN} =3D=3D xf86-input-* ]]; then > > + DEPEND+=3D" x11-base/xorg-proto" > > + RDEPEND+=3D" x11-base/xorg-server:=3D" > > + COMMON_DEPEND+=3D" >=3Dx11-base/xorg-server-1.20[xorg]" > > + [[ ${PN} =3D=3D xf86-video-* ]] && COMMON_DEPEND+=3D" >=3Dx11-lib= s/libpciaccess-0.14" > > At this point, I'd suggest removing COMMON_DEPEND entirely and just > inlining that stuff twice. In the end, xorg-server is explicitly > in RDEPEND already, and listing libpciaccess twice doesn't seem like > a big deal to me. Thanks, changed. > > +fi > > +BDEPEND+=3D" virtual/pkgconfig" > > + > > +# @ECLASS_VARIABLE: XORG_DOC > > +# @PRE_INHERIT > > +# @DESCRIPTION: > > +# Controls the installation of man3 developer documentation. Possible = values > > +# are the name of the useflag or "no". Default value is "no". > > +: "${XORG_DOC:=3D"no"}" > > What if I wanted to name the USE flag 'no'? xP Sorry :) > > + > > +case ${XORG_DOC} in > > + no) > > + ;; > > + *) > > + IUSE+=3D" ${XORG_DOC}" > > + ;; > > +esac > > + > > +DEPEND+=3D" ${COMMON_DEPEND}" > > +RDEPEND+=3D" ${COMMON_DEPEND}" > > +unset COMMON_DEPEND > > + > > +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=3D${DEPEND}" > > +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=3D${RDEPEND}" > > +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=3D${PDEPEND}" > > +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: BDEPEND=3D${BDEPEND}" > > + > > +# @FUNCTION: xorg-meson_src_unpack > > +# @DESCRIPTION: > > +# Simply unpack source code. > > +xorg-meson_src_unpack() { > > + debug-print-function ${FUNCNAME} "$@" > > + > > + if [[ ${PV} =3D=3D *9999* ]]; then > > + git-r3_src_unpack > > + else > > + unpack ${A} > > + fi > > +} > > + > > +# @FUNCTION: xorg-meson_flags_setup > > +# @DESCRIPTION: > > +# Set up CFLAGS for a debug build > > +xorg-meson_flags_setup() { > > + debug-print-function ${FUNCNAME} "$@" > > + > > + # Hardened flags break module autoloading et al (also fixes #7784= 94) > > + if [[ ${PN} =3D=3D xorg-server || ${PN} =3D=3D xf86-video-* || ${= PN} =3D=3D xf86-input-* ]]; then > > + filter-flags -fno-plt > > + append-ldflags -Wl,-z,lazy > > + fi > > +} > > + > > +# @VARIABLE: XORG_CONFIGURE_OPTIONS > > +# @DESCRIPTION: > > +# Array of an additional options to pass to meson setup. > > +# @DEFAULT_UNSET > > All tags must go before @DESCRIPTION. Fixed, thanks. > > + > > +# @FUNCTION: xorg-meson_src_configure > > +# @DESCRIPTION: > > +# Perform any necessary pre-configuration steps, then run configure > > +xorg-meson_src_configure() { > > + debug-print-function ${FUNCNAME} "$@" > > + > > + xorg-meson_flags_setup > > + > > + local emesonargs=3D( > > + -Ddefault_library=3Dshared > > + "${XORG_CONFIGURE_OPTIONS[@]}" > > + ) > > + > > + if [[ ${XORG_MULTILIB} =3D=3D yes ]]; then > > + meson-multilib_src_configure "$@" > > + else > > + meson_src_configure "$@" > > + fi > > +} > > + > > +# @FUNCTION: xorg-meson_src_compile > > +# @DESCRIPTION: > > +# Compile a package, performing all X-related tasks. > > +xorg-meson_src_compile() { > > + debug-print-function ${FUNCNAME} "$@" > > + > > + if [[ ${XORG_MULTILIB} =3D=3D yes ]]; then > > + meson-multilib_src_compile "$@" > > + else > > + meson_src_compile "$@" > > + fi > > +} > > + > > +# @FUNCTION: xorg-meson_src_install > > +# @DESCRIPTION: > > +# Install a built package to ${D}, performing any necessary steps. > > +xorg-meson_src_install() { > > + debug-print-function ${FUNCNAME} "$@" > > + > > + if [[ ${XORG_MULTILIB} =3D=3D yes ]]; then > > + meson-multilib_src_install "$@" > > + else > > + meson_src_install "$@" > > + fi > > + > > + # Many X11 libraries unconditionally install developer documentat= ion > > + if [[ -d "${D}"/usr/share/man/man3 ]]; then > > Maybe add '&& ! in_iuse doc' to the if? > > > + ! in_iuse doc && eqawarn "ebuild should set XORG_DOC=3Ddo= c since package installs man3 documentation" > > + fi > > + > > + if in_iuse doc && ! use doc; then > > + rm -rf "${D}"/usr/share/man/man3 > > || die > > > + rmdir "${D}"/usr{/share{/man,},} 2>/dev/null > > I generally prefer 'find -type d -empty -delete || die' over ignoring > errors. Thanks, fixed. > > + fi > > +} > > + > > +fi > > + > > +EXPORT_FUNCTIONS src_configure src_unpack src_compile src_install > > -- > Best regards, > Micha=C5=82 G=C3=B3rny >