* [gentoo-dev] [RFC 1/3] eclass: Add eqawarn to xorg-3.eclass if package contains a meson.build
@ 2025-04-29 18:28 Matt Turner
2025-04-29 18:28 ` [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass Matt Turner
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Matt Turner @ 2025-04-29 18:28 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Turner
---
eclass/xorg-3.eclass | 4 ++++
1 file changed, 4 insertions(+)
diff --git ./eclass/xorg-3.eclass ./eclass/xorg-3.eclass
index 4947cb86b8b0..81df265c922f 100644
--- ./eclass/xorg-3.eclass
+++ ./eclass/xorg-3.eclass
@@ -285,6 +285,10 @@ xorg-3_reconf_source() {
xorg-3_src_prepare() {
debug-print-function ${FUNCNAME} "$@"
+ if [[ -e meson.build ]]; then
+ eqawarn "Package contains a meson.build and should be migrated to xorg-meson.eclass if possible"
+ fi
+
default
xorg-3_reconf_source
}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
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 ` Matt Turner
2025-05-03 6:05 ` Michał Górny
` (2 more replies)
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
2 siblings, 3 replies; 9+ messages in thread
From: Matt Turner @ 2025-04-29 18:28 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Turner
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 | 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 <mattst88@gentoo.org>
+# @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 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
+
+GIT_ECLASS=""
+if [[ ${PV} == *9999* ]]; then
+ GIT_ECLASS="git-r3"
+fi
+
+# @ECLASS_VARIABLE: XORG_MULTILIB
+# @PRE_INHERIT
+# @DESCRIPTION:
+# If set to 'yes', the multilib support for package will be enabled. Set
+# before inheriting this eclass.
+: "${XORG_MULTILIB:="no"}"
+
+inherit flag-o-matic ${GIT_ECLASS}
+unset GIT_ECLASS
+
+[[ ${XORG_MULTILIB} == 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="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"
+ RDEPEND+=" x11-base/xorg-server:="
+ COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
+ [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/libpciaccess-0.14"
+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
+
+DEPEND+=" ${COMMON_DEPEND}"
+RDEPEND+=" ${COMMON_DEPEND}"
+unset COMMON_DEPEND
+
+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
+# @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
+# @DESCRIPTION:
+# Array of an additional options to pass to meson setup.
+# @DEFAULT_UNSET
+
+# @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_compile
+# @DESCRIPTION:
+# Compile a package, performing all X-related tasks.
+xorg-meson_src_compile() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ if [[ ${XORG_MULTILIB} == 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} == yes ]]; then
+ meson-multilib_src_install "$@"
+ else
+ meson_src_install "$@"
+ fi
+
+ # Many X11 libraries unconditionally install developer documentation
+ if [[ -d "${D}"/usr/share/man/man3 ]]; then
+ ! in_iuse doc && eqawarn "ebuild should set XORG_DOC=doc since package installs man3 documentation"
+ fi
+
+ if in_iuse doc && ! use doc; then
+ rm -rf "${D}"/usr/share/man/man3
+ rmdir "${D}"/usr{/share{/man,},} 2>/dev/null
+ fi
+}
+
+fi
+
+EXPORT_FUNCTIONS src_configure src_unpack src_compile src_install
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-dev] [RFC 3/3] */*: Example of switching packages from xorg-3 -> xorg-meson
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-04-29 18:28 ` 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
2 siblings, 0 replies; 9+ messages in thread
From: Matt Turner @ 2025-04-29 18:28 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Turner
---
Just an example of the changes needed to port from xorg-3 to xorg-meson.
Not to actually land -- ebuilds would either be converted during a
version bump or with a revbump.
media-fonts/encodings/encodings-1.1.0.ebuild | 11 +++--------
x11-apps/xisxwayland/xisxwayland-2.ebuild | 9 ++-------
x11-apps/xisxwayland/xisxwayland-9999.ebuild | 9 ++-------
x11-base/xorg-server/xorg-server-21.1.16.ebuild | 15 +++++++--------
x11-base/xorg-server/xorg-server-9999.ebuild | 17 ++++++++---------
.../xf86-input-wacom-1.2.3.ebuild | 8 ++++----
x11-libs/libXau/libXau-1.0.12.ebuild | 2 +-
x11-libs/libXft/libXft-2.3.9.ebuild | 2 +-
x11-libs/libXvMC/libXvMC-1.0.14.ebuild | 16 ++--------------
.../libpciaccess/libpciaccess-0.18.1.ebuild | 14 +++++---------
x11-libs/libxcvt/libxcvt-0.1.3.ebuild | 7 +------
x11-libs/libxcvt/libxcvt-9999.ebuild | 9 ++-------
x11-misc/rendercheck/rendercheck-1.6.ebuild | 10 ++--------
x11-misc/rendercheck/rendercheck-9999.ebuild | 10 ++--------
14 files changed, 42 insertions(+), 97 deletions(-)
diff --git ./media-fonts/encodings/encodings-1.1.0.ebuild ./media-fonts/encodings/encodings-1.1.0.ebuild
index d27332421526..8a0621336af1 100644
--- ./media-fonts/encodings/encodings-1.1.0.ebuild
+++ ./media-fonts/encodings/encodings-1.1.0.ebuild
@@ -5,7 +5,7 @@ EAPI=8
# font eclass is inherited directly, since this package is a special case that
# would greatly complicate the fonts logic of xorg-3
-inherit font xorg-3 meson
+inherit font xorg-meson
DESCRIPTION="X.Org font encodings"
@@ -13,14 +13,9 @@ KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390
BDEPEND="x11-apps/mkfontscale"
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
-
src_configure() {
- local emesonargs=(
+ local XORG_CONFIGURE_OPTIONS=(
-Dfontrootdir="${EPREFIX}"/usr/share/fonts
)
- meson_src_configure
+ xorg-meson_src_configure
}
diff --git ./x11-apps/xisxwayland/xisxwayland-2.ebuild ./x11-apps/xisxwayland/xisxwayland-2.ebuild
index 2c8b87718a37..9397aff453f3 100644
--- ./x11-apps/xisxwayland/xisxwayland-2.ebuild
+++ ./x11-apps/xisxwayland/xisxwayland-2.ebuild
@@ -1,9 +1,9 @@
-# Copyright 2020-2024 Gentoo Authors
+# Copyright 2020-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-inherit xorg-3 meson
+inherit xorg-meson
if [[ ${PV} != *9999* ]]; then
KEYWORDS="amd64 ~loong"
@@ -16,8 +16,3 @@ RDEPEND="
x11-libs/libXrandr"
DEPEND="${RDEPEND}
x11-base/xorg-proto"
-
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
diff --git ./x11-apps/xisxwayland/xisxwayland-9999.ebuild ./x11-apps/xisxwayland/xisxwayland-9999.ebuild
index 2c8b87718a37..9397aff453f3 100644
--- ./x11-apps/xisxwayland/xisxwayland-9999.ebuild
+++ ./x11-apps/xisxwayland/xisxwayland-9999.ebuild
@@ -1,9 +1,9 @@
-# Copyright 2020-2024 Gentoo Authors
+# Copyright 2020-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-inherit xorg-3 meson
+inherit xorg-meson
if [[ ${PV} != *9999* ]]; then
KEYWORDS="amd64 ~loong"
@@ -16,8 +16,3 @@ RDEPEND="
x11-libs/libXrandr"
DEPEND="${RDEPEND}
x11-base/xorg-proto"
-
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
diff --git ./x11-base/xorg-server/xorg-server-21.1.16.ebuild ./x11-base/xorg-server/xorg-server-21.1.16.ebuild
index 3c1ae3e1c2be..d65ca93e7aa7 100644
--- ./x11-base/xorg-server/xorg-server-21.1.16.ebuild
+++ ./x11-base/xorg-server/xorg-server-21.1.16.ebuild
@@ -3,8 +3,7 @@
EAPI=8
-XORG_EAUTORECONF="no"
-inherit flag-o-matic xorg-3 meson
+inherit flag-o-matic xorg-meson
EGIT_REPO_URI="https://gitlab.freedesktop.org/xorg/xserver.git"
DESCRIPTION="X.Org X servers"
@@ -113,7 +112,7 @@ src_configure() {
# localstatedir is used for the log location; we need to override the default
# from ebuild.sh
# sysconfdir is used for the xorg.conf location; same applies
- local emesonargs=(
+ local XORG_CONFIGURE_OPTIONS=(
--localstatedir "${EPREFIX}/var"
--sysconfdir "${EPREFIX}/etc/X11"
-Dbuildtype=$(usex debug debug plain)
@@ -146,26 +145,26 @@ src_configure() {
if [[ ${PV} == 9999 ]] ; then
# Gone in 21.1.x, but not in master.
- emesonargs+=( -Dxwayland=false )
+ XORG_CONFIGURE_OPTIONS+=( -Dxwayland=false )
fi
if use systemd || use elogind; then
- emesonargs+=(
+ XORG_CONFIGURE_OPTIONS+=(
-Dsystemd_logind=true
$(meson_use suid suid_wrapper)
)
else
- emesonargs+=(
+ XORG_CONFIGURE_OPTIONS+=(
-Dsystemd_logind=false
-Dsuid_wrapper=false
)
fi
- meson_src_configure
+ xorg-meson_src_configure
}
src_install() {
- meson_src_install
+ xorg-meson_src_install
# The meson build system does not support install-setuid
if ! use systemd && ! use elogind; then
diff --git ./x11-base/xorg-server/xorg-server-9999.ebuild ./x11-base/xorg-server/xorg-server-9999.ebuild
index b5b0e5a96c8e..a95ac63e8f27 100644
--- ./x11-base/xorg-server/xorg-server-9999.ebuild
+++ ./x11-base/xorg-server/xorg-server-9999.ebuild
@@ -1,10 +1,9 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-XORG_EAUTORECONF="no"
-inherit flag-o-matic xorg-3 meson
+inherit flag-o-matic xorg-meson
EGIT_REPO_URI="https://gitlab.freedesktop.org/xorg/xserver.git"
DESCRIPTION="X.Org X servers"
@@ -110,7 +109,7 @@ src_configure() {
# localstatedir is used for the log location; we need to override the default
# from ebuild.sh
# sysconfdir is used for the xorg.conf location; same applies
- local emesonargs=(
+ local XORG_CONFIGURE_OPTIONS=(
--localstatedir "${EPREFIX}/var"
--sysconfdir "${EPREFIX}/etc/X11"
-Db_ndebug=$(usex debug false true)
@@ -141,26 +140,26 @@ src_configure() {
if [[ ${PV} == 9999 ]] ; then
# Gone in 21.1.x, but not in master.
- emesonargs+=( -Dxwayland=false )
+ XORG_CONFIGURE_OPTIONS+=( -Dxwayland=false )
fi
if use systemd || use elogind; then
- emesonargs+=(
+ XORG_CONFIGURE_OPTIONS+=(
-Dsystemd_logind=true
$(meson_use suid suid_wrapper)
)
else
- emesonargs+=(
+ XORG_CONFIGURE_OPTIONS+=(
-Dsystemd_logind=false
-Dsuid_wrapper=false
)
fi
- meson_src_configure
+ xorg-meson_src_configure
}
src_install() {
- meson_src_install
+ xorg-meson_src_install
# The meson build system does not support install-setuid
if ! use systemd && ! use elogind; then
diff --git ./x11-drivers/xf86-input-wacom/xf86-input-wacom-1.2.3.ebuild ./x11-drivers/xf86-input-wacom/xf86-input-wacom-1.2.3.ebuild
index 8d3e38056e6b..b7e5033ae432 100644
--- ./x11-drivers/xf86-input-wacom/xf86-input-wacom-1.2.3.ebuild
+++ ./x11-drivers/xf86-input-wacom/xf86-input-wacom-1.2.3.ebuild
@@ -3,7 +3,7 @@
EAPI=8
-inherit linux-info systemd udev xorg-3 meson
+inherit linux-info systemd udev xorg-meson
DESCRIPTION="Driver for Wacom tablets and drawing devices"
HOMEPAGE="https://linuxwacom.github.io/"
@@ -43,15 +43,15 @@ pkg_setup() {
}
src_configure() {
- xorg-3_flags_setup
+ xorg-meson_flags_setup
- local emesonargs=(
+ local XORG_CONFIGURE_OPTIONS=(
-Dsystemd-unit-dir="$(systemd_get_systemunitdir)"
-Dudev-rules-dir="$(get_udevdir)/rules.d"
$(meson_feature test unittests)
-Dwacom-gobject=disabled
)
- meson_src_configure
+ xorg-meson_src_configure
}
pkg_postinst() {
diff --git ./x11-libs/libXau/libXau-1.0.12.ebuild ./x11-libs/libXau/libXau-1.0.12.ebuild
index 4555e7fcb0bd..b33a04d4eb73 100644
--- ./x11-libs/libXau/libXau-1.0.12.ebuild
+++ ./x11-libs/libXau/libXau-1.0.12.ebuild
@@ -5,7 +5,7 @@ EAPI=8
XORG_DOC=doc
XORG_MULTILIB=yes
-inherit xorg-3
+inherit xorg-meson
DESCRIPTION="X.Org X authorization library"
diff --git ./x11-libs/libXft/libXft-2.3.9.ebuild ./x11-libs/libXft/libXft-2.3.9.ebuild
index dd60251365ba..8120ef341ae2 100644
--- ./x11-libs/libXft/libXft-2.3.9.ebuild
+++ ./x11-libs/libXft/libXft-2.3.9.ebuild
@@ -4,7 +4,7 @@
EAPI=8
XORG_MULTILIB=yes
-inherit xorg-3
+inherit xorg-meson
DESCRIPTION="X.Org Xft library"
diff --git ./x11-libs/libXvMC/libXvMC-1.0.14.ebuild ./x11-libs/libXvMC/libXvMC-1.0.14.ebuild
index 93430e9de52b..dfd43c3d2a46 100644
--- ./x11-libs/libXvMC/libXvMC-1.0.14.ebuild
+++ ./x11-libs/libXvMC/libXvMC-1.0.14.ebuild
@@ -1,10 +1,10 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
XORG_MULTILIB=yes
-inherit xorg-3 meson-multilib
+inherit xorg-meson
DESCRIPTION="X.Org XvMC library"
@@ -18,18 +18,6 @@ RDEPEND="
DEPEND="${RDEPEND}
x11-base/xorg-proto"
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
-
-multilib_src_configure() {
- local emesonargs=(
- -Ddefault_library=shared
- )
- meson_src_configure
-}
-
multilib_src_install_all() {
einstalldocs
mv "${ED}"/usr/share/doc/{${PN},${P}}/XvMC_API.txt || die
diff --git ./x11-libs/libpciaccess/libpciaccess-0.18.1.ebuild ./x11-libs/libpciaccess/libpciaccess-0.18.1.ebuild
index b698148f8e09..da00c618c892 100644
--- ./x11-libs/libpciaccess/libpciaccess-0.18.1.ebuild
+++ ./x11-libs/libpciaccess/libpciaccess-0.18.1.ebuild
@@ -1,10 +1,10 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
XORG_MULTILIB=yes
-inherit xorg-3 meson-multilib
+inherit xorg-meson
DESCRIPTION="Library providing generic access to the PCI bus and devices"
KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~x64-solaris"
@@ -15,14 +15,10 @@ DEPEND="
RDEPEND="${DEPEND}
sys-apps/hwdata"
-src_prepare() {
- default
-}
-
-multilib_src_configure() {
- local emesonargs=(
+src_configure() {
+ local XORG_CONFIGURE_OPTIONS=(
-Dpci-ids="${EPREFIX}"/usr/share/hwdata
$(meson_feature zlib)
)
- meson_src_configure
+ xorg-meson_src_configure
}
diff --git ./x11-libs/libxcvt/libxcvt-0.1.3.ebuild ./x11-libs/libxcvt/libxcvt-0.1.3.ebuild
index 426847c19cfe..a2f7cf41dc3e 100644
--- ./x11-libs/libxcvt/libxcvt-0.1.3.ebuild
+++ ./x11-libs/libxcvt/libxcvt-0.1.3.ebuild
@@ -3,15 +3,10 @@
EAPI=8
-inherit xorg-3 meson
+inherit xorg-meson
if [[ ${PV} != *9999* ]]; then
KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
fi
DESCRIPTION="X.Org xcvt library and cvt program"
-
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
diff --git ./x11-libs/libxcvt/libxcvt-9999.ebuild ./x11-libs/libxcvt/libxcvt-9999.ebuild
index 1653d2ad10a4..e84c7c548fb6 100644
--- ./x11-libs/libxcvt/libxcvt-9999.ebuild
+++ ./x11-libs/libxcvt/libxcvt-9999.ebuild
@@ -1,17 +1,12 @@
-# Copyright 2021-2024 Gentoo Authors
+# Copyright 2021-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-inherit xorg-3 meson
+inherit xorg-meson
if [[ ${PV} != *9999* ]]; then
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
fi
DESCRIPTION="X.Org xcvt library and cvt program"
-
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
diff --git ./x11-misc/rendercheck/rendercheck-1.6.ebuild ./x11-misc/rendercheck/rendercheck-1.6.ebuild
index 9d5943e0a598..e6a837f1420e 100644
--- ./x11-misc/rendercheck/rendercheck-1.6.ebuild
+++ ./x11-misc/rendercheck/rendercheck-1.6.ebuild
@@ -1,10 +1,10 @@
-# Copyright 2024 Gentoo Authors
+# Copyright 2024-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
XORG_MODULE=test/
-inherit xorg-3 meson
+inherit xorg-meson
if [[ ${PV} != *9999* ]]; then
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86"
@@ -23,9 +23,3 @@ DEPEND="
${RDEPEND}
x11-base/xorg-proto
"
-BDEPEND="virtual/pkgconfig"
-
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
diff --git ./x11-misc/rendercheck/rendercheck-9999.ebuild ./x11-misc/rendercheck/rendercheck-9999.ebuild
index c9265373ea8b..44c0cf2573c5 100644
--- ./x11-misc/rendercheck/rendercheck-9999.ebuild
+++ ./x11-misc/rendercheck/rendercheck-9999.ebuild
@@ -1,10 +1,10 @@
-# Copyright 2024 Gentoo Authors
+# Copyright 2024-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
XORG_MODULE=test/
-inherit xorg-3 meson
+inherit xorg-meson
if [[ ${PV} != *9999* ]]; then
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
@@ -23,9 +23,3 @@ DEPEND="
${RDEPEND}
x11-base/xorg-proto
"
-BDEPEND="virtual/pkgconfig"
-
-# Override xorg-3's src_prepare
-src_prepare() {
- default
-}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
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:55 ` Matt Turner
2 siblings, 1 reply; 9+ messages in thread
From: Michał Górny @ 2025-05-03 6:05 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Turner
[-- Attachment #1: Type: text/plain, Size: 9064 bytes --]
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 pages
> 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 <mattst88@gentoo.org>
> +# @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 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
> +
> +GIT_ECLASS=""
> +if [[ ${PV} == *9999* ]]; then
> + GIT_ECLASS="git-r3"
> +fi
> +
> +# @ECLASS_VARIABLE: XORG_MULTILIB
> +# @PRE_INHERIT
> +# @DESCRIPTION:
> +# If set to 'yes', the multilib support for package will be enabled. Set
> +# before inheriting this eclass.
> +: "${XORG_MULTILIB:="no"}"
> +
> +inherit flag-o-matic ${GIT_ECLASS}
> +unset GIT_ECLASS
> +
> +[[ ${XORG_MULTILIB} == 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="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"
> + RDEPEND+=" x11-base/xorg-server:="
> + COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
> + [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/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.
> +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"}"
What if I wanted to name the USE flag 'no'? xP
> +
> +case ${XORG_DOC} in
> + no)
> + ;;
> + *)
> + IUSE+=" ${XORG_DOC}"
> + ;;
> +esac
> +
> +DEPEND+=" ${COMMON_DEPEND}"
> +RDEPEND+=" ${COMMON_DEPEND}"
> +unset COMMON_DEPEND
> +
> +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
> +# @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
> +# @DESCRIPTION:
> +# Array of an additional options to pass to meson setup.
> +# @DEFAULT_UNSET
All tags must go before @DESCRIPTION.
> +
> +# @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_compile
> +# @DESCRIPTION:
> +# Compile a package, performing all X-related tasks.
> +xorg-meson_src_compile() {
> + debug-print-function ${FUNCNAME} "$@"
> +
> + if [[ ${XORG_MULTILIB} == 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} == yes ]]; then
> + meson-multilib_src_install "$@"
> + else
> + meson_src_install "$@"
> + fi
> +
> + # Many X11 libraries unconditionally install developer documentation
> + 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=doc 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.
> + fi
> +}
> +
> +fi
> +
> +EXPORT_FUNCTIONS src_configure src_unpack src_compile src_install
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [RFC 1/3] eclass: Add eqawarn to xorg-3.eclass if package contains a meson.build
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-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 ` Sam James
2 siblings, 0 replies; 9+ messages in thread
From: Sam James @ 2025-05-03 6:22 UTC (permalink / raw
To: Matt Turner; +Cc: gentoo-dev
Matt Turner <mattst88@gentoo.org> writes:
> ---
> eclass/xorg-3.eclass | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git ./eclass/xorg-3.eclass ./eclass/xorg-3.eclass
> index 4947cb86b8b0..81df265c922f 100644
> --- ./eclass/xorg-3.eclass
> +++ ./eclass/xorg-3.eclass
> @@ -285,6 +285,10 @@ xorg-3_reconf_source() {
> xorg-3_src_prepare() {
> debug-print-function ${FUNCNAME} "$@"
>
> + if [[ -e meson.build ]]; then
Maybe drop the extra space.
> + eqawarn "Package contains a meson.build and should be migrated to xorg-meson.eclass if possible"
> + fi
> +
> default
> xorg-3_reconf_source
> }
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
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-03 6:28 ` Sam James
2025-05-05 15:54 ` Matt Turner
2025-05-05 15:55 ` Matt Turner
2 siblings, 1 reply; 9+ messages in thread
From: Sam James @ 2025-05-03 6:28 UTC (permalink / raw
To: Matt Turner; +Cc: gentoo-dev
Matt Turner <mattst88@gentoo.org> writes:
> 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.
Seems reasonable. We can add that later if needed (or give them their
own eclass if things necessitated that).
> - 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
Heh, I think I remember being confused about this before.
> ---
> 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 <mattst88@gentoo.org>
> +# @SUPPORTED_EAPIS: 8
> +# @PROVIDES: meson meson-multilib
> +# @BLURB: Reduces code duplication in the modularized X11 ebuilds.
IMO "modularized" in 2025 looks odd, it's obvious, but feel free to keep
it.
> +# @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
> +
> +GIT_ECLASS=""
> +if [[ ${PV} == *9999* ]]; then
> + GIT_ECLASS="git-r3"
> +fi
> +
> +# @ECLASS_VARIABLE: XORG_MULTILIB
> +# @PRE_INHERIT
> +# @DESCRIPTION:
> +# If set to 'yes', the multilib support for package will be enabled. Set
s/the//
> +# before inheriting this eclass.
> +: "${XORG_MULTILIB:="no"}"
> +
> +inherit flag-o-matic ${GIT_ECLASS}
> +unset GIT_ECLASS
Just call inherit twice (once earlier on), let's not bother with the variable and then
having to unset it.
> +
> +[[ ${XORG_MULTILIB} == 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="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"
> + RDEPEND+=" x11-base/xorg-server:="
> + COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
> + [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/libpciaccess-0.14"
> +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
> +
> +DEPEND+=" ${COMMON_DEPEND}"
> +RDEPEND+=" ${COMMON_DEPEND}"
> +unset COMMON_DEPEND
> +
> +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
> +# @DESCRIPTION:
> +# Set up CFLAGS for a debug build
Make this an internal function, maybe?
> +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
> +# @DESCRIPTION:
> +# Array of an additional options to pass to meson setup.
> +# @DEFAULT_UNSET
> +
> +# @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 "$@"
If you wanted, you could (earlier on) set ${_XORG_MESON} or something,
and then use that like:
${_XORG_MESON}_src_configure
... but who cares.
> + 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} == yes ]]; then
> + meson-multilib_src_compile "$@"
> + else
> + meson_src_compile "$@"
> + fi
> +}
> +
You're missing src_test? Does it Just Work? (If so, why do we need
xorg-meson_src_compile then?)
> +# @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} == yes ]]; then
> + meson-multilib_src_install "$@"
> + else
> + meson_src_install "$@"
> + fi
> +
> + # Many X11 libraries unconditionally install developer documentation
> + if [[ -d "${D}"/usr/share/man/man3 ]]; then
${ED} and below
> + ! in_iuse doc && eqawarn "ebuild should set XORG_DOC=doc since package installs man3 documentation"
> + fi
> +
> + if in_iuse doc && ! use doc; then
> + rm -rf "${D}"/usr/share/man/man3
> + rmdir "${D}"/usr{/share{/man,},} 2>/dev/null
> + fi
> +}
> +
> +fi
> +
> +EXPORT_FUNCTIONS src_configure src_unpack src_compile src_install
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
2025-05-03 6:05 ` Michał Górny
@ 2025-05-05 15:51 ` Matt Turner
0 siblings, 0 replies; 9+ messages in thread
From: Matt Turner @ 2025-05-05 15:51 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-dev
On Sat, May 3, 2025 at 2:05 AM Michał Górny <mgorny@gentoo.org> 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 pages
> > 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 <mattst88@gentoo.org>
> > +# @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 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
> > +
> > +GIT_ECLASS=""
> > +if [[ ${PV} == *9999* ]]; then
> > + GIT_ECLASS="git-r3"
> > +fi
> > +
> > +# @ECLASS_VARIABLE: XORG_MULTILIB
> > +# @PRE_INHERIT
> > +# @DESCRIPTION:
> > +# If set to 'yes', the multilib support for package will be enabled. Set
> > +# before inheriting this eclass.
> > +: "${XORG_MULTILIB:="no"}"
> > +
> > +inherit flag-o-matic ${GIT_ECLASS}
> > +unset GIT_ECLASS
> > +
> > +[[ ${XORG_MULTILIB} == 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="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"
> > + RDEPEND+=" x11-base/xorg-server:="
> > + COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
> > + [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/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+=" 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"}"
>
> What if I wanted to name the USE flag 'no'? xP
Sorry :)
> > +
> > +case ${XORG_DOC} in
> > + no)
> > + ;;
> > + *)
> > + IUSE+=" ${XORG_DOC}"
> > + ;;
> > +esac
> > +
> > +DEPEND+=" ${COMMON_DEPEND}"
> > +RDEPEND+=" ${COMMON_DEPEND}"
> > +unset COMMON_DEPEND
> > +
> > +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
> > +# @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
> > +# @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=(
> > + -Ddefault_library=shared
> > + "${XORG_CONFIGURE_OPTIONS[@]}"
> > + )
> > +
> > + if [[ ${XORG_MULTILIB} == 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} == 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} == yes ]]; then
> > + meson-multilib_src_install "$@"
> > + else
> > + meson_src_install "$@"
> > + fi
> > +
> > + # Many X11 libraries unconditionally install developer documentation
> > + 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=doc 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ł Górny
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
2025-05-03 6:28 ` Sam James
@ 2025-05-05 15:54 ` Matt Turner
0 siblings, 0 replies; 9+ messages in thread
From: Matt Turner @ 2025-05-05 15:54 UTC (permalink / raw
To: Sam James; +Cc: gentoo-dev
On Sat, May 3, 2025 at 2:28 AM Sam James <sam@gentoo.org> wrote:
>
> Matt Turner <mattst88@gentoo.org> writes:
>
> > 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.
>
> Seems reasonable. We can add that later if needed (or give them their
> own eclass if things necessitated that).
>
> > - 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
>
> Heh, I think I remember being confused about this before.
>
> > ---
> > 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 <mattst88@gentoo.org>
> > +# @SUPPORTED_EAPIS: 8
> > +# @PROVIDES: meson meson-multilib
> > +# @BLURB: Reduces code duplication in the modularized X11 ebuilds.
>
> IMO "modularized" in 2025 looks odd, it's obvious, but feel free to keep
> it.
Agreed. Removed.
> > +# @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
> > +
> > +GIT_ECLASS=""
> > +if [[ ${PV} == *9999* ]]; then
> > + GIT_ECLASS="git-r3"
> > +fi
> > +
> > +# @ECLASS_VARIABLE: XORG_MULTILIB
> > +# @PRE_INHERIT
> > +# @DESCRIPTION:
> > +# If set to 'yes', the multilib support for package will be enabled. Set
>
> s/the//
Thanks, fixed.
> > +# before inheriting this eclass.
> > +: "${XORG_MULTILIB:="no"}"
> > +
> > +inherit flag-o-matic ${GIT_ECLASS}
> > +unset GIT_ECLASS
>
> Just call inherit twice (once earlier on), let's not bother with the variable and then
> having to unset it.
Sounds good, fixed.
> > +
> > +[[ ${XORG_MULTILIB} == 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="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"
> > + RDEPEND+=" x11-base/xorg-server:="
> > + COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
> > + [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/libpciaccess-0.14"
> > +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
> > +
> > +DEPEND+=" ${COMMON_DEPEND}"
> > +RDEPEND+=" ${COMMON_DEPEND}"
> > +unset COMMON_DEPEND
> > +
> > +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
> > +# @DESCRIPTION:
> > +# Set up CFLAGS for a debug build
>
> Make this an internal function, maybe?
Thanks, fixed.
> > +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
> > +# @DESCRIPTION:
> > +# Array of an additional options to pass to meson setup.
> > +# @DEFAULT_UNSET
> > +
> > +# @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 "$@"
>
> If you wanted, you could (earlier on) set ${_XORG_MESON} or something,
> and then use that like:
> ${_XORG_MESON}_src_configure
> ... but who cares.
After removing the src_compile implementation, there are only two
instances so I'll just keep it as-is for now.
> > + 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} == yes ]]; then
> > + meson-multilib_src_compile "$@"
> > + else
> > + meson_src_compile "$@"
> > + fi
> > +}
> > +
>
> You're missing src_test? Does it Just Work? (If so, why do we need
> xorg-meson_src_compile then?)
Ah, good catch. Indeed, we don't need src_test nor src_compile.
Removed src_compile.
> > +# @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} == yes ]]; then
> > + meson-multilib_src_install "$@"
> > + else
> > + meson_src_install "$@"
> > + fi
> > +
> > + # Many X11 libraries unconditionally install developer documentation
> > + if [[ -d "${D}"/usr/share/man/man3 ]]; then
>
> ${ED} and below
Thanks, fixed.
>
> > + ! in_iuse doc && eqawarn "ebuild should set XORG_DOC=doc since package installs man3 documentation"
> > + fi
> > +
> > + if in_iuse doc && ! use doc; then
> > + rm -rf "${D}"/usr/share/man/man3
> > + rmdir "${D}"/usr{/share{/man,},} 2>/dev/null
> > + fi
> > +}
> > +
> > +fi
> > +
> > +EXPORT_FUNCTIONS src_configure src_unpack src_compile src_install
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gentoo-dev] [RFC 2/3] eclass: Add xorg-meson eclass
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-03 6:28 ` Sam James
@ 2025-05-05 15:55 ` Matt Turner
2 siblings, 0 replies; 9+ messages in thread
From: Matt Turner @ 2025-05-05 15:55 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Turner
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-05-05 15:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox