From: Matt Turner <mattst88@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
Date: Mon, 5 May 2025 11:55:53 -0400 [thread overview]
Message-ID: <20250505155609.322817-1-mattst88@gentoo.org> (raw)
In-Reply-To: <20250429182949.2838222-2-mattst88@gentoo.org>
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 pages
are checked into git so we don't ever need to generate them
---
eclass/xorg-meson.eclass | 209 +++++++++++++++++++++++++++++++++++++++
1 file changed, 209 insertions(+)
create mode 100644 eclass/xorg-meson.eclass
diff --git ./eclass/xorg-meson.eclass ./eclass/xorg-meson.eclass
new file mode 100644
index 000000000000..afb77e348618
--- /dev/null
+++ ./eclass/xorg-meson.eclass
@@ -0,0 +1,209 @@
+# 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 <mattst88@gentoo.org>
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: meson meson-multilib
+# @BLURB: Reduces code duplication in the X11 ebuilds.
+# @DESCRIPTION:
+# This eclass makes trivial X ebuilds possible for apps, drivers,
+# and more. Many things that would normally be done in various functions
+# 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 much
+# 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=1
+
+inherit flag-o-matic
+
+if [[ ${PV} == *9999* ]]; then
+ inherit git-r3
+fi
+
+# @ECLASS_VARIABLE: XORG_MULTILIB
+# @PRE_INHERIT
+# @DESCRIPTION:
+# If set to 'yes', multilib support for package will be enabled. Set
+# before inheriting this eclass.
+: "${XORG_MULTILIB:="no"}"
+
+[[ ${XORG_MULTILIB} == yes ]] && inherit meson-multilib || inherit meson
+
+# @ECLASS_VARIABLE: XORG_BASE_INDIVIDUAL_URI
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Set up SRC_URI for individual releases. If set to an empty
+# string, no SRC_URI will be provided by the eclass.
+: "${XORG_BASE_INDIVIDUAL_URI="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:="auto"}"
+if [[ ${XORG_MODULE} == auto ]]; then
+ case "${CATEGORY}/${P}" in
+ app-doc/*) XORG_MODULE=doc/ ;;
+ media-fonts/*) XORG_MODULE=font/ ;;
+ x11-apps/*|x11-wm/*) XORG_MODULE=app/ ;;
+ x11-misc/*|x11-themes/*) XORG_MODULE=util/ ;;
+ x11-base/*) XORG_MODULE=xserver/ ;;
+ x11-drivers/*) XORG_MODULE=driver/ ;;
+ x11-libs/*) XORG_MODULE=lib/ ;;
+ *) XORG_MODULE= ;;
+ 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:=${PN}}"
+
+HOMEPAGE="https://www.x.org/wiki/ https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}"
+
+# @ECLASS_VARIABLE: XORG_TARBALL_SUFFIX
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Most X11 projects provide tarballs as tar.xz. This eclass defaults to xz.
+: "${XORG_TARBALL_SUFFIX:="xz"}"
+
+if [[ ${PV} == *9999* ]]; then
+ : "${EGIT_REPO_URI:="https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}.git"}"
+elif [[ -n ${XORG_BASE_INDIVIDUAL_URI} ]]; then
+ SRC_URI="${XORG_BASE_INDIVIDUAL_URI}/${XORG_MODULE}${P}.tar.${XORG_TARBALL_SUFFIX}"
+fi
+
+: "${SLOT:=0}"
+
+# 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:=MIT}"
+
+if [[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]]; then
+ DEPEND+=" x11-base/xorg-proto"
+ DEPEND+=" >=x11-base/xorg-server-1.20:=[xorg]"
+ RDEPEND+=" >=x11-base/xorg-server-1.20:=[xorg]"
+ if [[ ${PN} == xf86-video-* ]]; then
+ DEPEND+=" >=x11-libs/libpciaccess-0.14"
+ RDEPEND+=" >=x11-libs/libpciaccess-0.14"
+ fi
+fi
+BDEPEND+=" 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:="no"}"
+
+case ${XORG_DOC} in
+ no)
+ ;;
+ *)
+ IUSE+=" ${XORG_DOC}"
+ ;;
+esac
+
+debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}"
+debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
+debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=${PDEPEND}"
+debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: BDEPEND=${BDEPEND}"
+
+# @FUNCTION: xorg-meson_src_unpack
+# @DESCRIPTION:
+# Simply unpack source code.
+xorg-meson_src_unpack() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ if [[ ${PV} == *9999* ]]; then
+ git-r3_src_unpack
+ else
+ unpack ${A}
+ fi
+}
+
+# @FUNCTION: xorg-meson_flags_setup
+# @INTERNAL
+# @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 #778494)
+ if [[ ${PN} == xorg-server || ${PN} == xf86-video-* || ${PN} == xf86-input-* ]]; then
+ filter-flags -fno-plt
+ append-ldflags -Wl,-z,lazy
+ fi
+}
+
+# @VARIABLE: XORG_CONFIGURE_OPTIONS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Array of an additional options to pass to meson setup.
+
+# @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=(
+ -Ddefault_library=shared
+ "${XORG_CONFIGURE_OPTIONS[@]}"
+ )
+
+ if [[ ${XORG_MULTILIB} == yes ]]; then
+ meson-multilib_src_configure "$@"
+ else
+ meson_src_configure "$@"
+ fi
+}
+
+# @FUNCTION: xorg-meson_src_install
+# @DESCRIPTION:
+# Install a built package to ${ED}, performing any necessary steps.
+xorg-meson_src_install() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ if [[ ${XORG_MULTILIB} == yes ]]; then
+ meson-multilib_src_install "$@"
+ else
+ meson_src_install "$@"
+ fi
+
+ # Many X11 libraries unconditionally install developer documentation
+ if ! in_iuse doc && [[ -d "${ED}"/usr/share/man/man3 ]]; then
+ eqawarn "ebuild should set XORG_DOC=doc since package installs man3 documentation"
+ fi
+
+ if in_iuse doc && ! use doc; then
+ rm -rf "${ED}"/usr/share/man/man3 || die
+ find "${ED}"/usr -type d -empty -delete || die
+ fi
+}
+
+fi
+
+EXPORT_FUNCTIONS src_unpack src_configure src_install
--
2.49.0
next prev parent reply other threads:[~2025-05-05 15:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 18:28 [gentoo-dev] [RFC 1/3] eclass: Add eqawarn to xorg-3.eclass if package contains a meson.build Matt Turner
2025-04-29 18:28 ` [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass Matt Turner
2025-05-03 6:05 ` Michał Górny
2025-05-05 15:51 ` Matt Turner
2025-05-03 6:28 ` Sam James
2025-05-05 15:54 ` Matt Turner
2025-05-05 15:55 ` Matt Turner [this message]
2025-04-29 18:28 ` [gentoo-dev] [RFC 3/3] */*: Example of switching packages from xorg-3 -> xorg-meson Matt Turner
2025-05-03 6:22 ` [gentoo-dev] [RFC 1/3] eclass: Add eqawarn to xorg-3.eclass if package contains a meson.build Sam James
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=20250505155609.322817-1-mattst88@gentoo.org \
--to=mattst88@gentoo.org \
--cc=gentoo-dev@lists.gentoo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox